diff --git a/cmd/helmvm/install.go b/cmd/helmvm/install.go index eeabedfb7..6679edf19 100644 --- a/cmd/helmvm/install.go +++ b/cmd/helmvm/install.go @@ -168,6 +168,8 @@ func updateConfigBundle(c *cli.Context, bundledir string) error { opts = append(opts, addons.WithoutAddon(addon)) } + opts = append(opts, addons.IsUpgrade()) + helmConfigs, err := addons.NewApplier(opts...).GenerateHelmConfigs(c) if err != nil { return fmt.Errorf("unable to apply addons: %w", err) diff --git a/pkg/addons/adminconsole/adminconsole.go b/pkg/addons/adminconsole/adminconsole.go index d48a3dd74..75a5f0697 100644 --- a/pkg/addons/adminconsole/adminconsole.go +++ b/pkg/addons/adminconsole/adminconsole.go @@ -89,7 +89,7 @@ func (a *AdminConsole) addLicenseToHelmValues() error { // GenerateHelmConfig generates the helm config for the adminconsole // and writes the charts to the disk. -func (a *AdminConsole) GenerateHelmConfig(ctx *cli.Context) ([]dig.Mapping, error) { +func (a *AdminConsole) GenerateHelmConfig(ctx *cli.Context, isUpgrade bool) ([]dig.Mapping, error) { chartConfig := dig.Mapping{ "name": releaseName, @@ -105,13 +105,14 @@ func (a *AdminConsole) GenerateHelmConfig(ctx *cli.Context) ([]dig.Mapping, erro return chartConfigs, fmt.Errorf("unable to add license to helm values: %w", err) } - pass, err := a.askPassword() - if err != nil { - return chartConfigs, fmt.Errorf("unable to ask for password: %w", err) + if !isUpgrade { + pass, err := a.askPassword() + if err != nil { + return chartConfigs, fmt.Errorf("unable to ask for password: %w", err) + } + helmValues["password"] = pass } - helmValues["password"] = pass - valuesStringData, err := yaml.Marshal(helmValues) if err != nil { return chartConfigs, err diff --git a/pkg/addons/applier.go b/pkg/addons/applier.go index 1ecfa8df9..eb3d68fd1 100644 --- a/pkg/addons/applier.go +++ b/pkg/addons/applier.go @@ -40,7 +40,7 @@ func getLogger(addon string, verbose bool) action.DebugLog { type AddOn interface { Version() (map[string]string, error) HostPreflights() (*v1beta2.HostPreflightSpec, error) - GenerateHelmConfig(ctx *cli.Context) ([]dig.Mapping, error) + GenerateHelmConfig(ctx *cli.Context, isUpgrade bool) ([]dig.Mapping, error) } // Applier is an entity that applies (installs and updates) addons in the cluster. @@ -48,6 +48,7 @@ type Applier struct { disabledAddons map[string]bool prompt bool verbose bool + isUpgrade bool } // GenerateHelmConfigs generates the helm config for all the embedded charts. @@ -66,7 +67,7 @@ func (a *Applier) GenerateHelmConfigs(ctx *cli.Context) (dig.Mapping, error) { } for _, addon := range addons { - addonChartConfig, err := addon.GenerateHelmConfig(ctx) + addonChartConfig, err := addon.GenerateHelmConfig(ctx, a.isUpgrade) if err != nil { return helmConfig, fmt.Errorf("Could not add chart: %w", err) } @@ -200,6 +201,7 @@ func NewApplier(opts ...Option) *Applier { prompt: true, verbose: true, disabledAddons: map[string]bool{}, + isUpgrade: false, } for _, fn := range opts { fn(applier) diff --git a/pkg/addons/custom/custom.go b/pkg/addons/custom/custom.go index 82bd0f62d..13169f226 100644 --- a/pkg/addons/custom/custom.go +++ b/pkg/addons/custom/custom.go @@ -56,7 +56,7 @@ func (c *Custom) HostPreflights() (*v1beta2.HostPreflightSpec, error) { // GenerateHelmConfig generates the helm config for all the embedded charts. // and writes the charts to the disk. -func (c *Custom) GenerateHelmConfig(ctx *cli.Context) ([]dig.Mapping, error) { +func (c *Custom) GenerateHelmConfig(ctx *cli.Context, isUpgrade bool) ([]dig.Mapping, error) { chartConfigs := []dig.Mapping{} diff --git a/pkg/addons/openebs/openebs.go b/pkg/addons/openebs/openebs.go index 87926f8d7..e8f761b86 100644 --- a/pkg/addons/openebs/openebs.go +++ b/pkg/addons/openebs/openebs.go @@ -61,7 +61,7 @@ func (o *OpenEBS) GetChartFileName() string { return fmt.Sprintf("openebs-%s.tgz", appVersion) } -func (o *OpenEBS) GenerateHelmConfig(ctx *cli.Context) ([]dig.Mapping, error) { +func (o *OpenEBS) GenerateHelmConfig(ctx *cli.Context, isUpgrade bool) ([]dig.Mapping, error) { chartConfigs := []dig.Mapping{} diff --git a/pkg/addons/options.go b/pkg/addons/options.go index 1816d664a..449a6603b 100644 --- a/pkg/addons/options.go +++ b/pkg/addons/options.go @@ -13,6 +13,12 @@ func WithoutAddon(addon string) Option { } } +func IsUpgrade() Option { + return func(a *Applier) { + a.isUpgrade = true + } +} + // WithoutPrompt disables the prompt before applying addons. func WithoutPrompt() Option { return func(a *Applier) {