diff --git a/pkg/action/dependency.go b/pkg/action/dependency.go index 03c370c8e..9e932b50c 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/cmd/dependency.go b/pkg/cmd/dependency.go index 34bbff6be..b1f4b2273 100644 --- a/pkg/cmd/dependency.go +++ b/pkg/cmd/dependency.go @@ -133,4 +133,5 @@ func addDependencySubcommandFlags(f *pflag.FlagSet, client *action.Dependency) { f.BoolVar(&client.InsecureSkipTLSverify, "insecure-skip-tls-verify", false, "skip tls certificate checks for the chart download") f.BoolVar(&client.PlainHTTP, "plain-http", false, "use insecure HTTP connections for the chart download") f.StringVar(&client.CaFile, "ca-file", "", "verify certificates of HTTPS-enabled servers using this CA bundle") + f.BoolVar(&client.Untar, "untar", false, "if set to true, will untar the chart after downloading it") } diff --git a/pkg/cmd/dependency_update.go b/pkg/cmd/dependency_update.go index 921e5ef49..86491982b 100644 --- a/pkg/cmd/dependency_update.go +++ b/pkg/cmd/dependency_update.go @@ -69,6 +69,7 @@ func newDependencyUpdateCmd(_ *action.Configuration, out io.Writer) *cobra.Comma ChartPath: chartpath, Keyring: client.Keyring, SkipUpdate: client.SkipRefresh, + Untar: client.Untar, Getters: getter.All(settings), RegistryClient: registryClient, RepositoryConfig: settings.RepositoryConfig, diff --git a/pkg/cmd/dependency_update_test.go b/pkg/cmd/dependency_update_test.go index 9646c6816..44cbe296e 100644 --- a/pkg/cmd/dependency_update_test.go +++ b/pkg/cmd/dependency_update_test.go @@ -147,6 +147,19 @@ func TestDependencyUpdateCmd(t *testing.T) { if _, err := os.Stat(expect); err != nil { t.Fatal(err) } + + // When using `--untar`, ./charts/*.tgz should not exist + _, _, 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 is downloaded and untar + expect = dir(chartname, "charts/reqtest") + if _, err := os.Stat(expect); err != nil { + t.Fatal(err) + } } func TestDependencyUpdateCmd_DoNotDeleteOldChartsOnError(t *testing.T) { @@ -236,7 +249,6 @@ func TestDependencyUpdateCmd_WithRepoThatWasNotAdded(t *testing.T) { fmt.Sprintf("dependency update '%s' --repository-config %s --repository-cache %s", dir(chartname), dir("repositories.yaml"), dir()), ) - if err != nil { t.Logf("Output: %s", out) t.Fatal(err) diff --git a/pkg/downloader/manager.go b/pkg/downloader/manager.go index b43165975..999e11c51 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,10 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error { break } + if m.Untar { + chartutil.ExpandFile(m.ChartPath+"/charts/", tmpPath) + } + churls[churl] = struct{}{} } @@ -498,7 +503,6 @@ Loop: // in a known repo and attempt to ensure the data is present for steps like // version resolution. func (m *Manager) ensureMissingRepos(repoNames map[string]string, deps []*chart.Dependency) (map[string]string, error) { - var ru []*repo.Entry for _, dd := range deps { @@ -675,7 +679,6 @@ func dedupeRepos(repos []*repo.Entry) []*repo.Entry { } func (m *Manager) parallelRepoUpdate(repos []*repo.Entry) error { - var wg sync.WaitGroup localRepos := dedupeRepos(repos)