Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow reuse-values on upgrade to be configurable #531

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ct/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ func addInstallFlags(flags *flag.FlagSet) {
(e.g. "--set=name=value"`))
flags.Bool("skip-clean-up", false, heredoc.Doc(`
Skip resources clean-up. Used if need to continue other flows or keep it around.`))
flags.Bool("reuse-values", true, heredoc.Doc(`
Can be reset to disable adding the reuse-values flag for upgrades when
using the --upgrade flag.`))
}

func install(cmd *cobra.Command, args []string) error {
Expand Down
2 changes: 1 addition & 1 deletion pkg/chart/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func NewTesting(config config.Configuration, extraSetArgs string) (Testing, erro

testing := Testing{
config: config,
helm: tool.NewHelm(procExec, extraArgs, strings.Fields(extraSetArgs)),
helm: tool.NewHelm(procExec, extraArgs, strings.Fields(extraSetArgs), config.ReuseValues),
git: tool.NewGit(procExec),
kubectl: tool.NewKubectl(procExec, config.KubectlTimeout),
linter: tool.NewLinter(procExec),
Expand Down
2 changes: 1 addition & 1 deletion pkg/chart/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func newTestingHelmIntegration(cfg config.Configuration, extraSetArgs string) Te
utils: util.Utils{},
accountValidator: fakeAccountValidator{},
linter: fakeMockLinter,
helm: tool.NewHelm(procExec, extraArgs, strings.Fields(extraSetArgs)),
helm: tool.NewHelm(procExec, extraArgs, strings.Fields(extraSetArgs), cfg.ReuseValues),
kubectl: tool.NewKubectl(procExec, 30*time.Second),
}
}
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ type Configuration struct {
ExcludeDeprecated bool `mapstructure:"exclude-deprecated"`
KubectlTimeout time.Duration `mapstructure:"kubectl-timeout"`
PrintLogs bool `mapstructure:"print-logs"`
ReuseValues bool `mapstructure:"reuse-values"`
}

func LoadConfiguration(cfgFile string, cmd *cobra.Command, printConfig bool) (*Configuration, error) {
Expand Down
10 changes: 8 additions & 2 deletions pkg/tool/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ type Helm struct {
exec exec.ProcessExecutor
extraArgs []string
extraSetArgs []string
reuseValues bool
}

func NewHelm(exec exec.ProcessExecutor, extraArgs []string, extraSetArgs []string) Helm {
func NewHelm(exec exec.ProcessExecutor, extraArgs []string, extraSetArgs []string, reuseValues bool) Helm {
return Helm{
exec: exec,
extraArgs: extraArgs,
extraSetArgs: extraSetArgs,
reuseValues: reuseValues,
}
}

Expand Down Expand Up @@ -70,8 +72,12 @@ func (h Helm) InstallWithValues(chart string, valuesFile string, namespace strin
}

func (h Helm) Upgrade(chart string, namespace string, release string) error {
var reuseValuesFlag string
if h.reuseValues {
reuseValuesFlag = "--reuse-values"
}
if err := h.exec.RunProcess("helm", "upgrade", release, chart, "--namespace", namespace,
"--reuse-values", "--wait", h.extraArgs, h.extraSetArgs); err != nil {
reuseValuesFlag, "--wait", h.extraArgs, h.extraSetArgs); err != nil {
return err
}

Expand Down