Skip to content

Commit

Permalink
Merge pull request #1 from qikiqi/add-apply-dry-runs
Browse files Browse the repository at this point in the history
Add apply dry-run client&server
  • Loading branch information
qikiqi committed Sep 6, 2021
2 parents 56ada4a + 19a9fba commit e9024b8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,11 @@ Examples:
# Look at output for a specific resource set and check to see if it's correct ...
kontemplate template example/prod-cluster.yaml -i some-api

# ... maybe do a dry-run to see what kubectl would do:
kontemplate apply example/prod-cluster.yaml --dry-run
+# ... maybe do an apply dry-run=client to see what kubectl would do:
kontemplate apply example/prod-cluster.yaml --dry-run

+# ... or maybe do an apply dry-run=server to see what kubectl would do:
+kontemplate apply example/prod-cluster.yaml --dry-run-server

# And actually apply it if you like what you see:
kontemplate apply example/prod-cluster.yaml
Expand Down
11 changes: 7 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ var (
templateFile = template.Arg("file", "Cluster configuration file to use").Required().String()
templateOutputDir = template.Flag("output", "Output directory in which to save templated files instead of printing them").Short('o').String()

apply = app.Command("apply", "Template resources and pass to 'kubectl apply'")
applyFile = apply.Arg("file", "Cluster configuration file to use").Required().String()
applyDryRun = apply.Flag("dry-run", "Print remote operations without executing them").Default("false").Bool()
apply = app.Command("apply", "Template resources and pass to 'kubectl apply'")
applyFile = apply.Arg("file", "Cluster configuration file to use").Required().String()
applyDryRun = apply.Flag("dry-run", "Print remote operations without executing them (--dry-run=client)").Default("false").Bool()
applyDryRunServer = apply.Flag("dry-run-server", "Print remote operations without executing them (--dry-run=server)").Default("false").Bool()

replace = app.Command("replace", "Template resources and pass to 'kubectl replace'")
replaceFile = replace.Arg("file", "Cluster configuration file to use").Required().String()
Expand Down Expand Up @@ -147,7 +148,9 @@ func applyCommand() {
var kubectlArgs []string

if *applyDryRun {
kubectlArgs = []string{"apply", "-f", "-", "--dry-run"}
kubectlArgs = []string{"apply", "-f", "-", "--dry-run=client"}
} else if *applyDryRunServer {
kubectlArgs = []string{"apply", "-f", "-", "--dry-run=server"}
} else {
kubectlArgs = []string{"apply", "-f", "-"}
}
Expand Down

0 comments on commit e9024b8

Please sign in to comment.