about summary refs log tree commit diff
path: root/main.go
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@gmail.com>2017-02-08T10·51+0100
committerVincent Ambo <tazjin@gmail.com>2017-02-08T10·51+0100
commit8fb24f9f750c4d87f1f36f11ca80f86c78832be6 (patch)
treee519a1584e72998d1b0b1058474385de492123bf /main.go
parent9e3ee3f2bbce7c7cb2aaea3de2ffb23b17a030ca (diff)
feat main: Initial program implementation & example
Diffstat (limited to 'main.go')
-rw-r--r--main.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/main.go b/main.go
new file mode 100644
index 0000000000..c33ec133d7
--- /dev/null
+++ b/main.go
@@ -0,0 +1,39 @@
+package main
+
+import (
+	"os"
+	"fmt"
+
+	"github.com/tazjin/kontemplate/context"
+	"github.com/tazjin/kontemplate/templater"
+)
+
+func main() {
+	args := os.Args[1:]
+	if len(args) == 0 {
+		fmt.Fprintln(os.Stderr, "Usage: kontemplate <cluster-config>")
+		os.Exit(1)
+	}
+
+	c, err := context.LoadContextFromFile(os.Args[1])
+
+	if err != nil {
+		fmt.Fprintf(os.Stderr, "%v\n", err)
+		os.Exit(1)
+	}
+
+	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)
+		resources, err := templater.LoadAndPrepareTemplates(c)
+
+		if err != nil {
+			fmt.Println(err)
+		}
+
+		for _, r := range resources {
+			fmt.Print(r)
+		}
+	}
+}