diff --git a/commands/upgrade.go b/commands/upgrade.go index bf9ab2195..04070b10b 100644 --- a/commands/upgrade.go +++ b/commands/upgrade.go @@ -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)") @@ -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 diff --git a/pkg/cli/upgrade/steps.go b/pkg/cli/upgrade/steps.go index 26749689c..56848b3ad 100644 --- a/pkg/cli/upgrade/steps.go +++ b/pkg/cli/upgrade/steps.go @@ -3,6 +3,7 @@ package upgrade import ( "context" "fmt" + "path/filepath" "github.com/AlekSi/pointer" "helm.sh/helm/v3/pkg/cli/values" @@ -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) } diff --git a/pkg/cli/upgrade/upgrade.go b/pkg/cli/upgrade/upgrade.go index 9969c4ecc..4c63d0155 100644 --- a/pkg/cli/upgrade/upgrade.go +++ b/pkg/cli/upgrade/upgrade.go @@ -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) }