Address error on deletion of old dependencies

Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
pull/8843/head
Peter Engelbert 4 years ago
parent f666fceb30
commit beda5e1e2b

@ -144,7 +144,7 @@ func TestDependencyUpdateCmd(t *testing.T) {
t.Logf("Output: %s", out) t.Logf("Output: %s", out)
t.Fatal(err) t.Fatal(err)
} }
expect = dir(ociChartName, "charts/oci-dependent-chart") expect = dir(ociChartName, "charts/oci-dependent-chart-0.1.0.tgz")
if _, err := os.Stat(expect); err != nil { if _, err := os.Stat(expect); err != nil {
t.Fatal(err) t.Fatal(err)
} }

@ -335,7 +335,7 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error {
}, },
} }
untar, version := false, "" version := ""
if strings.HasPrefix(churl, "oci://") { if strings.HasPrefix(churl, "oci://") {
if !resolver.FeatureGateOCI.IsEnabled() { if !resolver.FeatureGateOCI.IsEnabled() {
return errors.Wrapf(resolver.FeatureGateOCI.Error(), return errors.Wrapf(resolver.FeatureGateOCI.Error(),
@ -346,29 +346,17 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error {
if err != nil { if err != nil {
return errors.Wrapf(err, "could not parse OCI reference") return errors.Wrapf(err, "could not parse OCI reference")
} }
untar = true
dl.Options = append(dl.Options, dl.Options = append(dl.Options,
getter.WithRegistryClient(m.RegistryClient), getter.WithRegistryClient(m.RegistryClient),
getter.WithTagName(version)) getter.WithTagName(version))
} }
destFile, _, err := dl.DownloadTo(churl, version, destPath) _, _, err = dl.DownloadTo(churl, version, destPath)
if err != nil { if err != nil {
saveError = errors.Wrapf(err, "could not download %s", churl) saveError = errors.Wrapf(err, "could not download %s", churl)
break break
} }
if untar {
err = chartutil.ExpandFile(destPath, destFile)
if err != nil {
return errors.Wrapf(err, "could not open %s to untar", destFile)
}
err = os.RemoveAll(destFile)
if err != nil {
return errors.Wrapf(err, "chart was downloaded and untarred, but was unable to remove the tarball: %s", destFile)
}
}
churls[churl] = struct{}{} churls[churl] = struct{}{}
} }

@ -58,7 +58,7 @@ func TestAll(t *testing.T) {
all := All(env) all := All(env)
if len(all) != 4 { if len(all) != 4 {
t.Errorf("expected 3 providers (default plus two plugins), got %d", len(all)) t.Errorf("expected 4 providers (default plus three plugins), got %d", len(all))
} }
if _, err := all.ByScheme("test2"); err != nil { if _, err := all.ByScheme("test2"); err != nil {

Loading…
Cancel
Save