about summary refs log tree commit diff
path: root/main.go
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@gmail.com>2017-02-08T15·44+0100
committerVincent Ambo <tazjin@gmail.com>2017-02-08T15·53+0100
commit8e08a282eb4f29618c8de8090927b521ea0c9c2b (patch)
tree7a2731061681c8ddfc22a6d3af0255e8a33d12aa /main.go
parent11a5cf9e192b57eb594ce276ef7723693ff28014 (diff)
feat templater: Add ability to exclude resource sets
* renamed --limit to --include (-i)
* added --exclude (-e)

Kontemplate users can now explicitly include and exclude certain resource sets.
Excludes always override includes.

Closes #11
Diffstat (limited to 'main.go')
-rw-r--r--main.go23
1 files changed, 15 insertions, 8 deletions
diff --git a/main.go b/main.go
index 1a775bf7c5..f6e4921435 100644
--- a/main.go
+++ b/main.go
@@ -37,9 +37,10 @@ func templateCommand() cli.Command {
 		Usage: "Interpolate and print templates",
 		Flags: commonFlags(),
 		Action: func(c *cli.Context) error {
-			limit := c.StringSlice("limit")
+			include := c.StringSlice("include")
+			exclude := c.StringSlice("exclude")
 			ctx, err := loadContext(c)
-			resources, err := templater.LoadAndPrepareTemplates(&limit, ctx)
+			resources, err := templater.LoadAndPrepareTemplates(&include, &exclude, ctx)
 
 			if err != nil {
 				return err
@@ -66,9 +67,10 @@ func applyCommand() cli.Command {
 			Destination: &dryRun,
 		}),
 		Action: func(c *cli.Context) error {
-			limit := c.StringSlice("limit")
+			include := c.StringSlice("include")
+			exclude := c.StringSlice("exclude")
 			ctx, err := loadContext(c)
-			resources, err := templater.LoadAndPrepareTemplates(&limit, ctx)
+			resources, err := templater.LoadAndPrepareTemplates(&include, &exclude, ctx)
 
 			if err != nil {
 				return err
@@ -92,9 +94,10 @@ func replaceCommand() cli.Command {
 		Usage: "Interpolate templates and run 'kubectl replace'",
 		Flags: commonFlags(),
 		Action: func(c *cli.Context) error {
-			limit := c.StringSlice("limit")
+			include := c.StringSlice("include")
+			exclude := c.StringSlice("exclude")
 			ctx, err := loadContext(c)
-			resources, err := templater.LoadAndPrepareTemplates(&limit, ctx)
+			resources, err := templater.LoadAndPrepareTemplates(&include, &exclude, ctx)
 
 			if err != nil {
 				return err
@@ -140,8 +143,12 @@ func commonFlags() []cli.Flag {
 			Usage: "Cluster configuration file to use",
 		},
 		cli.StringSliceFlag{
-			Name:  "limit, l",
-			Usage: "Limit templating to certain resource sets",
+			Name:  "include, i",
+			Usage: "Limit templating to explicitly included resource sets",
+		},
+		cli.StringSliceFlag{
+			Name:  "exclude, e",
+			Usage: "Exclude certain resource sets from templating",
 		},
 	}
 }