Skip to content

Commit cf750b5

Browse files
authored
Merge pull request #1428 from fluxcd/helm-ga
Promote Helm APIs to `source.toolkit.fluxcd.io/v1` (GA)
2 parents 5fcae5c + 31c4df4 commit cf750b5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+5148
-932
lines changed

PROJECT

+6
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,15 @@ resources:
77
- group: source
88
kind: GitRepository
99
version: v1beta2
10+
- group: source
11+
kind: HelmRepository
12+
version: v1
1013
- group: source
1114
kind: HelmRepository
1215
version: v1beta2
16+
- group: source
17+
kind: HelmChart
18+
version: v1
1319
- group: source
1420
kind: HelmChart
1521
version: v1beta2

README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ and is a core component of the [GitOps toolkit](https://fluxcd.io/flux/component
1616

1717
## APIs
1818

19-
| Kind | API Version |
20-
|---------------------------------------------------------|------------------------------------|
21-
| [GitRepository](docs/spec/v1/gitrepositories.md) | `source.toolkit.fluxcd.io/v1` |
22-
| [OCIRepository](docs/spec/v1beta2/ocirepositories.md) | `source.toolkit.fluxcd.io/v1beta2` |
23-
| [HelmRepository](docs/spec/v1beta2/helmrepositories.md) | `source.toolkit.fluxcd.io/v1beta2` |
24-
| [HelmChart](docs/spec/v1beta2/helmcharts.md) | `source.toolkit.fluxcd.io/v1beta2` |
25-
| [Bucket](docs/spec/v1beta2/buckets.md) | `source.toolkit.fluxcd.io/v1beta2` |
19+
| Kind | API Version |
20+
|-------------------------------------------------------|------------------------------------|
21+
| [GitRepository](docs/spec/v1/gitrepositories.md) | `source.toolkit.fluxcd.io/v1` |
22+
| [OCIRepository](docs/spec/v1beta2/ocirepositories.md) | `source.toolkit.fluxcd.io/v1beta2` |
23+
| [HelmRepository](docs/spec/v1/helmrepositories.md) | `source.toolkit.fluxcd.io/v1` |
24+
| [HelmChart](docs/spec/v1/helmcharts.md) | `source.toolkit.fluxcd.io/v1` |
25+
| [Bucket](docs/spec/v1beta2/buckets.md) | `source.toolkit.fluxcd.io/v1beta2` |
2626

2727
## Features
2828

api/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/fluxcd/pkg/apis/acl v0.3.0
77
github.com/fluxcd/pkg/apis/meta v1.5.0
88
k8s.io/apimachinery v0.30.0
9-
sigs.k8s.io/controller-runtime v0.18.0
9+
sigs.k8s.io/controller-runtime v0.18.1
1010
)
1111

1212
// Fix CVE-2022-28948

api/go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw=
103103
k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
104104
k8s.io/utils v0.0.0-20231127182322-b307cd553661 h1:FepOBzJ0GXm8t0su67ln2wAZjbQ6RxQGZDnzuLcrUTI=
105105
k8s.io/utils v0.0.0-20231127182322-b307cd553661/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
106-
sigs.k8s.io/controller-runtime v0.18.0 h1:Z7jKuX784TQSUL1TIyeuF7j8KXZ4RtSX0YgtjKcSTME=
107-
sigs.k8s.io/controller-runtime v0.18.0/go.mod h1:tuAt1+wbVsXIT8lPtk5RURxqAnq7xkpv2Mhttslg7Hw=
106+
sigs.k8s.io/controller-runtime v0.18.1 h1:RpWbigmuiylbxOCLy0tGnq1cU1qWPwNIQzoJk+QeJx4=
107+
sigs.k8s.io/controller-runtime v0.18.1/go.mod h1:tuAt1+wbVsXIT8lPtk5RURxqAnq7xkpv2Mhttslg7Hw=
108108
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
109109
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
110110
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4=

api/v1/helmchart_types.go

+227
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
/*
2+
Copyright 2024 The Flux authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1
18+
19+
import (
20+
"time"
21+
22+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23+
24+
"github.com/fluxcd/pkg/apis/meta"
25+
)
26+
27+
// HelmChartKind is the string representation of a HelmChart.
28+
const HelmChartKind = "HelmChart"
29+
30+
// HelmChartSpec specifies the desired state of a Helm chart.
31+
type HelmChartSpec struct {
32+
// Chart is the name or path the Helm chart is available at in the
33+
// SourceRef.
34+
// +required
35+
Chart string `json:"chart"`
36+
37+
// Version is the chart version semver expression, ignored for charts from
38+
// GitRepository and Bucket sources. Defaults to latest when omitted.
39+
// +kubebuilder:default:=*
40+
// +optional
41+
Version string `json:"version,omitempty"`
42+
43+
// SourceRef is the reference to the Source the chart is available at.
44+
// +required
45+
SourceRef LocalHelmChartSourceReference `json:"sourceRef"`
46+
47+
// Interval at which the HelmChart SourceRef is checked for updates.
48+
// This interval is approximate and may be subject to jitter to ensure
49+
// efficient use of resources.
50+
// +kubebuilder:validation:Type=string
51+
// +kubebuilder:validation:Pattern="^([0-9]+(\\.[0-9]+)?(ms|s|m|h))+$"
52+
// +required
53+
Interval metav1.Duration `json:"interval"`
54+
55+
// ReconcileStrategy determines what enables the creation of a new artifact.
56+
// Valid values are ('ChartVersion', 'Revision').
57+
// See the documentation of the values for an explanation on their behavior.
58+
// Defaults to ChartVersion when omitted.
59+
// +kubebuilder:validation:Enum=ChartVersion;Revision
60+
// +kubebuilder:default:=ChartVersion
61+
// +optional
62+
ReconcileStrategy string `json:"reconcileStrategy,omitempty"`
63+
64+
// ValuesFiles is an alternative list of values files to use as the chart
65+
// values (values.yaml is not included by default), expected to be a
66+
// relative path in the SourceRef.
67+
// Values files are merged in the order of this list with the last file
68+
// overriding the first. Ignored when omitted.
69+
// +optional
70+
ValuesFiles []string `json:"valuesFiles,omitempty"`
71+
72+
// IgnoreMissingValuesFiles controls whether to silently ignore missing values
73+
// files rather than failing.
74+
// +optional
75+
IgnoreMissingValuesFiles bool `json:"ignoreMissingValuesFiles,omitempty"`
76+
77+
// Suspend tells the controller to suspend the reconciliation of this
78+
// source.
79+
// +optional
80+
Suspend bool `json:"suspend,omitempty"`
81+
82+
// Verify contains the secret name containing the trusted public keys
83+
// used to verify the signature and specifies which provider to use to check
84+
// whether OCI image is authentic.
85+
// This field is only supported when using HelmRepository source with spec.type 'oci'.
86+
// Chart dependencies, which are not bundled in the umbrella chart artifact, are not verified.
87+
// +optional
88+
Verify *OCIRepositoryVerification `json:"verify,omitempty"`
89+
}
90+
91+
const (
92+
// ReconcileStrategyChartVersion reconciles when the version of the Helm chart is different.
93+
ReconcileStrategyChartVersion string = "ChartVersion"
94+
95+
// ReconcileStrategyRevision reconciles when the Revision of the source is different.
96+
ReconcileStrategyRevision string = "Revision"
97+
)
98+
99+
// LocalHelmChartSourceReference contains enough information to let you locate
100+
// the typed referenced object at namespace level.
101+
type LocalHelmChartSourceReference struct {
102+
// APIVersion of the referent.
103+
// +optional
104+
APIVersion string `json:"apiVersion,omitempty"`
105+
106+
// Kind of the referent, valid values are ('HelmRepository', 'GitRepository',
107+
// 'Bucket').
108+
// +kubebuilder:validation:Enum=HelmRepository;GitRepository;Bucket
109+
// +required
110+
Kind string `json:"kind"`
111+
112+
// Name of the referent.
113+
// +required
114+
Name string `json:"name"`
115+
}
116+
117+
// HelmChartStatus records the observed state of the HelmChart.
118+
type HelmChartStatus struct {
119+
// ObservedGeneration is the last observed generation of the HelmChart
120+
// object.
121+
// +optional
122+
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
123+
124+
// ObservedSourceArtifactRevision is the last observed Artifact.Revision
125+
// of the HelmChartSpec.SourceRef.
126+
// +optional
127+
ObservedSourceArtifactRevision string `json:"observedSourceArtifactRevision,omitempty"`
128+
129+
// ObservedChartName is the last observed chart name as specified by the
130+
// resolved chart reference.
131+
// +optional
132+
ObservedChartName string `json:"observedChartName,omitempty"`
133+
134+
// ObservedValuesFiles are the observed value files of the last successful
135+
// reconciliation.
136+
// It matches the chart in the last successfully reconciled artifact.
137+
// +optional
138+
ObservedValuesFiles []string `json:"observedValuesFiles,omitempty"`
139+
140+
// Conditions holds the conditions for the HelmChart.
141+
// +optional
142+
Conditions []metav1.Condition `json:"conditions,omitempty"`
143+
144+
// URL is the dynamic fetch link for the latest Artifact.
145+
// It is provided on a "best effort" basis, and using the precise
146+
// BucketStatus.Artifact data is recommended.
147+
// +optional
148+
URL string `json:"url,omitempty"`
149+
150+
// Artifact represents the output of the last successful reconciliation.
151+
// +optional
152+
Artifact *Artifact `json:"artifact,omitempty"`
153+
154+
meta.ReconcileRequestStatus `json:",inline"`
155+
}
156+
157+
const (
158+
// ChartPullSucceededReason signals that the pull of the Helm chart
159+
// succeeded.
160+
ChartPullSucceededReason string = "ChartPullSucceeded"
161+
162+
// ChartPackageSucceededReason signals that the package of the Helm
163+
// chart succeeded.
164+
ChartPackageSucceededReason string = "ChartPackageSucceeded"
165+
)
166+
167+
// GetConditions returns the status conditions of the object.
168+
func (in HelmChart) GetConditions() []metav1.Condition {
169+
return in.Status.Conditions
170+
}
171+
172+
// SetConditions sets the status conditions on the object.
173+
func (in *HelmChart) SetConditions(conditions []metav1.Condition) {
174+
in.Status.Conditions = conditions
175+
}
176+
177+
// GetRequeueAfter returns the duration after which the source must be
178+
// reconciled again.
179+
func (in HelmChart) GetRequeueAfter() time.Duration {
180+
return in.Spec.Interval.Duration
181+
}
182+
183+
// GetArtifact returns the latest artifact from the source if present in the
184+
// status sub-resource.
185+
func (in *HelmChart) GetArtifact() *Artifact {
186+
return in.Status.Artifact
187+
}
188+
189+
// GetValuesFiles returns a merged list of HelmChartSpec.ValuesFiles.
190+
func (in *HelmChart) GetValuesFiles() []string {
191+
return in.Spec.ValuesFiles
192+
}
193+
194+
// +genclient
195+
// +kubebuilder:storageversion
196+
// +kubebuilder:object:root=true
197+
// +kubebuilder:resource:shortName=hc
198+
// +kubebuilder:subresource:status
199+
// +kubebuilder:printcolumn:name="Chart",type=string,JSONPath=`.spec.chart`
200+
// +kubebuilder:printcolumn:name="Version",type=string,JSONPath=`.spec.version`
201+
// +kubebuilder:printcolumn:name="Source Kind",type=string,JSONPath=`.spec.sourceRef.kind`
202+
// +kubebuilder:printcolumn:name="Source Name",type=string,JSONPath=`.spec.sourceRef.name`
203+
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description=""
204+
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status",description=""
205+
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].message",description=""
206+
207+
// HelmChart is the Schema for the helmcharts API.
208+
type HelmChart struct {
209+
metav1.TypeMeta `json:",inline"`
210+
metav1.ObjectMeta `json:"metadata,omitempty"`
211+
212+
Spec HelmChartSpec `json:"spec,omitempty"`
213+
// +kubebuilder:default={"observedGeneration":-1}
214+
Status HelmChartStatus `json:"status,omitempty"`
215+
}
216+
217+
// HelmChartList contains a list of HelmChart objects.
218+
// +kubebuilder:object:root=true
219+
type HelmChartList struct {
220+
metav1.TypeMeta `json:",inline"`
221+
metav1.ListMeta `json:"metadata,omitempty"`
222+
Items []HelmChart `json:"items"`
223+
}
224+
225+
func init() {
226+
SchemeBuilder.Register(&HelmChart{}, &HelmChartList{})
227+
}

0 commit comments

Comments
 (0)