diff --git a/cmd/helm/dependency_update.go b/cmd/helm/dependency_update.go index cb6e9c0cc..7517caa93 100644 --- a/cmd/helm/dependency_update.go +++ b/cmd/helm/dependency_update.go @@ -67,6 +67,7 @@ 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 @@ -78,6 +79,7 @@ func newDependencyUpdateCmd(cfg *action.Configuration, out io.Writer) *cobra.Com f := cmd.Flags() f.BoolVar(&client.Verify, "verify", false, "verify the packages against signatures") f.StringVar(&client.Keyring, "keyring", defaultKeyring(), "keyring containing public keys") + f.BoolVar(&client.Untar, "untar", false, "if set to true, will untar the chart after downloading it") f.BoolVar(&client.SkipRefresh, "skip-refresh", false, "do not refresh the local repository cache") return cmd diff --git a/cmd/helm/dependency_update_test.go b/cmd/helm/dependency_update_test.go index 1a1e0468f..d42a9f7ec 100644 --- a/cmd/helm/dependency_update_test.go +++ b/cmd/helm/dependency_update_test.go @@ -145,6 +145,18 @@ func TestDependencyUpdateCmd(t *testing.T) { if _, err := os.Stat(expect); err != nil { t.Fatal(err) } + // when use `--untar` flag, ./charts/*.tgz should not existed. + _, _, err = executeActionCommand( + fmt.Sprintf("dependency update '%s' --repository-config %s --repository-cache %s --untar", dir(chartname), dir("repositories.yaml"), dir()), + ) + if err != nil { + t.Fatal(err) + } + // Make sure the actual file got downloaded,and untar it. + expect = dir(chartname, "charts/reqtest") + if _, err := os.Stat(expect); err != nil { + t.Fatal(err) + } } func TestDependencyUpdateCmd_DoNotDeleteOldChartsOnError(t *testing.T) { diff --git a/pkg/action/dependency.go b/pkg/action/dependency.go index 3265f1f17..c9585a9bb 100644 --- a/pkg/action/dependency.go +++ b/pkg/action/dependency.go @@ -35,6 +35,7 @@ import ( // It provides the implementation of 'helm dependency' and its respective subcommands. type Dependency struct { Verify bool + Untar bool Keyring string SkipRefresh bool ColumnWidth uint diff --git a/pkg/downloader/manager.go b/pkg/downloader/manager.go index ec4056d27..8e8a91d16 100644 --- a/pkg/downloader/manager.go +++ b/pkg/downloader/manager.go @@ -75,6 +75,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{}{} }