mirror of
https://github.com/helm/helm.git
synced 2026-02-27 03:51:27 -05:00
feat(helm): add local path support for deps in requirements.yaml
fix change requests
This commit is contained in:
parent
d72ff65325
commit
39a2d5ec29
4 changed files with 27 additions and 4 deletions
|
|
@ -39,6 +39,16 @@ appending '/index.yaml' to the URL, it should be able to retrieve the chart
|
|||
repository's index. Note: 'repository' cannot be a repository alias. It must be
|
||||
a URL.
|
||||
|
||||
Starting from 2.2.0, repository can be defined as the path to the directory of
|
||||
the dependency charts stored locally. The path should start with a prefix of "file://".
|
||||
For example,
|
||||
# requirements.yaml
|
||||
dependencies:
|
||||
- name: nginx
|
||||
version: "1.2.3"
|
||||
repository: "file://../depedency_chart/nginx"
|
||||
If the dependency chart is retrieved locally, it is not required to have the repository
|
||||
added to helm by "helm add repo". Version matching is also supported for this case.
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
|
|
|
|||
|
|
@ -313,13 +313,13 @@ func (m *Manager) getRepoNames(deps []*chartutil.Dependency) (map[string]string,
|
|||
for _, dd := range deps {
|
||||
// if dep chart is from local path, verify the path is valid
|
||||
if strings.HasPrefix(dd.Repository, "file://") {
|
||||
depPath, err := filepath.Abs(dd.Repository[7:])
|
||||
depPath, err := filepath.Abs(strings.TrimPrefix(dd.Repository, "file://"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if _, err = os.Stat(depPath); os.IsNotExist(err) {
|
||||
return nil, fmt.Errorf("directory %s not found: %s", depPath, err)
|
||||
return nil, fmt.Errorf("directory %s not found", depPath)
|
||||
}
|
||||
|
||||
fmt.Fprintf(m.Out, "Repository from local path: %s\n", dd.Repository)
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ func (r *Resolver) Resolve(reqs *chartutil.Requirements, repoNames map[string]st
|
|||
missing := []string{}
|
||||
for i, d := range reqs.Dependencies {
|
||||
if strings.HasPrefix(d.Repository, "file://") {
|
||||
depPath, err := filepath.Abs(d.Repository[7:])
|
||||
depPath, err := filepath.Abs(strings.TrimPrefix(d.Repository, "file://"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,7 +78,20 @@ func TestResolve(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
name: "repo from local invalid path",
|
||||
name: "repo from valid local path",
|
||||
req: &chartutil.Requirements{
|
||||
Dependencies: []*chartutil.Dependency{
|
||||
{Name: "signtest", Repository: "file://../testdata/testcharts/signtest", Version: "0.1.0"},
|
||||
},
|
||||
},
|
||||
expect: &chartutil.RequirementsLock{
|
||||
Dependencies: []*chartutil.Dependency{
|
||||
{Name: "signtest", Repository: "file://../testdata/testcharts/signtest", Version: "0.1.0"},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "repo from invalid local path",
|
||||
req: &chartutil.Requirements{
|
||||
Dependencies: []*chartutil.Dependency{
|
||||
{Name: "notexist", Repository: "file://../testdata/notexist", Version: "0.1.0"},
|
||||
|
|
|
|||
Loading…
Reference in a new issue