Skip to content

Commit

Permalink
fix tarFromLocalDir saving file dependencies in dest path
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Fisher <matt.fisher@microsoft.com>
  • Loading branch information
Matthew Fisher authored and zegerius committed Sep 14, 2021
1 parent 4b49f35 commit adfb52e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pkg/downloader/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error {
if m.Debug {
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, err := tarFromLocalDir(m.ChartPath, dep.Name, dep.Repository, dep.Version, tmpPath)
if err != nil {
saveError = err
break
Expand Down Expand Up @@ -852,10 +852,8 @@ func writeLock(chartpath string, lock *chart.Lock, legacyLockfile bool) error {
return ioutil.WriteFile(dest, data, 0644)
}

// archive a dep chart from local directory and save it into charts/
func tarFromLocalDir(chartpath, name, repo, version string) (string, error) {
destPath := filepath.Join(chartpath, "charts")

// archive a dep chart from local directory and save it into destPath
func tarFromLocalDir(chartpath, name, repo, version, destPath string) (string, error) {
if !strings.HasPrefix(repo, "file://") {
return "", errors.Errorf("wrong format: chart %s repository %s", name, repo)
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/downloader/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@ func TestDownloadAll(t *testing.T) {
if err := m.downloadAll([]*chart.Dependency{signDep, localDep}); err != nil {
t.Error(err)
}

if _, err := os.Stat(filepath.Join(chartPath, "charts", "signtest-0.1.0.tgz")); os.IsNotExist(err) {
t.Error(err)
}
}

func TestUpdateBeforeBuild(t *testing.T) {
Expand Down

0 comments on commit adfb52e

Please sign in to comment.