|
32 | 32 | actionHelp bool
|
33 | 33 | errorStop bool
|
34 | 34 | isTemplate bool
|
| 35 | + missingOk bool |
35 | 36 | varFlags arrFlags
|
36 | 37 | )
|
37 | 38 |
|
@@ -100,6 +101,7 @@ func init() {
|
100 | 101 | flag.BoolVar(&isJSON, "json", false, "Spec-file is in JSON format (will try to detect format if none of --yaml or --json is set)")
|
101 | 102 | flag.BoolVar(&errorStop, "stop-on-error", false, "Exit on first occurred error")
|
102 | 103 | flag.BoolVar(&isTemplate, "template", false, "Spec-file is a template")
|
| 104 | + flag.BoolVar(&missingOk, "missingok", false, "Ignore missing template keys") |
103 | 105 | flag.BoolVar(&verbose, "verbose", false, "Verbose output")
|
104 | 106 | flag.Var(&varFlags, "var", "Variable for templating")
|
105 | 107 | flag.Usage = func() {
|
@@ -604,7 +606,12 @@ func parseSpecFile() (Spec, error) {
|
604 | 606 | }
|
605 | 607 |
|
606 | 608 | if isTemplate {
|
607 |
| - t, err := template.New("").Option("missingkey=error").Parse(string(specFile)) |
| 609 | + t := template.New("") |
| 610 | + if missingOk { |
| 611 | + t, err = t.Parse(string(specFile)) |
| 612 | + } else { |
| 613 | + t, err = t.Option("missingkey=error").Parse(string(specFile)) |
| 614 | + } |
608 | 615 | if err != nil {
|
609 | 616 | return spec, err
|
610 | 617 | }
|
@@ -914,6 +921,7 @@ Usage: %s <action> [<options>] [<broker connection options>]
|
914 | 921 | Env variables and from --var arguments (--var arguments are
|
915 | 922 | taking precedence)
|
916 | 923 | --var Variable in format "key=value". Can be presented multiple times
|
| 924 | + --missingok Do not fail if template key is not defined |
917 | 925 | --verbose Verbose output
|
918 | 926 | --stop-on-error Exit on first occurred error
|
919 | 927 | ----------------
|
|
0 commit comments