add untar option to dependency update

Signed-off-by: Andrea Tartaglia <me@andreatartaglia.com>
pull/30616/head
Andrea Tartaglia 7 months ago
parent a42b76421b
commit ac3950670c
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,

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

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

Loading…
Cancel
Save