fix error checking from os.stat

pull/1923/head
Qin Wang 8 years ago
parent 39a2d5ec29
commit 0153d273ce

@ -320,6 +320,8 @@ func (m *Manager) getRepoNames(deps []*chartutil.Dependency) (map[string]string,
if _, err = os.Stat(depPath); os.IsNotExist(err) {
return nil, fmt.Errorf("directory %s not found", depPath)
} else if err != nil {
return nil, err
}
fmt.Fprintf(m.Out, "Repository from local path: %s\n", dd.Repository)
@ -516,13 +518,20 @@ func writeLock(chartpath string, lock *chartutil.RequirementsLock) error {
// archive a dep chart from local directory and save it into charts/
func tarFromLocalDir(chartpath string, name string, repo string, version string) (string, error) {
destPath := filepath.Join(chartpath, "charts")
origPath, err := filepath.Abs(repo[7:])
if !strings.HasPrefix(repo, "file://") {
return "", fmt.Errorf("wrong format: chart %s repository %s", name, repo)
}
origPath, err := filepath.Abs(strings.TrimPrefix(repo, "file://"))
if err != nil {
return "", err
}
if _, err = os.Stat(origPath); os.IsNotExist(err) {
return "", fmt.Errorf("directory %s not found: %s", origPath, err)
} else if err != nil {
return "", err
}
ch, err := chartutil.LoadDir(origPath)

@ -65,6 +65,8 @@ func (r *Resolver) Resolve(reqs *chartutil.Requirements, repoNames map[string]st
if _, err = os.Stat(depPath); os.IsNotExist(err) {
return nil, fmt.Errorf("directory %s not found", depPath)
} else if err != nil {
return nil, err
}
locked[i] = &chartutil.Dependency{

Loading…
Cancel
Save