From 85aef0d3d76defd6f5c1e3b996c8933c2cc6e5d8 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Wed, 28 Nov 2018 10:20:33 -0800 Subject: [PATCH] ref(pkg/chart): rename Requirements to Dependencies Signed-off-by: Adam Reese --- cmd/helm/dependency.go | 31 ++++----- cmd/helm/dependency_test.go | 6 +- cmd/helm/dependency_update.go | 2 +- cmd/helm/dependency_update_test.go | 4 +- cmd/helm/install.go | 6 +- cmd/helm/package.go | 2 +- cmd/helm/template.go | 8 +-- .../dependency-list-no-requirements.txt | 2 +- .../testdata/output/list-with-namespace.txt | 2 - .../chart-bad-requirements/requirements.yaml | 4 -- .../chart-missing-deps/requirements.yaml | 7 -- .../testcharts/reqtest/requirements.yaml | 10 --- cmd/helm/upgrade.go | 4 +- pkg/chart/dependency.go | 4 +- pkg/chart/loader/load_test.go | 28 ++++---- pkg/chart/metadata.go | 4 +- .../{requirements.go => dependencies.go} | 38 +++++------ ...uirements_test.go => dependencies_test.go} | 68 +++++++++---------- .../dependent-chart-alias/requirements.yaml | 12 ---- .../requirements.yaml | 7 -- .../requirements.yaml | 4 -- .../testdata/frobnitz/requirements.yaml | 7 -- .../frobnitz_backslash/requirements.yaml | 7 -- .../testdata/mariner/requirements.yaml | 4 -- .../subpop/charts/subchart1/requirements.yaml | 32 --------- .../subpop/charts/subchart2/requirements.yaml | 15 ---- .../testdata/subpop/requirements.yaml | 31 --------- pkg/downloader/manager.go | 14 ++-- pkg/helm/client.go | 8 +-- pkg/resolver/resolver.go | 4 +- 30 files changed, 116 insertions(+), 259 deletions(-) delete mode 100644 cmd/helm/testdata/output/list-with-namespace.txt delete mode 100644 cmd/helm/testdata/testcharts/chart-bad-requirements/requirements.yaml delete mode 100644 cmd/helm/testdata/testcharts/chart-missing-deps/requirements.yaml delete mode 100644 cmd/helm/testdata/testcharts/reqtest/requirements.yaml rename pkg/chartutil/{requirements.go => dependencies.go} (84%) rename pkg/chartutil/{requirements_test.go => dependencies_test.go} (85%) delete mode 100644 pkg/chartutil/testdata/dependent-chart-alias/requirements.yaml delete mode 100644 pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/requirements.yaml delete mode 100644 pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/requirements.yaml delete mode 100644 pkg/chartutil/testdata/frobnitz/requirements.yaml delete mode 100755 pkg/chartutil/testdata/frobnitz_backslash/requirements.yaml delete mode 100644 pkg/chartutil/testdata/mariner/requirements.yaml delete mode 100644 pkg/chartutil/testdata/subpop/charts/subchart1/requirements.yaml delete mode 100644 pkg/chartutil/testdata/subpop/charts/subchart2/requirements.yaml delete mode 100644 pkg/chartutil/testdata/subpop/requirements.yaml diff --git a/cmd/helm/dependency.go b/cmd/helm/dependency.go index ff88150cd..2fd639d7d 100644 --- a/cmd/helm/dependency.go +++ b/cmd/helm/dependency.go @@ -34,18 +34,16 @@ const dependencyDesc = ` Manage the dependencies of a chart. Helm charts store their dependencies in 'charts/'. For chart developers, it is -often easier to manage a single dependency file ('requirements.yaml') -which declares all dependencies. +often easier to manage dependencies in 'Chart.yaml' which declares all +dependencies. The dependency commands operate on that file, making it easy to synchronize between the desired dependencies and the actual dependencies stored in the 'charts/' directory. -A 'requirements.yaml' file is a YAML file in which developers can declare chart -dependencies, along with the location of the chart and the desired version. -For example, this requirements file declares two dependencies: +For example, this Chart.yaml declares two dependencies: - # requirements.yaml + # Chart.yaml dependencies: - name: nginx version: "1.2.3" @@ -54,6 +52,7 @@ For example, this requirements file declares two dependencies: version: "3.2.1" repository: "https://another.example.com/charts" + The 'name' should be the name of a chart, where that name must match the name in that chart's 'Chart.yaml' file. @@ -68,7 +67,7 @@ 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 + # Chart.yaml dependencies: - name: nginx version: "1.2.3" @@ -85,8 +84,7 @@ List all of the dependencies declared in a chart. This can take chart archives and chart directories as input. It will not alter the contents of a chart. -This will produce an error if the chart cannot be loaded. It will emit a warning -if it cannot find a requirements.yaml. +This will produce an error if the chart cannot be loaded. ` func newDependencyCmd(out io.Writer) *cobra.Command { @@ -136,14 +134,14 @@ func (o *dependencyLisOptions) run(out io.Writer) error { return err } - if c.Metadata.Requirements == nil { - fmt.Fprintf(out, "WARNING: no requirements at %s/charts\n", o.chartpath) + if c.Metadata.Dependencies == nil { + fmt.Fprintf(out, "WARNING: no dependencies at %s/charts\n", o.chartpath) return nil } - o.printRequirements(out, c.Metadata.Requirements) + o.printDependencies(out, c.Metadata.Dependencies) fmt.Fprintln(out) - o.printMissing(out, c.Metadata.Requirements) + o.printMissing(out, c.Metadata.Dependencies) return nil } @@ -221,8 +219,8 @@ func (o *dependencyLisOptions) dependencyStatus(dep *chart.Dependency) string { return "unpacked" } -// printRequirements prints all of the requirements in the yaml file. -func (o *dependencyLisOptions) printRequirements(out io.Writer, reqs []*chart.Dependency) { +// printDependencies prints all of the dependencies in the yaml file. +func (o *dependencyLisOptions) printDependencies(out io.Writer, reqs []*chart.Dependency) { table := uitable.New() table.MaxColWidth = 80 table.AddRow("NAME", "VERSION", "REPOSITORY", "STATUS") @@ -232,7 +230,8 @@ func (o *dependencyLisOptions) printRequirements(out io.Writer, reqs []*chart.De fmt.Fprintln(out, table) } -// printMissing prints warnings about charts that are present on disk, but are not in the requirements. +// printMissing prints warnings about charts that are present on disk, but are +// not in Charts.yaml. func (o *dependencyLisOptions) printMissing(out io.Writer, reqs []*chart.Dependency) { folder := filepath.Join(o.chartpath, "charts/*") files, err := filepath.Glob(folder) diff --git a/cmd/helm/dependency_test.go b/cmd/helm/dependency_test.go index da4829736..709741b7a 100644 --- a/cmd/helm/dependency_test.go +++ b/cmd/helm/dependency_test.go @@ -26,15 +26,15 @@ func TestDependencyListCmd(t *testing.T) { golden: "output/dependency-list-no-chart.txt", wantError: true, }, { - name: "No requirements.yaml", + name: "No dependencies", cmd: "dependency list testdata/testcharts/alpine", golden: "output/dependency-list-no-requirements.txt", }, { - name: "Requirements in chart dir", + name: "Dependencies in chart dir", cmd: "dependency list testdata/testcharts/reqtest", golden: "output/dependency-list.txt", }, { - name: "Requirements in chart archive", + name: "Dependencies in chart archive", cmd: "dependency list testdata/testcharts/reqtest-0.1.0.tgz", golden: "output/dependency-list-archive.txt", }} diff --git a/cmd/helm/dependency_update.go b/cmd/helm/dependency_update.go index 586c2e09b..1ce07fb52 100644 --- a/cmd/helm/dependency_update.go +++ b/cmd/helm/dependency_update.go @@ -35,7 +35,7 @@ are present in 'charts/' and are at an acceptable version. It will pull down the latest charts that satisfy the dependencies, and clean up old dependencies. On successful update, this will generate a lock file that can be used to -rebuild the requirements to an exact version. +rebuild the dependencies to an exact version. Dependencies are not required to be represented in 'Chart.yaml'. For that reason, an update command will not remove charts unless they are (a) present diff --git a/cmd/helm/dependency_update_test.go b/cmd/helm/dependency_update_test.go index f6a8b91cb..5a9d80585 100644 --- a/cmd/helm/dependency_update_test.go +++ b/cmd/helm/dependency_update_test.go @@ -86,7 +86,7 @@ func TestDependencyUpdateCmd(t *testing.T) { // Now change the dependencies and update. This verifies that on update, // old dependencies are cleansed and new dependencies are added. - md.Requirements = []*chart.Dependency{ + md.Dependencies = []*chart.Dependency{ {Name: "reqtest", Version: "0.1.0", Repository: srv.URL()}, {Name: "compressedchart", Version: "0.3.0", Repository: srv.URL()}, } @@ -213,7 +213,7 @@ func createTestingMetadata(name, baseURL string) *chart.Metadata { return &chart.Metadata{ Name: name, Version: "1.2.3", - Requirements: []*chart.Dependency{ + Dependencies: []*chart.Dependency{ {Name: "reqtest", Version: "0.1.0", Repository: baseURL}, {Name: "compressedchart", Version: "0.1.0", Repository: baseURL}, }, diff --git a/cmd/helm/install.go b/cmd/helm/install.go index 09b1bec51..3ea6d26e7 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -219,13 +219,13 @@ func (o *installOptions) run(out io.Writer) error { fmt.Printf("FINAL NAME: %s\n", o.name) } - // Check chart requirements to make sure all dependencies are present in /charts + // Check chart dependencies to make sure all are present in /charts chartRequested, err := loader.Load(o.chartPath) if err != nil { return err } - if req := chartRequested.Metadata.Requirements; req != nil { + if req := chartRequested.Metadata.Dependencies; req != nil { // If checkDependencies returns an error, we have unfulfilled dependencies. // As of Helm 2.4.0, this is treated as a stopping condition: // https://github.com/kubernetes/helm/issues/2209 @@ -344,7 +344,7 @@ OUTER: } if len(missing) > 0 { - return errors.Errorf("found in requirements.yaml, but missing in charts/ directory: %s", strings.Join(missing, ", ")) + return errors.Errorf("found in Chart.yaml, but missing in charts/ directory: %s", strings.Join(missing, ", ")) } return nil } diff --git a/cmd/helm/package.go b/cmd/helm/package.go index 0178af6ab..c5ec6e36a 100644 --- a/cmd/helm/package.go +++ b/cmd/helm/package.go @@ -157,7 +157,7 @@ func (o *packageOptions) run(out io.Writer) error { debug("Setting appVersion to %s", o.appVersion) } - if reqs := ch.Metadata.Requirements; reqs != nil { + if reqs := ch.Metadata.Dependencies; reqs != nil { if err := checkDependencies(ch, reqs); err != nil { return err } diff --git a/cmd/helm/template.go b/cmd/helm/template.go index 4c48f0e6d..d5019283b 100644 --- a/cmd/helm/template.go +++ b/cmd/helm/template.go @@ -152,13 +152,13 @@ func (o *templateOptions) run(out io.Writer) error { } } - // Check chart requirements to make sure all dependencies are present in /charts + // Check chart dependencies to make sure all are present in /charts c, err := loader.Load(o.chartPath) if err != nil { return err } - if req := c.Metadata.Requirements; req != nil { + if req := c.Metadata.Dependencies; req != nil { if err := checkDependencies(c, req); err != nil { return err } @@ -171,10 +171,10 @@ func (o *templateOptions) run(out io.Writer) error { if err := yaml.Unmarshal(config, &m); err != nil { return err } - if err := chartutil.ProcessRequirementsEnabled(c, m); err != nil { + if err := chartutil.ProcessDependencyEnabled(c, m); err != nil { return err } - if err := chartutil.ProcessRequirementsImportValues(c); err != nil { + if err := chartutil.ProcessDependencyImportValues(c); err != nil { return err } diff --git a/cmd/helm/testdata/output/dependency-list-no-requirements.txt b/cmd/helm/testdata/output/dependency-list-no-requirements.txt index 7e698e627..35fe1d2e3 100644 --- a/cmd/helm/testdata/output/dependency-list-no-requirements.txt +++ b/cmd/helm/testdata/output/dependency-list-no-requirements.txt @@ -1 +1 @@ -WARNING: no requirements at testdata/testcharts/alpine/charts +WARNING: no dependencies at testdata/testcharts/alpine/charts diff --git a/cmd/helm/testdata/output/list-with-namespace.txt b/cmd/helm/testdata/output/list-with-namespace.txt deleted file mode 100644 index 289dcac23..000000000 --- a/cmd/helm/testdata/output/list-with-namespace.txt +++ /dev/null @@ -1,2 +0,0 @@ -thomas-guide -atlas-guide diff --git a/cmd/helm/testdata/testcharts/chart-bad-requirements/requirements.yaml b/cmd/helm/testdata/testcharts/chart-bad-requirements/requirements.yaml deleted file mode 100644 index 10c4d6dcb..000000000 --- a/cmd/helm/testdata/testcharts/chart-bad-requirements/requirements.yaml +++ /dev/null @@ -1,4 +0,0 @@ -dependencies: - - name: reqsubchart - version: 0.1.0 - repository: "https://example.com/charts" diff --git a/cmd/helm/testdata/testcharts/chart-missing-deps/requirements.yaml b/cmd/helm/testdata/testcharts/chart-missing-deps/requirements.yaml deleted file mode 100644 index 4b0b8c2db..000000000 --- a/cmd/helm/testdata/testcharts/chart-missing-deps/requirements.yaml +++ /dev/null @@ -1,7 +0,0 @@ -dependencies: - - name: reqsubchart - version: 0.1.0 - repository: "https://example.com/charts" - - name: reqsubchart2 - version: 0.2.0 - repository: "https://example.com/charts" diff --git a/cmd/helm/testdata/testcharts/reqtest/requirements.yaml b/cmd/helm/testdata/testcharts/reqtest/requirements.yaml deleted file mode 100644 index 1ddedc742..000000000 --- a/cmd/helm/testdata/testcharts/reqtest/requirements.yaml +++ /dev/null @@ -1,10 +0,0 @@ -dependencies: - - name: reqsubchart - version: 0.1.0 - repository: "https://example.com/charts" - - name: reqsubchart2 - version: 0.2.0 - repository: "https://example.com/charts" - - name: reqsubchart3 - version: ">=0.1.0" - repository: "https://example.com/charts" diff --git a/cmd/helm/upgrade.go b/cmd/helm/upgrade.go index 30f1198a4..73082dc1d 100644 --- a/cmd/helm/upgrade.go +++ b/cmd/helm/upgrade.go @@ -146,12 +146,12 @@ func (o *upgradeOptions) run(out io.Writer) error { return err } - // Check chart requirements to make sure all dependencies are present in /charts + // Check chart dependencies to make sure all are present in /charts ch, err := loader.Load(chartPath) if err != nil { return err } - if req := ch.Metadata.Requirements; req != nil { + if req := ch.Metadata.Dependencies; req != nil { if err := checkDependencies(ch, req); err != nil { return err } diff --git a/pkg/chart/dependency.go b/pkg/chart/dependency.go index 2c17a97c6..0837f8d19 100644 --- a/pkg/chart/dependency.go +++ b/pkg/chart/dependency.go @@ -49,13 +49,13 @@ type Dependency struct { Alias string `json:"alias,omitempty"` } -// Lock is a lock file for requirements. +// Lock is a lock file for dependencies. // // It represents the state that the dependencies should be in. type Lock struct { // Genderated is the date the lock file was last generated. Generated time.Time `json:"generated"` - // Digest is a hash of the requirements file used to generate it. + // Digest is a hash of the dependencies in Chart.yaml. Digest string `json:"digest"` // Dependencies is the list of dependencies that this lock file has locked. Dependencies []*Dependency `json:"dependencies"` diff --git a/pkg/chart/loader/load_test.go b/pkg/chart/loader/load_test.go index 6fda07ceb..f2d072aa6 100644 --- a/pkg/chart/loader/load_test.go +++ b/pkg/chart/loader/load_test.go @@ -33,8 +33,8 @@ func TestLoadDir(t *testing.T) { } verifyFrobnitz(t, c) verifyChart(t, c) - verifyRequirements(t, c) - verifyRequirementsLock(t, c) + verifyDependencies(t, c) + verifyDependenciesLock(t, c) } func TestLoadFile(t *testing.T) { @@ -48,7 +48,7 @@ func TestLoadFile(t *testing.T) { } verifyFrobnitz(t, c) verifyChart(t, c) - verifyRequirements(t, c) + verifyDependencies(t, c) } func TestLoadFiles(t *testing.T) { @@ -123,7 +123,7 @@ func TestLoadFileBackslash(t *testing.T) { } verifyChartFileAndTemplate(t, c, "frobnitz_backslash") verifyChart(t, c) - verifyRequirements(t, c) + verifyDependencies(t, c) } func verifyChart(t *testing.T, c *chart.Chart) { @@ -175,16 +175,16 @@ func verifyChart(t *testing.T, c *chart.Chart) { } -func verifyRequirements(t *testing.T, c *chart.Chart) { - if len(c.Metadata.Requirements) != 2 { - t.Errorf("Expected 2 requirements, got %d", len(c.Metadata.Requirements)) +func verifyDependencies(t *testing.T, c *chart.Chart) { + if len(c.Metadata.Dependencies) != 2 { + t.Errorf("Expected 2 dependencies, got %d", len(c.Metadata.Dependencies)) } tests := []*chart.Dependency{ {Name: "alpine", Version: "0.1.0", Repository: "https://example.com/charts"}, {Name: "mariner", Version: "4.3.2", Repository: "https://example.com/charts"}, } for i, tt := range tests { - d := c.Metadata.Requirements[i] + d := c.Metadata.Dependencies[i] if d.Name != tt.Name { t.Errorf("Expected dependency named %q, got %q", tt.Name, d.Name) } @@ -197,16 +197,16 @@ func verifyRequirements(t *testing.T, c *chart.Chart) { } } -func verifyRequirementsLock(t *testing.T, c *chart.Chart) { - if len(c.Metadata.Requirements) != 2 { - t.Errorf("Expected 2 requirements, got %d", len(c.Metadata.Requirements)) +func verifyDependenciesLock(t *testing.T, c *chart.Chart) { + if len(c.Metadata.Dependencies) != 2 { + t.Errorf("Expected 2 dependencies, got %d", len(c.Metadata.Dependencies)) } tests := []*chart.Dependency{ {Name: "alpine", Version: "0.1.0", Repository: "https://example.com/charts"}, {Name: "mariner", Version: "4.3.2", Repository: "https://example.com/charts"}, } for i, tt := range tests { - d := c.Metadata.Requirements[i] + d := c.Metadata.Dependencies[i] if d.Name != tt.Name { t.Errorf("Expected dependency named %q, got %q", tt.Name, d.Name) } @@ -245,8 +245,8 @@ func verifyChartFileAndTemplate(t *testing.T, c *chart.Chart, name string) { if len(c.Dependencies()) != 2 { t.Fatalf("Expected 2 Dependency, got %d", len(c.Dependencies())) } - if len(c.Metadata.Requirements) != 2 { - t.Fatalf("Expected 2 Requirements.Dependency, got %d", len(c.Metadata.Requirements)) + if len(c.Metadata.Dependencies) != 2 { + t.Fatalf("Expected 2 Dependencies.Dependency, got %d", len(c.Metadata.Dependencies)) } if len(c.Lock.Dependencies) != 2 { t.Fatalf("Expected 2 Lock.Dependency, got %d", len(c.Lock.Dependencies)) diff --git a/pkg/chart/metadata.go b/pkg/chart/metadata.go index 239bdd2eb..a89e371f2 100644 --- a/pkg/chart/metadata.go +++ b/pkg/chart/metadata.go @@ -65,6 +65,6 @@ type Metadata struct { Annotations map[string]string `json:"annotations,omitempty"` // KubeVersion is a SemVer constraint specifying the version of Kubernetes required. KubeVersion string `json:"kubeVersion,omitempty"` - // Requirements are a list of requirements for a chart. - Requirements []*Dependency `json:"dependencies,omitempty"` + // Dependencies are a list of dependencies for a chart. + Dependencies []*Dependency `json:"dependencies,omitempty"` } diff --git a/pkg/chartutil/requirements.go b/pkg/chartutil/dependencies.go similarity index 84% rename from pkg/chartutil/requirements.go rename to pkg/chartutil/dependencies.go index 3a003e1a3..fbb56ec28 100644 --- a/pkg/chartutil/requirements.go +++ b/pkg/chartutil/dependencies.go @@ -25,8 +25,8 @@ import ( "k8s.io/helm/pkg/version" ) -// ProcessRequirementsConditions disables charts based on condition path value in values -func ProcessRequirementsConditions(reqs []*chart.Dependency, cvals Values) { +// ProcessDependencyConditions disables charts based on condition path value in values +func ProcessDependencyConditions(reqs []*chart.Dependency, cvals Values) { if reqs == nil { return } @@ -66,8 +66,8 @@ func ProcessRequirementsConditions(reqs []*chart.Dependency, cvals Values) { } } -// ProcessRequirementsTags disables charts based on tags in values -func ProcessRequirementsTags(reqs []*chart.Dependency, cvals Values) { +// ProcessDependencyTags disables charts based on tags in values +func ProcessDependencyTags(reqs []*chart.Dependency, cvals Values) { if reqs == nil { return } @@ -125,9 +125,9 @@ func getAliasDependency(charts []*chart.Chart, aliasChart *chart.Dependency) *ch return nil } -// ProcessRequirementsEnabled removes disabled charts from dependencies -func ProcessRequirementsEnabled(c *chart.Chart, v map[string]interface{}) error { - if c.Metadata.Requirements == nil { +// ProcessDependencyEnabled removes disabled charts from dependencies +func ProcessDependencyEnabled(c *chart.Chart, v map[string]interface{}) error { + if c.Metadata.Dependencies == nil { return nil } @@ -139,7 +139,7 @@ func ProcessRequirementsEnabled(c *chart.Chart, v map[string]interface{}) error for _, existingDependency := range c.Dependencies() { var dependencyFound bool - for _, req := range c.Metadata.Requirements { + for _, req := range c.Metadata.Dependencies { if existingDependency.Metadata.Name == req.Name && version.IsCompatibleRange(req.Version, existingDependency.Metadata.Version) { dependencyFound = true break @@ -150,7 +150,7 @@ func ProcessRequirementsEnabled(c *chart.Chart, v map[string]interface{}) error } } - for _, req := range c.Metadata.Requirements { + for _, req := range c.Metadata.Dependencies { if chartDependency := getAliasDependency(c.Dependencies(), req); chartDependency != nil { chartDependencies = append(chartDependencies, chartDependency) } @@ -161,7 +161,7 @@ func ProcessRequirementsEnabled(c *chart.Chart, v map[string]interface{}) error c.SetDependencies(chartDependencies...) // set all to true - for _, lr := range c.Metadata.Requirements { + for _, lr := range c.Metadata.Dependencies { lr.Enabled = true } b, _ := yaml.Marshal(v) @@ -170,11 +170,11 @@ func ProcessRequirementsEnabled(c *chart.Chart, v map[string]interface{}) error return err } // flag dependencies as enabled/disabled - ProcessRequirementsTags(c.Metadata.Requirements, cvals) - ProcessRequirementsConditions(c.Metadata.Requirements, cvals) + ProcessDependencyTags(c.Metadata.Dependencies, cvals) + ProcessDependencyConditions(c.Metadata.Dependencies, cvals) // make a map of charts to remove rm := map[string]struct{}{} - for _, r := range c.Metadata.Requirements { + for _, r := range c.Metadata.Dependencies { if !r.Enabled { // remove disabled chart rm[r.Name] = struct{}{} @@ -191,7 +191,7 @@ func ProcessRequirementsEnabled(c *chart.Chart, v map[string]interface{}) error // recursively call self to process sub dependencies for _, t := range cd { - if err := ProcessRequirementsEnabled(t, cvals); err != nil { + if err := ProcessDependencyEnabled(t, cvals); err != nil { return err } } @@ -221,7 +221,7 @@ func set(path []string, data map[string]interface{}) map[string]interface{} { // processImportValues merges values from child to parent based on the chart's dependencies' ImportValues field. func processImportValues(c *chart.Chart) error { - if c.Metadata.Requirements == nil { + if c.Metadata.Dependencies == nil { return nil } // combine chart values and empty config to get Values @@ -231,7 +231,7 @@ func processImportValues(c *chart.Chart) error { } b := make(map[string]interface{}) // import values from each dependency if specified in import-values - for _, r := range c.Metadata.Requirements { + for _, r := range c.Metadata.Dependencies { var outiv []interface{} for _, riv := range r.ImportValues { switch iv := riv.(type) { @@ -276,11 +276,11 @@ func processImportValues(c *chart.Chart) error { return nil } -// ProcessRequirementsImportValues imports specified chart values from child to parent. -func ProcessRequirementsImportValues(c *chart.Chart) error { +// ProcessDependencyImportValues imports specified chart values from child to parent. +func ProcessDependencyImportValues(c *chart.Chart) error { for _, d := range c.Dependencies() { // recurse - if err := ProcessRequirementsImportValues(d); err != nil { + if err := ProcessDependencyImportValues(d); err != nil { return err } } diff --git a/pkg/chartutil/requirements_test.go b/pkg/chartutil/dependencies_test.go similarity index 85% rename from pkg/chartutil/requirements_test.go rename to pkg/chartutil/dependencies_test.go index 1683c01e2..e65958cd0 100644 --- a/pkg/chartutil/requirements_test.go +++ b/pkg/chartutil/dependencies_test.go @@ -27,12 +27,12 @@ import ( "k8s.io/helm/pkg/version" ) -func TestLoadRequirements(t *testing.T) { +func TestLoadDependency(t *testing.T) { c, err := loader.Load("testdata/frobnitz") if err != nil { t.Fatalf("Failed to load testdata: %s", err) } - verifyRequirements(t, c) + verifyDependency(t, c) } func TestLoadChartLock(t *testing.T) { @@ -43,7 +43,7 @@ func TestLoadChartLock(t *testing.T) { verifyChartLock(t, c) } -func TestRequirementsEnabled(t *testing.T) { +func TestDependencyEnabled(t *testing.T) { tests := []struct { name string v []byte @@ -104,16 +104,16 @@ func TestRequirementsEnabled(t *testing.T) { t.Fatalf("Failed to load testdata: %s", err) } t.Run(tc.name, func(t *testing.T) { - verifyRequirementsEnabled(t, c, tc.v, tc.e) + verifyDependencyEnabled(t, c, tc.v, tc.e) }) } } -func verifyRequirementsEnabled(t *testing.T, c *chart.Chart, v []byte, e []string) { +func verifyDependencyEnabled(t *testing.T, c *chart.Chart, v []byte, e []string) { var m map[string]interface{} yaml.Unmarshal(v, &m) - if err := ProcessRequirementsEnabled(c, m); err != nil { - t.Errorf("Error processing enabled requirements %v", err) + if err := ProcessDependencyEnabled(c, m); err != nil { + t.Errorf("Error processing enabled dependencies %v", err) } out := extractCharts(c, nil) @@ -146,7 +146,7 @@ func extractCharts(c *chart.Chart, out []*chart.Chart) []*chart.Chart { return out } -func TestProcessRequirementsImportValues(t *testing.T) { +func TestProcessDependencyImportValues(t *testing.T) { c, err := loader.Load("testdata/subpop") if err != nil { t.Fatalf("Failed to load testdata: %s", err) @@ -213,12 +213,12 @@ func TestProcessRequirementsImportValues(t *testing.T) { e["SCBexported2A"] = "blaster" e["global.SC1exported2.all.SC1exported3"] = "SC1expstr" - verifyRequirementsImportValues(t, c, e) + verifyDependencyImportValues(t, c, e) } -func verifyRequirementsImportValues(t *testing.T, c *chart.Chart, e map[string]string) { - if err := ProcessRequirementsImportValues(c); err != nil { - t.Fatalf("Error processing import values requirements %v", err) +func verifyDependencyImportValues(t *testing.T, c *chart.Chart, e map[string]string) { + if err := ProcessDependencyImportValues(c); err != nil { + t.Fatalf("Error processing import values dependencies %v", err) } cc := Values(c.Values) for kk, vv := range e { @@ -256,10 +256,10 @@ func TestGetAliasDependency(t *testing.T) { t.Fatalf("Failed to load testdata: %s", err) } - req := c.Metadata.Requirements + req := c.Metadata.Dependencies if len(req) == 0 { - t.Fatalf("There are no requirements to test") + t.Fatalf("There are no dependencies to test") } // Success case @@ -304,7 +304,7 @@ func TestDependentChartAliases(t *testing.T) { } origLength := len(c.Dependencies()) - if err := ProcessRequirementsEnabled(c, c.Values); err != nil { + if err := ProcessDependencyEnabled(c, c.Values); err != nil { t.Fatalf("Expected no errors but got %q", err) } @@ -312,12 +312,12 @@ func TestDependentChartAliases(t *testing.T) { t.Fatal("Expected alias dependencies to be added, but did not got that") } - if len(c.Dependencies()) != len(c.Metadata.Requirements) { - t.Fatalf("Expected number of chart dependencies %d, but got %d", len(c.Metadata.Requirements), len(c.Dependencies())) + if len(c.Dependencies()) != len(c.Metadata.Dependencies) { + t.Fatalf("Expected number of chart dependencies %d, but got %d", len(c.Metadata.Dependencies), len(c.Dependencies())) } } -func TestDependentChartWithSubChartsAbsentInRequirements(t *testing.T) { +func TestDependentChartWithSubChartsAbsentInDependency(t *testing.T) { c, err := loader.Load("testdata/dependent-chart-no-requirements-yaml") if err != nil { t.Fatalf("Failed to load testdata: %s", err) @@ -328,7 +328,7 @@ func TestDependentChartWithSubChartsAbsentInRequirements(t *testing.T) { } origLength := len(c.Dependencies()) - if err := ProcessRequirementsEnabled(c, c.Values); err != nil { + if err := ProcessDependencyEnabled(c, c.Values); err != nil { t.Fatalf("Expected no errors but got %q", err) } @@ -356,7 +356,7 @@ func TestDependentChartsWithSubChartsSymlink(t *testing.T) { } } -func TestDependentChartsWithSubchartsAllSpecifiedInRequirements(t *testing.T) { +func TestDependentChartsWithSubchartsAllSpecifiedInDependency(t *testing.T) { c, err := loader.Load("testdata/dependent-chart-with-all-in-requirements-yaml") if err != nil { t.Fatalf("Failed to load testdata: %s", err) @@ -367,7 +367,7 @@ func TestDependentChartsWithSubchartsAllSpecifiedInRequirements(t *testing.T) { } origLength := len(c.Dependencies()) - if err := ProcessRequirementsEnabled(c, c.Values); err != nil { + if err := ProcessDependencyEnabled(c, c.Values); err != nil { t.Fatalf("Expected no errors but got %q", err) } @@ -375,12 +375,12 @@ func TestDependentChartsWithSubchartsAllSpecifiedInRequirements(t *testing.T) { t.Fatal("Expected no changes in dependencies to be, but did something got changed") } - if len(c.Dependencies()) != len(c.Metadata.Requirements) { - t.Fatalf("Expected number of chart dependencies %d, but got %d", len(c.Metadata.Requirements), len(c.Dependencies())) + if len(c.Dependencies()) != len(c.Metadata.Dependencies) { + t.Fatalf("Expected number of chart dependencies %d, but got %d", len(c.Metadata.Dependencies), len(c.Dependencies())) } } -func TestDependentChartsWithSomeSubchartsSpecifiedInRequirements(t *testing.T) { +func TestDependentChartsWithSomeSubchartsSpecifiedInDependency(t *testing.T) { c, err := loader.Load("testdata/dependent-chart-with-mixed-requirements-yaml") if err != nil { t.Fatalf("Failed to load testdata: %s", err) @@ -391,7 +391,7 @@ func TestDependentChartsWithSomeSubchartsSpecifiedInRequirements(t *testing.T) { } origLength := len(c.Dependencies()) - if err := ProcessRequirementsEnabled(c, c.Values); err != nil { + if err := ProcessDependencyEnabled(c, c.Values); err != nil { t.Fatalf("Expected no errors but got %q", err) } @@ -399,21 +399,21 @@ func TestDependentChartsWithSomeSubchartsSpecifiedInRequirements(t *testing.T) { t.Fatal("Expected no changes in dependencies to be, but did something got changed") } - if len(c.Dependencies()) <= len(c.Metadata.Requirements) { - t.Fatalf("Expected more dependencies than specified in requirements.yaml(%d), but got %d", len(c.Metadata.Requirements), len(c.Dependencies())) + if len(c.Dependencies()) <= len(c.Metadata.Dependencies) { + t.Fatalf("Expected more dependencies than specified in Chart.yaml(%d), but got %d", len(c.Metadata.Dependencies), len(c.Dependencies())) } } -func verifyRequirements(t *testing.T, c *chart.Chart) { - if len(c.Metadata.Requirements) != 2 { - t.Errorf("Expected 2 requirements, got %d", len(c.Metadata.Requirements)) +func verifyDependency(t *testing.T, c *chart.Chart) { + if len(c.Metadata.Dependencies) != 2 { + t.Errorf("Expected 2 dependencies, got %d", len(c.Metadata.Dependencies)) } tests := []*chart.Dependency{ {Name: "alpine", Version: "0.1.0", Repository: "https://example.com/charts"}, {Name: "mariner", Version: "4.3.2", Repository: "https://example.com/charts"}, } for i, tt := range tests { - d := c.Metadata.Requirements[i] + d := c.Metadata.Dependencies[i] if d.Name != tt.Name { t.Errorf("Expected dependency named %q, got %q", tt.Name, d.Name) } @@ -427,15 +427,15 @@ func verifyRequirements(t *testing.T, c *chart.Chart) { } func verifyChartLock(t *testing.T, c *chart.Chart) { - if len(c.Metadata.Requirements) != 2 { - t.Errorf("Expected 2 requirements, got %d", len(c.Metadata.Requirements)) + if len(c.Metadata.Dependencies) != 2 { + t.Errorf("Expected 2 dependencies, got %d", len(c.Metadata.Dependencies)) } tests := []*chart.Dependency{ {Name: "alpine", Version: "0.1.0", Repository: "https://example.com/charts"}, {Name: "mariner", Version: "4.3.2", Repository: "https://example.com/charts"}, } for i, tt := range tests { - d := c.Metadata.Requirements[i] + d := c.Metadata.Dependencies[i] if d.Name != tt.Name { t.Errorf("Expected dependency named %q, got %q", tt.Name, d.Name) } diff --git a/pkg/chartutil/testdata/dependent-chart-alias/requirements.yaml b/pkg/chartutil/testdata/dependent-chart-alias/requirements.yaml deleted file mode 100644 index aab6cddf7..000000000 --- a/pkg/chartutil/testdata/dependent-chart-alias/requirements.yaml +++ /dev/null @@ -1,12 +0,0 @@ -dependencies: - - name: alpine - version: "0.1.0" - repository: https://example.com/charts - - name: mariner - version: "4.3.2" - repository: https://example.com/charts - alias: mariners2 - - name: mariner - version: "4.3.2" - repository: https://example.com/charts - alias: mariners1 diff --git a/pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/requirements.yaml b/pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/requirements.yaml deleted file mode 100644 index 5eb0bc98b..000000000 --- a/pkg/chartutil/testdata/dependent-chart-with-all-in-requirements-yaml/requirements.yaml +++ /dev/null @@ -1,7 +0,0 @@ -dependencies: - - name: alpine - version: "0.1.0" - repository: https://example.com/charts - - name: mariner - version: "4.3.2" - repository: https://example.com/charts diff --git a/pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/requirements.yaml b/pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/requirements.yaml deleted file mode 100644 index 5f8bdc5a8..000000000 --- a/pkg/chartutil/testdata/dependent-chart-with-mixed-requirements-yaml/requirements.yaml +++ /dev/null @@ -1,4 +0,0 @@ -dependencies: - - name: alpine - version: "0.1.0" - repository: https://example.com/charts diff --git a/pkg/chartutil/testdata/frobnitz/requirements.yaml b/pkg/chartutil/testdata/frobnitz/requirements.yaml deleted file mode 100644 index 5eb0bc98b..000000000 --- a/pkg/chartutil/testdata/frobnitz/requirements.yaml +++ /dev/null @@ -1,7 +0,0 @@ -dependencies: - - name: alpine - version: "0.1.0" - repository: https://example.com/charts - - name: mariner - version: "4.3.2" - repository: https://example.com/charts diff --git a/pkg/chartutil/testdata/frobnitz_backslash/requirements.yaml b/pkg/chartutil/testdata/frobnitz_backslash/requirements.yaml deleted file mode 100755 index 5eb0bc98b..000000000 --- a/pkg/chartutil/testdata/frobnitz_backslash/requirements.yaml +++ /dev/null @@ -1,7 +0,0 @@ -dependencies: - - name: alpine - version: "0.1.0" - repository: https://example.com/charts - - name: mariner - version: "4.3.2" - repository: https://example.com/charts diff --git a/pkg/chartutil/testdata/mariner/requirements.yaml b/pkg/chartutil/testdata/mariner/requirements.yaml deleted file mode 100644 index 0b21d15b7..000000000 --- a/pkg/chartutil/testdata/mariner/requirements.yaml +++ /dev/null @@ -1,4 +0,0 @@ -dependencies: - - name: albatross - repository: https://example.com/mariner/charts - version: "0.1.0" diff --git a/pkg/chartutil/testdata/subpop/charts/subchart1/requirements.yaml b/pkg/chartutil/testdata/subpop/charts/subchart1/requirements.yaml deleted file mode 100644 index abfe85e76..000000000 --- a/pkg/chartutil/testdata/subpop/charts/subchart1/requirements.yaml +++ /dev/null @@ -1,32 +0,0 @@ -dependencies: - - name: subcharta - repository: http://localhost:10191 - version: 0.1.0 - condition: subcharta.enabled,subchart1.subcharta.enabled - tags: - - front-end - - subcharta - import-values: - - child: SCAdata - parent: imported-chartA - - child: SCAdata - parent: overridden-chartA - - child: SCAdata - parent: imported-chartA-B - - - name: subchartb - repository: http://localhost:10191 - version: 0.1.0 - condition: subchartb.enabled - import-values: - - child: SCBdata - parent: imported-chartB - - child: SCBdata - parent: imported-chartA-B - - child: exports.SCBexported2 - parent: exports.SCBexported2 - - SCBexported1 - - tags: - - front-end - - subchartb diff --git a/pkg/chartutil/testdata/subpop/charts/subchart2/requirements.yaml b/pkg/chartutil/testdata/subpop/charts/subchart2/requirements.yaml deleted file mode 100644 index 1f0023a08..000000000 --- a/pkg/chartutil/testdata/subpop/charts/subchart2/requirements.yaml +++ /dev/null @@ -1,15 +0,0 @@ -dependencies: - - name: subchartb - repository: http://localhost:10191 - version: 0.1.0 - condition: subchartb.enabled,subchart2.subchartb.enabled - tags: - - back-end - - subchartb - - name: subchartc - repository: http://localhost:10191 - version: 0.1.0 - condition: subchartc.enabled - tags: - - back-end - - subchartc diff --git a/pkg/chartutil/testdata/subpop/requirements.yaml b/pkg/chartutil/testdata/subpop/requirements.yaml deleted file mode 100644 index a8eb0aace..000000000 --- a/pkg/chartutil/testdata/subpop/requirements.yaml +++ /dev/null @@ -1,31 +0,0 @@ -dependencies: - - name: subchart1 - repository: http://localhost:10191 - version: 0.1.0 - condition: subchart1.enabled - tags: - - front-end - - subchart1 - import-values: - - child: SC1data - parent: imported-chart1 - - child: SC1data - parent: overridden-chart1 - - child: imported-chartA - parent: imported-chartA - - child: imported-chartA-B - parent: imported-chartA-B - - child: overridden-chartA-B - parent: overridden-chartA-B - - child: SCBexported1A - parent: . - - SCBexported2 - - SC1exported1 - - - name: subchart2 - repository: http://localhost:10191 - version: 0.1.0 - condition: subchart2.enabled - tags: - - back-end - - subchart2 diff --git a/pkg/downloader/manager.go b/pkg/downloader/manager.go index 5c657fca5..6bfc2c37b 100644 --- a/pkg/downloader/manager.go +++ b/pkg/downloader/manager.go @@ -78,7 +78,7 @@ func (m *Manager) Build() error { return m.Update() } - req := c.Metadata.Requirements + req := c.Metadata.Dependencies if sum, err := resolver.HashReq(req); err != nil || sum != lock.Digest { return errors.New("Chart.lock is out of sync with Chart.yaml") } @@ -114,14 +114,14 @@ func (m *Manager) Update() error { return err } - // If no requirements file is found, we consider this a successful + // If no dependencies are found, we consider this a successful // completion. - req := c.Metadata.Requirements + req := c.Metadata.Dependencies if req == nil { return nil } - // Hash requirements.yaml + // Hash dependencies // FIXME should this hash all of Chart.yaml hash, err := resolver.HashReq(req) if err != nil { @@ -143,7 +143,7 @@ func (m *Manager) Update() error { } // Now we need to find out which version of a chart best satisfies the - // requirements in the Chart.yaml + // dependencies in the Chart.yaml lock, err := m.resolve(req, repoNames, hash) if err != nil { return err @@ -173,9 +173,9 @@ func (m *Manager) loadChartDir() (*chart.Chart, error) { return loader.LoadDir(m.ChartPath) } -// resolve takes a list of requirements and translates them into an exact version to download. +// resolve takes a list of dependencies and translates them into an exact version to download. // -// This returns a lock file, which has all of the requirements normalized to a specific version. +// This returns a lock file, which has all of the dependencies normalized to a specific version. func (m *Manager) resolve(req []*chart.Dependency, repoNames map[string]string, hash string) (*chart.Lock, error) { res := resolver.New(m.ChartPath, m.HelmHome) return res.Resolve(req, repoNames, hash) diff --git a/pkg/helm/client.go b/pkg/helm/client.go index 4c40b0fbf..2a26cc4de 100644 --- a/pkg/helm/client.go +++ b/pkg/helm/client.go @@ -97,11 +97,11 @@ func (c *Client) InstallReleaseFromChart(chart *chart.Chart, ns string, opts ... } var m map[string]interface{} yaml.Unmarshal(req.Values, &m) - err := chartutil.ProcessRequirementsEnabled(req.Chart, m) + err := chartutil.ProcessDependencyEnabled(req.Chart, m) if err != nil { return nil, err } - err = chartutil.ProcessRequirementsImportValues(req.Chart) + err = chartutil.ProcessDependencyImportValues(req.Chart) if err != nil { return nil, err } @@ -171,10 +171,10 @@ func (c *Client) UpdateReleaseFromChart(rlsName string, chart *chart.Chart, opts if err := yaml.Unmarshal(req.Values, &m); err != nil { return nil, err } - if err := chartutil.ProcessRequirementsEnabled(req.Chart, m); err != nil { + if err := chartutil.ProcessDependencyEnabled(req.Chart, m); err != nil { return nil, err } - if err := chartutil.ProcessRequirementsImportValues(req.Chart); err != nil { + if err := chartutil.ProcessDependencyImportValues(req.Chart); err != nil { return nil, err } diff --git a/pkg/resolver/resolver.go b/pkg/resolver/resolver.go index 367529f0c..d658f5f6f 100644 --- a/pkg/resolver/resolver.go +++ b/pkg/resolver/resolver.go @@ -114,7 +114,7 @@ func (r *Resolver) Resolve(reqs []*chart.Dependency, repoNames map[string]string }, nil } -// HashReq generates a hash of the requirements. +// HashReq generates a hash of the dependencies. // // This should be used only to compare against another hash generated by this // function. @@ -128,7 +128,7 @@ func HashReq(req []*chart.Dependency) (string, error) { } // GetLocalPath generates absolute local path when use -// "file://" in repository of requirements +// "file://" in repository of dependencies func GetLocalPath(repo, chartpath string) (string, error) { var depPath string var err error