From 59c72bd6a44ad78dc4ebc11cd667b93aea1e2a1e Mon Sep 17 00:00:00 2001 From: Lohit Kolluri Date: Wed, 15 Jul 2026 03:31:01 +0530 Subject: [PATCH] fix: adapt SourceDateEpoch to upstream refactored dep check Upstream/main restructured the dependency error handling in install.go and upgrade.go from a nested-if block (if DependencyUpdate) to an early-return pattern (if !DependencyUpdate). Adapt the feature's Manager construction to match the new code structure. Signed-off-by: Lohit Kolluri --- pkg/cmd/install.go | 43 +++++++++++++++++++++---------------------- pkg/cmd/upgrade.go | 41 ++++++++++++++++++++--------------------- 2 files changed, 41 insertions(+), 43 deletions(-) diff --git a/pkg/cmd/install.go b/pkg/cmd/install.go index b0f8c64b7..b935ed4d0 100644 --- a/pkg/cmd/install.go +++ b/pkg/cmd/install.go @@ -305,30 +305,29 @@ func runInstall(args []string, client *action.Install, valueOpts *values.Options // As of Helm 2.4.0, this is treated as a stopping condition: // https://github.com/helm/helm/issues/2209 if err := action.CheckDependencies(chartRequested, req); err != nil { - if client.DependencyUpdate { - man := &downloader.Manager{ - Out: out, - ChartPath: cp, - Keyring: client.Keyring, - SkipUpdate: false, - Getters: p, - RepositoryConfig: settings.RepositoryConfig, - RepositoryCache: settings.RepositoryCache, - ContentCache: settings.ContentCache, - Debug: settings.Debug, - RegistryClient: client.GetRegistryClient(), - SourceDateEpoch: sourceDateEpoch, - } - if err := man.Update(); err != nil { - return nil, err - } - // Reload the chart with the updated Chart.lock file. - if chartRequested, err = loader.Load(cp); err != nil { - return nil, fmt.Errorf("failed reloading chart after repo update: %w", err) - } - } else { + if !client.DependencyUpdate { return nil, fmt.Errorf("an error occurred while checking for chart dependencies. You may need to run 'helm dependency build' to fetch missing dependencies: %w", err) } + man := &downloader.Manager{ + Out: out, + ChartPath: cp, + Keyring: client.Keyring, + SkipUpdate: false, + Getters: p, + RepositoryConfig: settings.RepositoryConfig, + RepositoryCache: settings.RepositoryCache, + ContentCache: settings.ContentCache, + Debug: settings.Debug, + RegistryClient: client.GetRegistryClient(), + SourceDateEpoch: sourceDateEpoch, + } + if err := man.Update(); err != nil { + return nil, err + } + // Reload the chart with the updated Chart.lock file. + if chartRequested, err = loader.Load(cp); err != nil { + return nil, fmt.Errorf("failed reloading chart after repo update: %w", err) + } } } diff --git a/pkg/cmd/upgrade.go b/pkg/cmd/upgrade.go index 0a0490956..c038a2149 100644 --- a/pkg/cmd/upgrade.go +++ b/pkg/cmd/upgrade.go @@ -210,29 +210,28 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { } if err := action.CheckDependencies(ch, req); err != nil { err = fmt.Errorf("an error occurred while checking for chart dependencies. You may need to run 'helm dependency build' to fetch missing dependencies: %w", err) - if client.DependencyUpdate { - man := &downloader.Manager{ - Out: out, - ChartPath: chartPath, - Keyring: client.Keyring, - SkipUpdate: false, - Getters: p, - RepositoryConfig: settings.RepositoryConfig, - RepositoryCache: settings.RepositoryCache, - ContentCache: settings.ContentCache, - Debug: settings.Debug, - SourceDateEpoch: sourceDateEpoch, - } - if err := man.Update(); err != nil { - return err - } - // Reload the chart with the updated Chart.lock file. - if ch, err = loader.Load(chartPath); err != nil { - return fmt.Errorf("failed reloading chart after repo update: %w", err) - } - } else { + if !client.DependencyUpdate { return err } + man := &downloader.Manager{ + Out: out, + ChartPath: chartPath, + Keyring: client.Keyring, + SkipUpdate: false, + Getters: p, + RepositoryConfig: settings.RepositoryConfig, + RepositoryCache: settings.RepositoryCache, + ContentCache: settings.ContentCache, + Debug: settings.Debug, + SourceDateEpoch: sourceDateEpoch, + } + if err := man.Update(); err != nil { + return err + } + // Reload the chart with the updated Chart.lock file. + if ch, err = loader.Load(chartPath); err != nil { + return fmt.Errorf("failed reloading chart after repo update: %w", err) + } } }