1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
package main
import (
"fmt"
"os"
"github.com/polydawn/meep"
"github.com/tazjin/kontemplate/context"
"github.com/tazjin/kontemplate/templater"
"github.com/urfave/cli"
)
func main() {
app := cli.NewApp()
app.Name = "kontemplate"
app.Usage = "simple Kubernetes resource templating"
app.Version = "0.0.1"
app.Commands = []cli.Command{
ApplyCommand(),
}
app.Run(os.Args)
}
func ApplyCommand() cli.Command {
return cli.Command{
Name: "run",
Usage: "Interpolate and print templates",
Flags: []cli.Flag{
cli.StringFlag{
Name: "file, f",
Usage: "Cluster configuration file to use",
},
cli.StringSliceFlag{
Name: "limit, l",
Usage: "Limit templating to certain resource sets",
},
},
Action: func(c *cli.Context) error {
limit := c.StringSlice("limit")
f := c.String("file")
if f == "" {
return meep.New(
&meep.ErrInvalidParam{
Param: "file",
Reason: "Cluster config file must be specified",
},
)
}
ctx, err := context.LoadContextFromFile(f)
if err != nil {
return err
}
resources, err := templater.LoadAndPrepareTemplates(&limit, ctx)
if err != nil {
return err
}
for _, r := range resources {
fmt.Println(r)
}
return nil
},
}
}
|