Skip to content

Commit 449a469

Browse files
authored
Merge pull request #252 from arbourd/values-files
Add `ValuesFiles` to HelmChart spec
2 parents 7ae853a + da31867 commit 449a469

8 files changed

+85
-13
lines changed

api/v2beta1/helmrelease_types.go

+12-2
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,19 @@ type HelmChartTemplateSpec struct {
246246
// +optional
247247
Interval *metav1.Duration `json:"interval,omitempty"`
248248

249-
// Alternative values file to use as the default chart values, expected to be a
250-
// relative path in the SourceRef. Ignored when omitted.
249+
// Alternative list of values files to use as the chart values (values.yaml
250+
// is not included by default), expected to be a relative path in the SourceRef.
251+
// Values files are merged in the order of this list with the last file overriding
252+
// the first. Ignored when omitted.
251253
// +optional
254+
ValuesFiles []string `json:"valuesFiles,omitempty"`
255+
256+
// Alternative values file to use as the default chart values, expected to
257+
// be a relative path in the SourceRef. Deprecated in favor of ValuesFiles,
258+
// for backwards compatibility the file defined here is merged before the
259+
// ValuesFiles items. Ignored when omitted.
260+
// +optional
261+
// +deprecated
252262
ValuesFile string `json:"valuesFile,omitempty"`
253263
}
254264

api/v2beta1/zz_generated.deepcopy.go

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,19 @@ spec:
9494
valuesFile:
9595
description: Alternative values file to use as the default
9696
chart values, expected to be a relative path in the SourceRef.
97+
Deprecated in favor of ValuesFiles, for backwards compatibility
98+
the file defined here is merged before the ValuesFiles items.
9799
Ignored when omitted.
98100
type: string
101+
valuesFiles:
102+
description: Alternative list of values files to use as the
103+
chart values (values.yaml is not included by default), expected
104+
to be a relative path in the SourceRef. Values files are
105+
merged in the order of this list with the last file overriding
106+
the first. Ignored when omitted.
107+
items:
108+
type: string
109+
type: array
99110
version:
100111
default: '*'
101112
description: Version semver expression, ignored for charts

controllers/helmrelease_controller_chart.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"net/http"
2525
"net/url"
2626
"os"
27+
"reflect"
2728
"strings"
2829

2930
"github.com/go-logr/logr"
@@ -173,8 +174,9 @@ func buildHelmChartFromTemplate(hr *v2.HelmRelease) *sourcev1.HelmChart {
173174
Name: template.Spec.SourceRef.Name,
174175
Kind: template.Spec.SourceRef.Kind,
175176
},
176-
Interval: template.GetInterval(hr.Spec.Interval),
177-
ValuesFile: template.Spec.ValuesFile,
177+
Interval: template.GetInterval(hr.Spec.Interval),
178+
ValuesFiles: template.Spec.ValuesFiles,
179+
ValuesFile: template.Spec.ValuesFile,
178180
},
179181
}
180182
}
@@ -197,6 +199,8 @@ func helmChartRequiresUpdate(hr *v2.HelmRelease, chart *sourcev1.HelmChart) bool
197199
return true
198200
case template.GetInterval(hr.Spec.Interval) != chart.Spec.Interval:
199201
return true
202+
case !reflect.DeepEqual(template.Spec.ValuesFiles, chart.Spec.ValuesFiles):
203+
return true
200204
case template.Spec.ValuesFile != chart.Spec.ValuesFile:
201205
return true
202206
default:

controllers/helmrelease_controller_chart_test.go

+7
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,13 @@ func Test_helmChartRequiresUpdate(t *testing.T) {
420420
},
421421
want: true,
422422
},
423+
{
424+
name: "detects values files change",
425+
modify: func(hr *v2.HelmRelease, hc *sourcev1.HelmChart) {
426+
hr.Spec.Chart.Spec.ValuesFiles = []string{"values-prod.yaml"}
427+
},
428+
want: true,
429+
},
423430
{
424431
name: "detects values file change",
425432
modify: func(hr *v2.HelmRelease, hc *sourcev1.HelmChart) {

docs/api/helmrelease.md

+38-4
Original file line numberDiff line numberDiff line change
@@ -509,15 +509,32 @@ Kubernetes meta/v1.Duration
509509
</tr>
510510
<tr>
511511
<td>
512+
<code>valuesFiles</code><br>
513+
<em>
514+
[]string
515+
</em>
516+
</td>
517+
<td>
518+
<em>(Optional)</em>
519+
<p>Alternative list of values files to use as the chart values (values.yaml
520+
is not included by default), expected to be a relative path in the SourceRef.
521+
Values files are merged in the order of this list with the last file overriding
522+
the first. Ignored when omitted.</p>
523+
</td>
524+
</tr>
525+
<tr>
526+
<td>
512527
<code>valuesFile</code><br>
513528
<em>
514529
string
515530
</em>
516531
</td>
517532
<td>
518533
<em>(Optional)</em>
519-
<p>Alternative values file to use as the default chart values, expected to be a
520-
relative path in the SourceRef. Ignored when omitted.</p>
534+
<p>Alternative values file to use as the default chart values, expected to
535+
be a relative path in the SourceRef. Deprecated in favor of ValuesFiles,
536+
for backwards compatibility the file defined here is merged before the
537+
ValuesFiles items. Ignored when omitted.</p>
521538
</td>
522539
</tr>
523540
</table>
@@ -599,15 +616,32 @@ Kubernetes meta/v1.Duration
599616
</tr>
600617
<tr>
601618
<td>
619+
<code>valuesFiles</code><br>
620+
<em>
621+
[]string
622+
</em>
623+
</td>
624+
<td>
625+
<em>(Optional)</em>
626+
<p>Alternative list of values files to use as the chart values (values.yaml
627+
is not included by default), expected to be a relative path in the SourceRef.
628+
Values files are merged in the order of this list with the last file overriding
629+
the first. Ignored when omitted.</p>
630+
</td>
631+
</tr>
632+
<tr>
633+
<td>
602634
<code>valuesFile</code><br>
603635
<em>
604636
string
605637
</em>
606638
</td>
607639
<td>
608640
<em>(Optional)</em>
609-
<p>Alternative values file to use as the default chart values, expected to be a
610-
relative path in the SourceRef. Ignored when omitted.</p>
641+
<p>Alternative values file to use as the default chart values, expected to
642+
be a relative path in the SourceRef. Deprecated in favor of ValuesFiles,
643+
for backwards compatibility the file defined here is merged before the
644+
ValuesFiles items. Ignored when omitted.</p>
611645
</td>
612646
</tr>
613647
</tbody>

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/fluxcd/pkg/apis/kustomize v0.0.1
1010
github.com/fluxcd/pkg/apis/meta v0.8.0
1111
github.com/fluxcd/pkg/runtime v0.10.2
12-
github.com/fluxcd/source-controller/api v0.10.0
12+
github.com/fluxcd/source-controller/api v0.11.1-0.20210419133153-f56c96fff636
1313
github.com/go-logr/logr v0.3.0
1414
github.com/hashicorp/go-retryablehttp v0.6.8
1515
github.com/onsi/ginkgo v1.14.1
@@ -18,7 +18,7 @@ require (
1818
helm.sh/helm/v3 v3.5.3
1919
k8s.io/api v0.20.2
2020
k8s.io/apiextensions-apiserver v0.20.2
21-
k8s.io/apimachinery v0.20.2
21+
k8s.io/apimachinery v0.20.4
2222
k8s.io/cli-runtime v0.20.2
2323
k8s.io/client-go v0.20.2
2424
sigs.k8s.io/controller-runtime v0.8.3

go.sum

+4-3
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ github.com/fluxcd/pkg/apis/meta v0.8.0 h1:wqWpUsxhKHB1ZztcvOz+vnyhdKW9cWmjFp8Vci
239239
github.com/fluxcd/pkg/apis/meta v0.8.0/go.mod h1:yHuY8kyGHYz22I0jQzqMMGCcHViuzC/WPdo9Gisk8Po=
240240
github.com/fluxcd/pkg/runtime v0.10.2 h1:JAI/pOfU3Rgr4MysWJoWenEP6vq03EspBmoekSZMUfo=
241241
github.com/fluxcd/pkg/runtime v0.10.2/go.mod h1:JD0eZIn5xkTeHHQUWXSqJPIh/ecO0d0qrUKbSVHnpnw=
242-
github.com/fluxcd/source-controller/api v0.10.0 h1:Mu4cAXtZ7yq/rIrab81q1jbbhWwUxxAZ2R5bZ1m8AxE=
243-
github.com/fluxcd/source-controller/api v0.10.0/go.mod h1:Vuw+7UqEUUOdkKBfTUPHwaQgbn6LL2FwqPDx2UAk7NE=
242+
github.com/fluxcd/source-controller/api v0.11.1-0.20210419133153-f56c96fff636 h1:MKewkVohNKjqpQW/J4dU9oyKGv8TCN5jcfuS09iPkjY=
243+
github.com/fluxcd/source-controller/api v0.11.1-0.20210419133153-f56c96fff636/go.mod h1:/LRxF55Mf+j5mXVfHLbonb/2YYHVSaouLa5zt5aj7D4=
244244
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
245245
github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4=
246246
github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20=
@@ -1275,8 +1275,9 @@ k8s.io/apiextensions-apiserver v0.20.2 h1:rfrMWQ87lhd8EzQWRnbQ4gXrniL/yTRBgYH1x1
12751275
k8s.io/apiextensions-apiserver v0.20.2/go.mod h1:F6TXp389Xntt+LUq3vw6HFOLttPa0V8821ogLGwb6Zs=
12761276
k8s.io/apimachinery v0.17.0/go.mod h1:b9qmWdKlLuU9EBh+06BtLcSf/Mu89rWL33naRxs1uZg=
12771277
k8s.io/apimachinery v0.20.1/go.mod h1:WlLqWAHZGg07AeltaI0MV5uk1Omp8xaN0JGLY6gkRpU=
1278-
k8s.io/apimachinery v0.20.2 h1:hFx6Sbt1oG0n6DZ+g4bFt5f6BoMkOjKWsQFu077M3Vg=
12791278
k8s.io/apimachinery v0.20.2/go.mod h1:WlLqWAHZGg07AeltaI0MV5uk1Omp8xaN0JGLY6gkRpU=
1279+
k8s.io/apimachinery v0.20.4 h1:vhxQ0PPUUU2Ns1b9r4/UFp13UPs8cw2iOoTjnY9faa0=
1280+
k8s.io/apimachinery v0.20.4/go.mod h1:WlLqWAHZGg07AeltaI0MV5uk1Omp8xaN0JGLY6gkRpU=
12801281
k8s.io/apiserver v0.20.1/go.mod h1:ro5QHeQkgMS7ZGpvf4tSMx6bBOgPfE+f52KwvXfScaU=
12811282
k8s.io/apiserver v0.20.2 h1:lGno2t3gcZnLtzsKH4oG0xA9/4GTiBzMO1DGp+K+Bak=
12821283
k8s.io/apiserver v0.20.2/go.mod h1:2nKd93WyMhZx4Hp3RfgH2K5PhwyTrprrkWYnI7id7jA=

0 commit comments

Comments
 (0)