Unpack also the charts downloaded from a local repository

Signed-off-by: Cosmin Cojocar <cosmin.cojocar@gmx.ch>
pull/4468/head
Cosmin Cojocar 7 years ago
parent ce461733d3
commit bb4445f4c6

@ -294,12 +294,19 @@ func (m *Manager) downloadAll(deps []*chartutil.Dependency) error {
if m.Debug { if m.Debug {
fmt.Fprintf(m.Out, "Archiving %s from repo %s\n", dep.Name, dep.Repository) fmt.Fprintf(m.Out, "Archiving %s from repo %s\n", dep.Name, dep.Repository)
} }
ver, err := tarFromLocalDir(m.ChartPath, dep.Name, dep.Repository, dep.Version) ver, archiveFile, err := tarFromLocalDir(m.ChartPath, dep.Name, dep.Repository, dep.Version)
if err != nil { if err != nil {
saveError = err saveError = err
break break
} }
dep.Version = ver dep.Version = ver
if m.Recursive {
fmt.Fprintln(m.Out, "Unpacking:", archiveFile)
err := chartutil.ExpandFile(destPath, archiveFile)
if err != nil {
return fmt.Errorf("could not unpack %s: %s", archiveFile, err)
}
}
continue continue
} }
@ -687,40 +694,40 @@ func writeLock(chartpath string, lock *chartutil.RequirementsLock) error {
return ioutil.WriteFile(dest, data, 0644) return ioutil.WriteFile(dest, data, 0644)
} }
// tarFromLocalDir archive a dep chart from local directory and save it into charts/ // archive a dep chart from local directory and save it into charts/
func tarFromLocalDir(chartpath string, name string, repo string, version string) (string, error) { func tarFromLocalDir(chartpath string, name string, repo string, version string) (string, string, error) {
destPath := filepath.Join(chartpath, "charts") destPath := filepath.Join(chartpath, "charts")
if !strings.HasPrefix(repo, "file://") { if !strings.HasPrefix(repo, "file://") {
return "", fmt.Errorf("wrong format: chart %s repository %s", name, repo) return "", "", fmt.Errorf("wrong format: chart %s repository %s", name, repo)
} }
origPath, err := resolver.GetLocalPath(repo, chartpath) origPath, err := resolver.GetLocalPath(repo, chartpath)
if err != nil { if err != nil {
return "", err return "", "", err
} }
ch, err := chartutil.LoadDir(origPath) ch, err := chartutil.LoadDir(origPath)
if err != nil { if err != nil {
return "", err return "", "", err
} }
constraint, err := semver.NewConstraint(version) constraint, err := semver.NewConstraint(version)
if err != nil { if err != nil {
return "", fmt.Errorf("dependency %s has an invalid version/constraint format: %s", name, err) return "", "", fmt.Errorf("dependency %s has an invalid version/constraint format: %s", name, err)
} }
v, err := semver.NewVersion(ch.Metadata.Version) v, err := semver.NewVersion(ch.Metadata.Version)
if err != nil { if err != nil {
return "", err return "", "", err
} }
if constraint.Check(v) { if constraint.Check(v) {
_, err = chartutil.Save(ch, destPath) archiveFile, err := chartutil.Save(ch, destPath)
return ch.Metadata.Version, err return ch.Metadata.Version, archiveFile, err
} }
return "", fmt.Errorf("can't get a valid version for dependency %s", name) return "", "", fmt.Errorf("can't get a valid version for dependency %s", name)
} }
// move files from tmppath to destpath // move files from tmppath to destpath

Loading…
Cancel
Save