GetLocalPath generates absolute local path when use "file://" in repository of dependencies
(repo, chartpath string)
| 240 | // GetLocalPath generates absolute local path when use |
| 241 | // "file://" in repository of dependencies |
| 242 | func GetLocalPath(repo, chartpath string) (string, error) { |
| 243 | var depPath string |
| 244 | var err error |
| 245 | p := strings.TrimPrefix(repo, "file://") |
| 246 | |
| 247 | // root path is absolute |
| 248 | if strings.HasPrefix(p, "/") { |
| 249 | if depPath, err = filepath.Abs(p); err != nil { |
| 250 | return "", err |
| 251 | } |
| 252 | } else { |
| 253 | depPath = filepath.Join(chartpath, p) |
| 254 | } |
| 255 | |
| 256 | if _, err = os.Stat(depPath); errors.Is(err, fs.ErrNotExist) { |
| 257 | return "", fmt.Errorf("directory %s not found", depPath) |
| 258 | } else if err != nil { |
| 259 | return "", err |
| 260 | } |
| 261 | |
| 262 | return depPath, nil |
| 263 | } |
searching dependent graphs…