add untar option to dependency update

Signed-off-by: Andrea Tartaglia <me@andreatartaglia.com>
pull/30616/head
Andrea Tartaglia 2 years ago
parent 1ac9e4c272
commit b29b73f8d8
No known key found for this signature in database

@ -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

@ -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")
}

@ -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,

@ -149,6 +149,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) {
@ -241,7 +254,6 @@ func TestDependencyUpdateCmd_WithRepoThatWasNotAdded(t *testing.T) {
fmt.Sprintf("dependency update '%s' --repository-config %s --repository-cache %s --content-cache %s", dir(chartname),
dir("repositories.yaml"), dir(), contentCache),
)
if err != nil {
t.Logf("Output: %s", out)
t.Fatal(err)

@ -361,6 +361,10 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error {
break
}
if m.Untar {
chartutil.ExpandFile(m.ChartPath+"/charts/", tmpPath)
}
churls[churl] = struct{}{}
}
@ -502,7 +506,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 {
@ -679,7 +682,6 @@ func dedupeRepos(repos []*repo.Entry) []*repo.Entry {
}
func (m *Manager) parallelRepoUpdate(repos []*repo.Entry) error {
var wg sync.WaitGroup
localRepos := dedupeRepos(repos)

Loading…
Cancel
Save