diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index f85bb98c58d..e1c20eceff3 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -128,3 +128,26 @@ func loadReleasesInMemory(actionConfig *action.Configuration) { // Must reset namespace to the proper one mem.SetNamespace(settings.Namespace()) } + +func Init() (*cobra.Command, error) { + kube.ManagedFieldsManager = "helm" + + actionConfig := new(action.Configuration) + cmd, err := newRootCmd(actionConfig, os.Stdout, os.Args[1:]) + if err != nil { + return nil, err + } + + cobra.OnInitialize(func() { + helmDriver := os.Getenv("HELM_DRIVER") + if err := actionConfig.Init(settings.RESTClientGetter(), settings.Namespace(), helmDriver, debug); err != nil { + log.Fatal(err) + } + + if helmDriver == "memory" { + loadReleasesInMemory(actionConfig) + } + }) + + return cmd, nil +} diff --git a/cmd/helm/root.go b/cmd/helm/root.go index 68f84509ccf..2f6f1f952d3 100644 --- a/cmd/helm/root.go +++ b/cmd/helm/root.go @@ -151,7 +151,7 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string // This call is required to gather configuration information prior to // execution. flags.ParseErrorsWhitelist.UnknownFlags = true - flags.Parse(args) + // flags.Parse(args) registryClient, err := newDefaultRegistryClient(false) if err != nil { @@ -199,7 +199,7 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string ) // Find and add plugins - loadPlugins(cmd, out) + // loadPlugins(cmd, out) // Check permissions on critical files checkPerms() diff --git a/pkg/chart/loader/load_dependencies.go b/pkg/chart/loader/load_dependencies.go index 550bfed22c6..92b588e3ea0 100644 --- a/pkg/chart/loader/load_dependencies.go +++ b/pkg/chart/loader/load_dependencies.go @@ -30,6 +30,8 @@ var localCacheDir string var DepsBuildFunc func() error var SetChartPathFunc func(string) +var NoChartLockWarning = `Cannot automatically download chart dependencies without Chart.lock or requirements.lock.` + func LocalCacheDir() (string, error) { if localCacheDir == "" { userHomeDir, err := os.UserHomeDir() @@ -102,12 +104,8 @@ func LoadChartDependencies( } if chartMetadataLock == nil { - if len(chartMetadata.Dependencies) > 0 { - logboek.Context(ctx).Error().LogLn("Cannot build chart dependencies and preload charts without lock file (.helm/Chart.lock or .helm/requirements.lock)") - logboek.Context(ctx).Error().LogLn("It is recommended to add Chart.lock file to your project repository or remove chart dependencies.") - logboek.Context(ctx).Error().LogLn() - logboek.Context(ctx).Error().LogLn("To generate a lock file run 'werf helm dependency update .helm' and commit resulting .helm/Chart.lock or .helm/requirements.lock (it is not required to commit whole .helm/charts directory, better add it to the .gitignore).") - logboek.Context(ctx).Error().LogLn() + if len(chartMetadata.Dependencies) > 0 && NoChartLockWarning != "" { + logboek.Context(ctx).Warn().LogLn(NoChartLockWarning) } return res, nil diff --git a/pkg/werf/secrets/secrets_runtime_data.go b/pkg/werf/secrets/secrets_runtime_data.go index 24bab1e2472..af5a9dbae44 100644 --- a/pkg/werf/secrets/secrets_runtime_data.go +++ b/pkg/werf/secrets/secrets_runtime_data.go @@ -20,6 +20,7 @@ var _ runtimedata.RuntimeData = (*SecretsRuntimeData)(nil) var CoalesceTablesFunc func(dst, src map[string]interface{}) map[string]interface{} var SecretsWorkingDir string var ChartDir string +var DisableSecrets bool type SecretsRuntimeData struct { decryptedSecretValues map[string]interface{} @@ -40,6 +41,10 @@ func (secretsRuntimeData *SecretsRuntimeData) DecodeAndLoadSecrets( secretsManager *secrets_manager.SecretsManager, opts runtimedata.DecodeAndLoadSecretsOptions, ) error { + if DisableSecrets { + return nil + } + var secretsWorkingDir string if !noSecretsWorkingDir && SecretsWorkingDir != "" { secretsWorkingDir = SecretsWorkingDir