diff --git a/cmd/helm/dependency_build.go b/cmd/helm/dependency_build.go index 1ee46d3d2..299b25e4d 100644 --- a/cmd/helm/dependency_build.go +++ b/cmd/helm/dependency_build.go @@ -54,20 +54,23 @@ func newDependencyBuildCmd(cfg *action.Configuration, out io.Writer) *cobra.Comm if len(args) > 0 { chartpath = filepath.Clean(args[0]) } - man := &downloader.Manager{ - Out: out, - ChartPath: chartpath, - Keyring: client.Keyring, - SkipUpdate: client.SkipRefresh, - Getters: getter.All(settings), - RegistryClient: cfg.RegistryClient, - RepositoryConfig: settings.RepositoryConfig, - RepositoryCache: settings.RepositoryCache, - Debug: settings.Debug, - } + + verify := downloader.VerifyNever if client.Verify { - man.Verify = downloader.VerifyIfPossible + verify = downloader.VerifyIfPossible } + man := downloader.NewManager( + out, + chartpath, + verify, + settings.Debug, + client.Keyring, + client.SkipRefresh, + getter.All(settings), + cfg.RegistryClient, + settings.RepositoryConfig, + settings.RepositoryCache, + ) err := man.Build() if e, ok := err.(downloader.ErrRepoNotFound); ok { return fmt.Errorf("%s. Please add the missing repos via 'helm repo add'", e.Error()) diff --git a/cmd/helm/dependency_update.go b/cmd/helm/dependency_update.go index ad0188f17..bac40634b 100644 --- a/cmd/helm/dependency_update.go +++ b/cmd/helm/dependency_update.go @@ -57,20 +57,23 @@ func newDependencyUpdateCmd(cfg *action.Configuration, out io.Writer) *cobra.Com if len(args) > 0 { chartpath = filepath.Clean(args[0]) } - man := &downloader.Manager{ - Out: out, - ChartPath: chartpath, - Keyring: client.Keyring, - SkipUpdate: client.SkipRefresh, - Getters: getter.All(settings), - RegistryClient: cfg.RegistryClient, - RepositoryConfig: settings.RepositoryConfig, - RepositoryCache: settings.RepositoryCache, - Debug: settings.Debug, - } + + verify := downloader.VerifyNever if client.Verify { - man.Verify = downloader.VerifyAlways + verify = downloader.VerifyAlways } + man := downloader.NewManager( + out, + chartpath, + verify, + settings.Debug, + client.Keyring, + client.SkipRefresh, + getter.All(settings), + cfg.RegistryClient, + settings.RepositoryConfig, + settings.RepositoryCache, + ) return man.Update() }, } diff --git a/cmd/helm/install.go b/cmd/helm/install.go index 23ea1afb1..3171b9e1f 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -235,17 +235,18 @@ func runInstall(args []string, client *action.Install, valueOpts *values.Options if err := action.CheckDependencies(chartRequested, req); err != nil { err = errors.Wrap(err, "An error occurred while checking for chart dependencies. You may need to run `helm dependency build` to fetch missing dependencies") if client.DependencyUpdate { - man := &downloader.Manager{ - Out: out, - ChartPath: cp, - Keyring: client.ChartPathOptions.Keyring, - SkipUpdate: false, - Getters: p, - RegistryClient: client.RegistryClient, - RepositoryConfig: settings.RepositoryConfig, - RepositoryCache: settings.RepositoryCache, - Debug: settings.Debug, - } + man := downloader.NewManager( + out, + cp, + downloader.VerifyNever, + settings.Debug, + client.ChartPathOptions.Keyring, + false, + p, + client.RegistryClient, + settings.RepositoryConfig, + settings.RepositoryCache, + ) if err := man.Update(); err != nil { return nil, err } diff --git a/cmd/helm/package.go b/cmd/helm/package.go index ce965b729..501b2f640 100644 --- a/cmd/helm/package.go +++ b/cmd/helm/package.go @@ -86,16 +86,18 @@ func newPackageCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { } if client.DependencyUpdate { - downloadManager := &downloader.Manager{ - Out: ioutil.Discard, - ChartPath: path, - Keyring: client.Keyring, - Getters: p, - Debug: settings.Debug, - RegistryClient: cfg.RegistryClient, - RepositoryConfig: settings.RepositoryConfig, - RepositoryCache: settings.RepositoryCache, - } + downloadManager := downloader.NewManager( + ioutil.Discard, + path, + downloader.VerifyNever, + settings.Debug, + client.Keyring, + false, + p, + nil, + settings.RepositoryConfig, + settings.RepositoryCache, + ) if err := downloadManager.Update(); err != nil { return err diff --git a/pkg/downloader/manager.go b/pkg/downloader/manager.go index 18b28dde1..3b2af56e3 100644 --- a/pkg/downloader/manager.go +++ b/pkg/downloader/manager.go @@ -78,6 +78,32 @@ type Manager struct { RepositoryCache string } +func NewManager( + out io.Writer, + chartPath string, + verify VerificationStrategy, + debug bool, + keyring string, + skipUpdate bool, + getters []getter.Provider, + registryClient *registry.Client, + repositoryConfig string, + repositoryCache string, +) *Manager { + return &Manager{ + Out: out, + ChartPath: chartPath, + Verify: verify, + Debug: debug, + Keyring: keyring, + SkipUpdate: skipUpdate, + Getters: getters, + RegistryClient: registryClient, + RepositoryConfig: repositoryConfig, + RepositoryCache: repositoryCache, + } +} + // Build rebuilds a local charts directory from a lockfile. // // If the lockfile is not present, this will run a Manager.Update()