Skip to content

Commit a1e9302

Browse files
committed
internal/helm: "value files" -> "values files"
Previous usage while consistent, was incorrect, and inconsitent with the field in the API spec. Signed-off-by: Hidde Beydals <hello@hidde.co>
1 parent 37ac5a9 commit a1e9302

File tree

10 files changed

+66
-66
lines changed

10 files changed

+66
-66
lines changed

controllers/helmchart_controller.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ func (r *HelmChartReconciler) fromHelmRepository(ctx context.Context, repo sourc
335335
cBuilder := chart.NewRemoteBuilder(chartRepo)
336336
ref := chart.RemoteReference{Name: c.Spec.Chart, Version: c.Spec.Version}
337337
opts := chart.BuildOptions{
338-
ValueFiles: c.GetValuesFiles(),
338+
ValuesFiles: c.GetValuesFiles(),
339339
CachedChart: cachedChart,
340340
Force: force,
341341
}
@@ -431,8 +431,8 @@ func (r *HelmChartReconciler) fromTarballArtifact(ctx context.Context, source so
431431

432432
// Configure builder options, including any previously cached chart
433433
buildsOpts := chart.BuildOptions{
434-
ValueFiles: c.GetValuesFiles(),
435-
Force: force,
434+
ValuesFiles: c.GetValuesFiles(),
435+
Force: force,
436436
}
437437
if artifact := c.Status.Artifact; artifact != nil {
438438
buildsOpts.CachedChart = artifact.Path
@@ -815,7 +815,7 @@ func reasonForBuildError(err error) string {
815815
return sourcev1.ChartPullFailedReason
816816
}
817817
switch buildErr.Reason {
818-
case chart.ErrChartMetadataPatch, chart.ErrValueFilesMerge, chart.ErrDependencyBuild, chart.ErrChartPackage:
818+
case chart.ErrChartMetadataPatch, chart.ErrValuesFilesMerge, chart.ErrDependencyBuild, chart.ErrChartPackage:
819819
return sourcev1.ChartPackageFailedReason
820820
default:
821821
return sourcev1.ChartPullFailedReason

internal/helm/chart/builder.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ func (r RemoteReference) Validate() error {
8181

8282
// Builder is capable of building a (specific) chart Reference.
8383
type Builder interface {
84-
// Build builds and packages a Helm chart with the given Reference
85-
// and BuildOptions and writes it to p. It returns the Build result,
86-
// or an error. It may return an error for unsupported Reference
87-
// implementations.
84+
// Build pulls and (optionally) packages a Helm chart with the given
85+
// Reference and BuildOptions, and writes it to p.
86+
// It returns the Build result, or an error.
87+
// It may return an error for unsupported Reference implementations.
8888
Build(ctx context.Context, ref Reference, p string, opts BuildOptions) (*Build, error)
8989
}
9090

@@ -94,25 +94,25 @@ type BuildOptions struct {
9494
// the spec, and is included during packaging.
9595
// Ref: https://semver.org/#spec-item-10
9696
VersionMetadata string
97-
// ValueFiles can be set to a list of relative paths, used to compose
97+
// ValuesFiles can be set to a list of relative paths, used to compose
9898
// and overwrite an alternative default "values.yaml" for the chart.
99-
ValueFiles []string
99+
ValuesFiles []string
100100
// CachedChart can be set to the absolute path of a chart stored on
101101
// the local filesystem, and is used for simple validation by metadata
102102
// comparisons.
103103
CachedChart string
104104
// Force can be set to force the build of the chart, for example
105-
// because the list of ValueFiles has changed.
105+
// because the list of ValuesFiles has changed.
106106
Force bool
107107
}
108108

109-
// GetValueFiles returns BuildOptions.ValueFiles, except if it equals
109+
// GetValuesFiles returns BuildOptions.ValuesFiles, except if it equals
110110
// "values.yaml", which returns nil.
111-
func (o BuildOptions) GetValueFiles() []string {
112-
if len(o.ValueFiles) == 1 && filepath.Clean(o.ValueFiles[0]) == filepath.Clean(chartutil.ValuesfileName) {
111+
func (o BuildOptions) GetValuesFiles() []string {
112+
if len(o.ValuesFiles) == 1 && filepath.Clean(o.ValuesFiles[0]) == filepath.Clean(chartutil.ValuesfileName) {
113113
return nil
114114
}
115-
return o.ValueFiles
115+
return o.ValuesFiles
116116
}
117117

118118
// Build contains the Builder.Build result, including specific
@@ -124,14 +124,14 @@ type Build struct {
124124
Name string
125125
// Version of the packaged chart.
126126
Version string
127-
// ValueFiles is the list of files used to compose the chart's
127+
// ValuesFiles is the list of files used to compose the chart's
128128
// default "values.yaml".
129-
ValueFiles []string
129+
ValuesFiles []string
130130
// ResolvedDependencies is the number of local and remote dependencies
131131
// collected by the DependencyManager before building the chart.
132132
ResolvedDependencies int
133133
// Packaged indicates if the Builder has packaged the chart.
134-
// This can for example be false if ValueFiles is empty and the chart
134+
// This can for example be false if ValuesFiles is empty and the chart
135135
// source was already packaged.
136136
Packaged bool
137137
}
@@ -150,8 +150,8 @@ func (b *Build) Summary() string {
150150
}
151151
s.WriteString(fmt.Sprintf("%s '%s' chart with version '%s'", action, b.Name, b.Version))
152152

153-
if b.Packaged && len(b.ValueFiles) > 0 {
154-
s.WriteString(fmt.Sprintf(", with merged value files %v", b.ValueFiles))
153+
if b.Packaged && len(b.ValuesFiles) > 0 {
154+
s.WriteString(fmt.Sprintf(", with merged values files %v", b.ValuesFiles))
155155
}
156156

157157
if b.Packaged && b.ResolvedDependencies > 0 {

internal/helm/chart/builder_local.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ func (b *localChartBuilder) Build(ctx context.Context, ref Reference, p string,
8585
if opts.CachedChart != "" && !opts.Force {
8686
if curMeta, err = LoadChartMetadataFromArchive(opts.CachedChart); err == nil && result.Version == curMeta.Version {
8787
result.Path = opts.CachedChart
88-
result.ValueFiles = opts.ValueFiles
88+
result.ValuesFiles = opts.ValuesFiles
8989
return result, nil
9090
}
9191
}
9292

93-
// If the chart at the path is already packaged and no custom value files
93+
// If the chart at the path is already packaged and no custom values files
9494
// options are set, we can copy the chart without making modifications
9595
isChartDir := pathIsDir(localRef.Path)
96-
if !isChartDir && len(opts.GetValueFiles()) == 0 {
96+
if !isChartDir && len(opts.GetValuesFiles()) == 0 {
9797
if err = copyFileToPath(localRef.Path, p); err != nil {
9898
return nil, &BuildError{Reason: ErrChartPull, Err: err}
9999
}
@@ -103,9 +103,9 @@ func (b *localChartBuilder) Build(ctx context.Context, ref Reference, p string,
103103

104104
// Merge chart values, if instructed
105105
var mergedValues map[string]interface{}
106-
if len(opts.GetValueFiles()) > 0 {
107-
if mergedValues, err = mergeFileValues(localRef.WorkDir, opts.ValueFiles); err != nil {
108-
return nil, &BuildError{Reason: ErrValueFilesMerge, Err: err}
106+
if len(opts.GetValuesFiles()) > 0 {
107+
if mergedValues, err = mergeFileValues(localRef.WorkDir, opts.ValuesFiles); err != nil {
108+
return nil, &BuildError{Reason: ErrValuesFilesMerge, Err: err}
109109
}
110110
}
111111

@@ -122,9 +122,9 @@ func (b *localChartBuilder) Build(ctx context.Context, ref Reference, p string,
122122
// Overwrite default values with merged values, if any
123123
if ok, err = OverwriteChartDefaultValues(chart, mergedValues); ok || err != nil {
124124
if err != nil {
125-
return nil, &BuildError{Reason: ErrValueFilesMerge, Err: err}
125+
return nil, &BuildError{Reason: ErrValuesFilesMerge, Err: err}
126126
}
127-
result.ValueFiles = opts.GetValueFiles()
127+
result.ValuesFiles = opts.GetValuesFiles()
128128
}
129129

130130
// Ensure dependencies are fetched if building from a directory

internal/helm/chart/builder_local_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func TestLocalBuilder_Build(t *testing.T) {
6666
name string
6767
reference Reference
6868
buildOpts BuildOptions
69-
valueFiles []helmchart.File
69+
valuesFiles []helmchart.File
7070
repositories map[string]*repository.ChartRepository
7171
dependentChartPaths []string
7272
wantValues chartutil.Values
@@ -118,12 +118,12 @@ func TestLocalBuilder_Build(t *testing.T) {
118118
wantPackaged: true,
119119
},
120120
{
121-
name: "with value files",
121+
name: "with values files",
122122
reference: LocalReference{Path: "./../testdata/charts/helmchart"},
123123
buildOpts: BuildOptions{
124-
ValueFiles: []string{"custom-values1.yaml", "custom-values2.yaml"},
124+
ValuesFiles: []string{"custom-values1.yaml", "custom-values2.yaml"},
125125
},
126-
valueFiles: []helmchart.File{
126+
valuesFiles: []helmchart.File{
127127
{
128128
Name: "custom-values1.yaml",
129129
Data: []byte(`replicaCount: 11
@@ -189,7 +189,7 @@ fullnameOverride: "full-foo-name-override"`),
189189
}
190190

191191
// Write value file in the base dir.
192-
for _, f := range tt.valueFiles {
192+
for _, f := range tt.valuesFiles {
193193
vPath := filepath.Join(workDir, f.Name)
194194
g.Expect(os.WriteFile(vPath, f.Data, 0644)).ToNot(HaveOccurred())
195195
}

internal/helm/chart/builder_remote.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func (b *remoteChartBuilder) Build(_ context.Context, ref Reference, p string, o
9393
if opts.CachedChart != "" && !opts.Force {
9494
if curMeta, err := LoadChartMetadataFromArchive(opts.CachedChart); err == nil && result.Version == curMeta.Version {
9595
result.Path = opts.CachedChart
96-
result.ValueFiles = opts.GetValueFiles()
96+
result.ValuesFiles = opts.GetValuesFiles()
9797
return result, nil
9898
}
9999
}
@@ -105,9 +105,9 @@ func (b *remoteChartBuilder) Build(_ context.Context, ref Reference, p string, o
105105
return nil, &BuildError{Reason: ErrChartPull, Err: err}
106106
}
107107

108-
// Use literal chart copy from remote if no custom value files options are
108+
// Use literal chart copy from remote if no custom values files options are
109109
// set or build option version metadata isn't set.
110-
if len(opts.GetValueFiles()) == 0 && opts.VersionMetadata == "" {
110+
if len(opts.GetValuesFiles()) == 0 && opts.VersionMetadata == "" {
111111
if err = validatePackageAndWriteToPath(res, p); err != nil {
112112
return nil, &BuildError{Reason: ErrChartPull, Err: err}
113113
}
@@ -123,17 +123,17 @@ func (b *remoteChartBuilder) Build(_ context.Context, ref Reference, p string, o
123123
}
124124
chart.Metadata.Version = result.Version
125125

126-
mergedValues, err := mergeChartValues(chart, opts.ValueFiles)
126+
mergedValues, err := mergeChartValues(chart, opts.ValuesFiles)
127127
if err != nil {
128128
err = fmt.Errorf("failed to merge chart values: %w", err)
129-
return nil, &BuildError{Reason: ErrValueFilesMerge, Err: err}
129+
return nil, &BuildError{Reason: ErrValuesFilesMerge, Err: err}
130130
}
131131
// Overwrite default values with merged values, if any
132132
if ok, err = OverwriteChartDefaultValues(chart, mergedValues); ok || err != nil {
133133
if err != nil {
134-
return nil, &BuildError{Reason: ErrValueFilesMerge, Err: err}
134+
return nil, &BuildError{Reason: ErrValuesFilesMerge, Err: err}
135135
}
136-
result.ValueFiles = opts.GetValueFiles()
136+
result.ValuesFiles = opts.GetValuesFiles()
137137
}
138138

139139
// Package the chart with the custom values

internal/helm/chart/builder_remote_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ entries:
144144
name: "merge values",
145145
reference: RemoteReference{Name: "grafana"},
146146
buildOpts: BuildOptions{
147-
ValueFiles: []string{"a.yaml", "b.yaml", "c.yaml"},
147+
ValuesFiles: []string{"a.yaml", "b.yaml", "c.yaml"},
148148
},
149149
repository: mockRepo(),
150150
wantVersion: "6.17.4",

internal/helm/chart/builder_test.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -104,29 +104,29 @@ func TestRemoteReference_Validate(t *testing.T) {
104104
}
105105
}
106106

107-
func TestBuildOptions_GetValueFiles(t *testing.T) {
107+
func TestBuildOptions_GetValuesFiles(t *testing.T) {
108108
tests := []struct {
109-
name string
110-
valueFiles []string
111-
want []string
109+
name string
110+
valuesFiles []string
111+
want []string
112112
}{
113113
{
114-
name: "Default values.yaml",
115-
valueFiles: []string{chartutil.ValuesfileName},
116-
want: nil,
114+
name: "Default values.yaml",
115+
valuesFiles: []string{chartutil.ValuesfileName},
116+
want: nil,
117117
},
118118
{
119-
name: "Value files",
120-
valueFiles: []string{chartutil.ValuesfileName, "foo.yaml"},
121-
want: []string{chartutil.ValuesfileName, "foo.yaml"},
119+
name: "Values files",
120+
valuesFiles: []string{chartutil.ValuesfileName, "foo.yaml"},
121+
want: []string{chartutil.ValuesfileName, "foo.yaml"},
122122
},
123123
}
124124
for _, tt := range tests {
125125
t.Run(tt.name, func(t *testing.T) {
126126
g := NewWithT(t)
127127

128-
o := BuildOptions{ValueFiles: tt.valueFiles}
129-
g.Expect(o.GetValueFiles()).To(Equal(tt.want))
128+
o := BuildOptions{ValuesFiles: tt.valuesFiles}
129+
g.Expect(o.GetValuesFiles()).To(Equal(tt.want))
130130
})
131131
}
132132
}
@@ -146,14 +146,14 @@ func TestChartBuildResult_Summary(t *testing.T) {
146146
want: "Pulled 'chart' chart with version '1.2.3-rc.1+bd6bf40'.",
147147
},
148148
{
149-
name: "With value files",
149+
name: "With values files",
150150
build: &Build{
151-
Name: "chart",
152-
Version: "arbitrary-version",
153-
Packaged: true,
154-
ValueFiles: []string{"a.yaml", "b.yaml"},
151+
Name: "chart",
152+
Version: "arbitrary-version",
153+
Packaged: true,
154+
ValuesFiles: []string{"a.yaml", "b.yaml"},
155155
},
156-
want: "Packaged 'chart' chart with version 'arbitrary-version', with merged value files [a.yaml b.yaml].",
156+
want: "Packaged 'chart' chart with version 'arbitrary-version', with merged values files [a.yaml b.yaml].",
157157
},
158158
{
159159
name: "With dependencies",

internal/helm/chart/dependency_manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ func (dm *DependencyManager) secureLocalChartPath(ref LocalReference, dep *helmc
296296

297297
// collectMissing returns a map with reqs that are missing from current,
298298
// indexed by their alias or name. All dependencies of a chart are present
299-
// if len of returned value == 0.
299+
// if len of returned map == 0.
300300
func collectMissing(current []*helmchart.Chart, reqs []*helmchart.Dependency) map[string]*helmchart.Dependency {
301301
// If the number of dependencies equals the number of requested
302302
// dependencies, there are no missing dependencies

internal/helm/chart/errors.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func (e *BuildError) Unwrap() error {
5959
var (
6060
ErrChartPull = BuildErrorReason("chart pull error")
6161
ErrChartMetadataPatch = BuildErrorReason("chart metadata patch error")
62-
ErrValueFilesMerge = BuildErrorReason("value files merge error")
62+
ErrValuesFilesMerge = BuildErrorReason("values files merge error")
6363
ErrDependencyBuild = BuildErrorReason("dependency build error")
6464
ErrChartPackage = BuildErrorReason("chart package error")
6565
)

internal/helm/chart/errors_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ func TestBuildErrorReason_Error(t *testing.T) {
3232

3333
func TestBuildError_Error(t *testing.T) {
3434
tests := []struct {
35-
name string
36-
err *BuildError
37-
want string
35+
name string
36+
err *BuildError
37+
want string
3838
}{
3939
{
4040
name: "with reason",
4141
err: &BuildError{
4242
Reason: BuildErrorReason("reason"),
43-
Err: errors.New("error"),
43+
Err: errors.New("error"),
4444
},
4545
want: "reason: error",
4646
},
@@ -67,7 +67,7 @@ func TestBuildError_Is(t *testing.T) {
6767
wrappedErr := errors.New("wrapped")
6868
err := &BuildError{
6969
Reason: ErrChartPackage,
70-
Err: wrappedErr,
70+
Err: wrappedErr,
7171
}
7272

7373
g.Expect(err.Is(ErrChartPackage)).To(BeTrue())

0 commit comments

Comments
 (0)