Skip to content
This repository has been archived by the owner on Dec 21, 2019. It is now read-only.

Commit

Permalink
chore: Better example & gofmt
Browse files Browse the repository at this point in the history
  • Loading branch information
tazjin committed Feb 8, 2017
1 parent 8fb24f9 commit 8fac7c1
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 14 deletions.
2 changes: 1 addition & 1 deletion example/prod-cluster.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"context": "k8s.prod.mydomain.com",
"global": {
"globalTest": "lizards"
"globalVar": "lizards"
},
"include": [
{
Expand Down
Empty file removed example/some-api/deployment.yaml
Empty file.
5 changes: 0 additions & 5 deletions example/some-api/service.yaml

This file was deleted.

34 changes: 34 additions & 0 deletions example/some-api/some-api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: some-api
spec:
replicas: 1
template:
metadata:
labels:
app: some-api
spec:
containers:
- image: my.container.repo/some-api:{{ .version }}
name: some-api
env:
- name: ENABLE_IMPORTANT_FEATURE
value: {{ .importantFeature }}
- name: SOME_GLOBAL_VAR
value: {{ .globalVar }}
---
apiVersion: v1
kind: Service
metadata:
name: some-api
labels:
app: some-api
spec:
selector:
app: some-api
ports:
- port: 80
targetPort: {{ .apiPort }}
name: http
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package main

import (
"os"
"fmt"
"os"

"github.com/tazjin/kontemplate/context"
"github.com/tazjin/kontemplate/templater"
Expand All @@ -22,10 +22,10 @@ func main() {
os.Exit(1)
}

fmt.Fprintf(os.Stderr,"Applying cluster %s\n", c.Name)
fmt.Fprintf(os.Stderr, "Applying cluster %s\n", c.Name)

for _, rs := range c.ResourceSets {
fmt.Fprintf(os.Stderr,"Applying resource %s with values %v\n", rs.Name, rs.Values)
fmt.Fprintf(os.Stderr, "Applying resource %s with values %v\n", rs.Name, rs.Values)
resources, err := templater.LoadAndPrepareTemplates(c)

if err != nil {
Expand Down
9 changes: 4 additions & 5 deletions templater/templater.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package templater

import (
"bytes"
"fmt"
"io/ioutil"
"strings"
"os"
"path"
"strings"
"text/template"
"bytes"

"github.com/tazjin/kontemplate/context"
"github.com/polydawn/meep"
"github.com/tazjin/kontemplate/context"
)

// Error that is caused by non-existent template files being specified
Expand All @@ -28,7 +28,7 @@ func LoadAndPrepareTemplates(c *context.Context) ([]string, error) {
output := make([]string, 0)

for _, rs := range c.ResourceSets {
fmt.Fprintf(os.Stderr,"Loading resources for %s\n", rs.Name)
fmt.Fprintf(os.Stderr, "Loading resources for %s\n", rs.Name)

rp := path.Join(c.BaseDir, rs.Name)
files, err := ioutil.ReadDir(rp)
Expand All @@ -40,7 +40,6 @@ func LoadAndPrepareTemplates(c *context.Context) ([]string, error) {
)
}


for _, file := range files {
if !file.IsDir() && isResourceFile(file) {
p := path.Join(rp, file.Name())
Expand Down

0 comments on commit 8fac7c1

Please sign in to comment.