diff --git a/runner/cmd_config.go b/runner/cmd_config.go index 2512605560fedefe97c3fac9c71a91633b117d51_cnVubmVyL2NtZF9jb25maWcuZ28=..e6d2d49e5342b5852ddea6ce786bc82010692453_cnVubmVyL2NtZF9jb25maWcuZ28= 100644 --- a/runner/cmd_config.go +++ b/runner/cmd_config.go @@ -267,11 +267,12 @@ type CmdCharts map[string]CmdChart type CmdChart struct { - Type string - Path string - Name string - Namespace string - Disabled bool + Type string + Path string + Name string + Namespace string + // Must be castable into bool (0,1,true,false) + Disabled string ValuesFileNames []string } diff --git a/runner/config.go b/runner/config.go index 2512605560fedefe97c3fac9c71a91633b117d51_cnVubmVyL2NvbmZpZy5nbw==..e6d2d49e5342b5852ddea6ce786bc82010692453_cnVubmVyL2NvbmZpZy5nbw== 100644 --- a/runner/config.go +++ b/runner/config.go @@ -31,7 +31,8 @@ Namespace string // Disabled: disable this chart // This can be useful when inheriting the chart - Disabled bool + // must be castable to bool (0,1,true,false) + Disabled string } // Arg define command line arguments diff --git a/runner/main.go b/runner/main.go index 2512605560fedefe97c3fac9c71a91633b117d51_cnVubmVyL21haW4uZ28=..e6d2d49e5342b5852ddea6ce786bc82010692453_cnVubmVyL21haW4uZ28= 100644 --- a/runner/main.go +++ b/runner/main.go @@ -52,6 +52,15 @@ outputDir = r.config.Output } + for name := range r.config.Spec.Charts { + w := bytes.NewBuffer([]byte{}) + if err := hydrateString(r.config.Spec.Charts[name].Disabled, w, variables); err != nil { + return err + } + chart := r.config.Spec.Charts[name] + chart.Disabled = w.String() + r.config.Spec.Charts[name] = chart + } preBuildDir := filepath.Join(tmpDir, "pre-build") if err := r.DoBuild(tmpDir, preBuildDir); err != nil { return fmt.Errorf("failed to do pre-build: %w", err) @@ -216,8 +225,21 @@ return input, nil } +func toBool(s string) (bool, error) { + sLower := strings.ToLower(s) + finalString := strings.TrimSuffix(sLower, "\n") + switch finalString { + case "0", "false", "": + return false, nil + case "1", "true": + return true, nil + default: + return false, errors.New("cannot parse " + s + " as bool") + } +} + func (r *Runner) prepareCmds() (map[string]*cmd.Cmd, error) { // create helm commands // create ytt chart commands cmds := make(map[string]*cmd.Cmd) for name, chart := range r.config.Spec.Charts { @@ -219,9 +241,13 @@ func (r *Runner) prepareCmds() (map[string]*cmd.Cmd, error) { // create helm commands // create ytt chart commands cmds := make(map[string]*cmd.Cmd) for name, chart := range r.config.Spec.Charts { - if chart.Disabled { + disabled, err := toBool(chart.Disabled) + if err != nil { + return nil, err + } + if disabled { continue } args, err := chart.BuildArgs(name, r.config.Namespace)