Skip to content

Commit

Permalink
EVEREST-1752 Add chart-dir to CLI upgrade (#959)
Browse files Browse the repository at this point in the history
EVEREST-1752 add chart-dir to upgrade
  • Loading branch information
oksana-grishchenko authored Dec 23, 2024
1 parent 00333a7 commit 0fe2dbd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
3 changes: 3 additions & 0 deletions commands/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ func initUpgradeFlags(cmd *cobra.Command) {
cmd.Flags().String(cli.FlagVersionMetadataURL, "https://check.percona.com", "URL to retrieve version metadata information from")
cmd.Flags().Bool(cli.FlagSkipEnvDetection, false, "Skip detecting Kubernetes environment where Everest is installed")

cmd.Flags().String(helm.FlagChartDir, "", "Path to the chart directory. If not set, the chart will be downloaded from the repository")
cmd.Flags().MarkHidden(helm.FlagChartDir) //nolint:errcheck,gosec
cmd.Flags().String(helm.FlagRepository, helm.DefaultHelmRepoURL, "Helm chart repository to download the Everest charts from")
cmd.Flags().StringSlice(helm.FlagHelmSet, []string{}, "Set helm values on the command line (can specify multiple values with commas: key1=val1,key2=val2)")
cmd.Flags().StringSliceP(helm.FlagHelmValues, "f", []string{}, "Specify values in a YAML file or a URL (can specify multiple)")
Expand All @@ -97,6 +99,7 @@ func initUpgradeViperFlags(cmd *cobra.Command) {

viper.BindPFlag(upgrade.FlagSkipEnvDetection, cmd.Flags().Lookup(upgrade.FlagSkipEnvDetection)) //nolint:errcheck,gosec

viper.BindPFlag(helm.FlagChartDir, cmd.Flags().Lookup(helm.FlagChartDir)) //nolint:errcheck,gosec
viper.BindPFlag(helm.FlagRepository, cmd.Flags().Lookup(helm.FlagRepository)) //nolint:errcheck,gosec
viper.BindPFlag(helm.FlagHelmSet, cmd.Flags().Lookup(helm.FlagHelmSet)) //nolint:errcheck,gosec
viper.BindPFlag(helm.FlagHelmValues, cmd.Flags().Lookup(helm.FlagHelmValues)) //nolint:errcheck,gosec
Expand Down
13 changes: 10 additions & 3 deletions pkg/cli/upgrade/steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package upgrade
import (
"context"
"fmt"
"path/filepath"

"github.com/AlekSi/pointer"
"helm.sh/helm/v3/pkg/cli/values"
Expand Down Expand Up @@ -189,10 +190,16 @@ func (u *Upgrade) helmAdoptDBNamespaces(ctx context.Context, namespace, version
ReleaseNamespace: namespace,
Values: values,
}

var directory string
if u.config.ChartDir != "" {
directory = filepath.Join(u.config.ChartDir, "charts/everest-db-namespace")
}
if err := installer.Init(u.config.KubeconfigPath, helm.ChartOptions{
URL: u.config.RepoURL,
Name: helm.EverestDBNamespaceChartName,
Version: version,
URL: u.config.RepoURL,
Directory: directory,
Name: helm.EverestDBNamespaceChartName,
Version: version,
}); err != nil {
return fmt.Errorf("could not initialize Helm installer: %w", err)
}
Expand Down
7 changes: 4 additions & 3 deletions pkg/cli/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,10 @@ func (u *Upgrade) setupHelmInstaller(ctx context.Context) error {
Values: values,
}
if err := installer.Init(u.config.KubeconfigPath, helm.ChartOptions{
URL: u.config.RepoURL,
Name: helm.EverestChartName,
Version: u.upgradeToVersion,
URL: u.config.RepoURL,
Directory: u.config.ChartDir,
Name: helm.EverestChartName,
Version: u.upgradeToVersion,
}); err != nil {
return fmt.Errorf("could not initialize Helm installer: %w", err)
}
Expand Down

0 comments on commit 0fe2dbd

Please sign in to comment.