Skip to content

Commit

Permalink
don't ask for password if admin panel already has one
Browse files Browse the repository at this point in the history
  • Loading branch information
danj-replicated committed Oct 4, 2023
1 parent e8b7599 commit 3f5054b
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 10 deletions.
2 changes: 2 additions & 0 deletions cmd/helmvm/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 7 additions & 6 deletions pkg/addons/adminconsole/adminconsole.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions pkg/addons/applier.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@ 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.
type Applier struct {
disabledAddons map[string]bool
prompt bool
verbose bool
isUpgrade bool
}

// GenerateHelmConfigs generates the helm config for all the embedded charts.
Expand All @@ -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)
}
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/addons/custom/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}

Expand Down
2 changes: 1 addition & 1 deletion pkg/addons/openebs/openebs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}

Expand Down
6 changes: 6 additions & 0 deletions pkg/addons/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 3f5054b

Please sign in to comment.