From 7e5182e30cd7594e8db945b00ad6c19e81535913 Mon Sep 17 00:00:00 2001 From: Weiping Cai Date: Sat, 8 Aug 2020 11:49:41 +0800 Subject: [PATCH] mv untar to pkg/manager Signed-off-by: Weiping Cai --- cmd/helm/dependency_update.go | 22 ++-------------------- pkg/downloader/manager.go | 6 ++++++ 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/cmd/helm/dependency_update.go b/cmd/helm/dependency_update.go index 3d7c816fd..7f8a340ba 100644 --- a/cmd/helm/dependency_update.go +++ b/cmd/helm/dependency_update.go @@ -17,14 +17,12 @@ package main import ( "io" - "os" "path/filepath" "github.com/spf13/cobra" "helm.sh/helm/v3/cmd/helm/require" "helm.sh/helm/v3/pkg/action" - "helm.sh/helm/v3/pkg/chartutil" "helm.sh/helm/v3/pkg/downloader" "helm.sh/helm/v3/pkg/getter" ) @@ -69,28 +67,12 @@ func newDependencyUpdateCmd(cfg *action.Configuration, out io.Writer) *cobra.Com RepositoryConfig: settings.RepositoryConfig, RepositoryCache: settings.RepositoryCache, Debug: settings.Debug, + Untar: client.Untar, } if client.Verify { man.Verify = downloader.VerifyAlways } - - err := man.Update() - if err != nil { - return err - } - - if client.Untar { - match := chartpath + "/charts/*.tgz" - files, err := filepath.Glob(match) - if err != nil { - return err - } - for _, f := range files { - chartutil.ExpandFile(chartpath+"/charts/", f) - os.Remove(f) - } - } - return nil + return man.Update() }, } diff --git a/pkg/downloader/manager.go b/pkg/downloader/manager.go index d2d3e9f31..84a41af7a 100644 --- a/pkg/downloader/manager.go +++ b/pkg/downloader/manager.go @@ -76,6 +76,7 @@ type Manager struct { RegistryClient *registry.Client RepositoryConfig string RepositoryCache string + Untar bool } // Build rebuilds a local charts directory from a lockfile. @@ -357,6 +358,11 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error { break } + if m.Untar { + chartutil.ExpandFile(m.ChartPath+"/charts/", destfile) + os.Remove(destfile) + } + churls[churl] = struct{}{} }