Skip to content

Commit 7f92d98

Browse files
committed
use new standardized meta package and source-controller v1beta2 API
Signed-off-by: Sunny <darkowlzz@protonmail.com>
1 parent f8855da commit 7f92d98

22 files changed

+209
-202
lines changed

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ api-docs: gen-crd-api-reference-docs
7272

7373
# Run go mod tidy
7474
tidy:
75-
cd api; rm -f go.sum; go mod tidy
76-
rm -f go.sum; go mod tidy
75+
cd api; rm -f go.sum; go mod tidy -compat=1.17
76+
rm -f go.sum; go mod tidy -compat=1.17
7777

7878
# Run go fmt against code
7979
fmt:

api/go.mod

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ go 1.17
44

55
require (
66
github.com/fluxcd/pkg/apis/kustomize v0.3.1
7-
github.com/fluxcd/pkg/apis/meta v0.10.2
8-
github.com/fluxcd/pkg/runtime v0.12.5
7+
github.com/fluxcd/pkg/apis/meta v0.12.0
98
k8s.io/apiextensions-apiserver v0.23.1
10-
k8s.io/apimachinery v0.23.1
9+
k8s.io/apimachinery v0.23.2
1110
sigs.k8s.io/controller-runtime v0.11.0
1211
)
1312

@@ -20,11 +19,13 @@ require (
2019
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
2120
github.com/modern-go/reflect2 v1.0.2 // indirect
2221
golang.org/x/net v0.0.0-20211215060638-4ddde0e984e9 // indirect
22+
golang.org/x/sys v0.0.0-20211110154304-99a53858aa08 // indirect
2323
golang.org/x/text v0.3.7 // indirect
24+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
2425
gopkg.in/inf.v0 v0.9.1 // indirect
2526
gopkg.in/yaml.v2 v2.4.0 // indirect
2627
k8s.io/klog/v2 v2.30.0 // indirect
2728
k8s.io/utils v0.0.0-20211208161948-7d6a63dca704 // indirect
2829
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 // indirect
29-
sigs.k8s.io/structured-merge-diff/v4 v4.2.0 // indirect
30+
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
3031
)

api/go.sum

+12-39
Large diffs are not rendered by default.

api/v2beta1/condition_types.go

+12
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,16 @@ const (
8383
// GetLastReleaseFailedReason represents the fact that observing the last
8484
// release failed.
8585
GetLastReleaseFailedReason string = "GetLastReleaseFailed"
86+
87+
// DependencyNotReadyReason represents the fact that
88+
// one of the dependencies is not ready.
89+
DependencyNotReadyReason string = "DependencyNotReady"
90+
91+
// ReconciliationSucceededReason represents the fact that
92+
// the reconciliation succeeded.
93+
ReconciliationSucceededReason string = "ReconciliationSucceeded"
94+
95+
// ReconciliationFailedReason represents the fact that
96+
// the reconciliation failed.
97+
ReconciliationFailedReason string = "ReconciliationFailed"
8698
)

api/v2beta1/helmrelease_types.go

+38-26
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ import (
2222
"time"
2323

2424
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
25+
apimeta "k8s.io/apimachinery/pkg/api/meta"
2526
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2627
"k8s.io/apimachinery/pkg/types"
2728

2829
"github.com/fluxcd/pkg/apis/kustomize"
2930
"github.com/fluxcd/pkg/apis/meta"
30-
"github.com/fluxcd/pkg/runtime/dependency"
3131
)
3232

3333
const HelmReleaseKind = "HelmRelease"
@@ -59,7 +59,7 @@ type PostRenderer struct {
5959

6060
// HelmReleaseSpec defines the desired state of a Helm release.
6161
type HelmReleaseSpec struct {
62-
// Chart defines the template of the v1beta1.HelmChart that should be created
62+
// Chart defines the template of the v1beta2.HelmChart that should be created
6363
// for this HelmRelease.
6464
// +required
6565
Chart HelmChartTemplate `json:"chart"`
@@ -102,11 +102,11 @@ type HelmReleaseSpec struct {
102102
// +optional
103103
StorageNamespace string `json:"storageNamespace,omitempty"`
104104

105-
// DependsOn may contain a dependency.CrossNamespaceDependencyReference slice with
105+
// DependsOn may contain a meta.NamespacedObjectReference slice with
106106
// references to HelmRelease resources that must be ready before this HelmRelease
107107
// can be reconciled.
108108
// +optional
109-
DependsOn []dependency.CrossNamespaceDependencyReference `json:"dependsOn,omitempty"`
109+
DependsOn []meta.NamespacedObjectReference `json:"dependsOn,omitempty"`
110110

111111
// Timeout is the time to wait for any individual Kubernetes operation (like Jobs
112112
// for hooks) during the performance of a Helm action. Defaults to '5m0s'.
@@ -216,32 +216,32 @@ type KubeConfig struct {
216216
}
217217

218218
// HelmChartTemplate defines the template from which the controller will
219-
// generate a v1beta1.HelmChart object in the same namespace as the referenced
220-
// v1beta1.Source.
219+
// generate a v1beta2.HelmChart object in the same namespace as the referenced
220+
// v1beta2.Source.
221221
type HelmChartTemplate struct {
222-
// Spec holds the template for the v1beta1.HelmChartSpec for this HelmRelease.
222+
// Spec holds the template for the v1beta2.HelmChartSpec for this HelmRelease.
223223
// +required
224224
Spec HelmChartTemplateSpec `json:"spec"`
225225
}
226226

227227
// HelmChartTemplateSpec defines the template from which the controller will
228-
// generate a v1beta1.HelmChartSpec object.
228+
// generate a v1beta2.HelmChartSpec object.
229229
type HelmChartTemplateSpec struct {
230230
// The name or path the Helm chart is available at in the SourceRef.
231231
// +required
232232
Chart string `json:"chart"`
233233

234-
// Version semver expression, ignored for charts from v1beta1.GitRepository and
235-
// v1beta1.Bucket sources. Defaults to latest when omitted.
234+
// Version semver expression, ignored for charts from v1beta2.GitRepository and
235+
// v1beta2.Bucket sources. Defaults to latest when omitted.
236236
// +kubebuilder:default:=*
237237
// +optional
238238
Version string `json:"version,omitempty"`
239239

240-
// The name and namespace of the v1beta1.Source the chart is available at.
240+
// The name and namespace of the v1beta2.Source the chart is available at.
241241
// +required
242242
SourceRef CrossNamespaceObjectReference `json:"sourceRef"`
243243

244-
// Interval at which to check the v1beta1.Source for updates. Defaults to
244+
// Interval at which to check the v1beta2.Source for updates. Defaults to
245245
// 'HelmReleaseSpec.Interval'.
246246
// +optional
247247
Interval *metav1.Duration `json:"interval,omitempty"`
@@ -271,7 +271,7 @@ type HelmChartTemplateSpec struct {
271271
ValuesFile string `json:"valuesFile,omitempty"`
272272
}
273273

274-
// GetInterval returns the configured interval for the v1beta1.HelmChart,
274+
// GetInterval returns the configured interval for the v1beta2.HelmChart,
275275
// or the given default.
276276
func (in HelmChartTemplate) GetInterval(defaultInterval metav1.Duration) metav1.Duration {
277277
if in.Spec.Interval == nil {
@@ -281,7 +281,7 @@ func (in HelmChartTemplate) GetInterval(defaultInterval metav1.Duration) metav1.
281281
}
282282

283283
// GetNamespace returns the namespace targeted namespace for the
284-
// v1beta1.HelmChart, or the given default.
284+
// v1beta2.HelmChart, or the given default.
285285
func (in HelmChartTemplate) GetNamespace(defaultNamespace string) string {
286286
if in.Spec.SourceRef.Namespace == "" {
287287
return defaultNamespace
@@ -836,23 +836,39 @@ func (in HelmReleaseStatus) GetHelmChart() (string, string) {
836836
// 'Unknown' for meta.ProgressingReason.
837837
func HelmReleaseProgressing(hr HelmRelease) HelmRelease {
838838
hr.Status.Conditions = []metav1.Condition{}
839-
meta.SetResourceCondition(&hr, meta.ReadyCondition, metav1.ConditionUnknown, meta.ProgressingReason,
840-
"Reconciliation in progress")
839+
newCondition := metav1.Condition{
840+
Type: meta.ReadyCondition,
841+
Status: metav1.ConditionUnknown,
842+
Reason: meta.ProgressingReason,
843+
Message: "Reconciliation in progress",
844+
}
845+
apimeta.SetStatusCondition(hr.GetStatusConditions(), newCondition)
841846
resetFailureCounts(&hr)
842847
return hr
843848
}
844849

845850
// HelmReleaseNotReady registers a failed reconciliation of the given HelmRelease.
846851
func HelmReleaseNotReady(hr HelmRelease, reason, message string) HelmRelease {
847-
meta.SetResourceCondition(&hr, meta.ReadyCondition, metav1.ConditionFalse, reason, message)
852+
newCondition := metav1.Condition{
853+
Type: meta.ReadyCondition,
854+
Status: metav1.ConditionFalse,
855+
Reason: reason,
856+
Message: message,
857+
}
858+
apimeta.SetStatusCondition(hr.GetStatusConditions(), newCondition)
848859
hr.Status.Failures++
849860
return hr
850861
}
851862

852863
// HelmReleaseReady registers a successful reconciliation of the given HelmRelease.
853864
func HelmReleaseReady(hr HelmRelease) HelmRelease {
854-
meta.SetResourceCondition(&hr, meta.ReadyCondition, metav1.ConditionTrue, meta.ReconciliationSucceededReason,
855-
"Release reconciliation succeeded")
865+
newCondition := metav1.Condition{
866+
Type: meta.ReadyCondition,
867+
Status: metav1.ConditionTrue,
868+
Reason: ReconciliationSucceededReason,
869+
Message: "Release reconciliation succeeded",
870+
}
871+
apimeta.SetStatusCondition(hr.GetStatusConditions(), newCondition)
856872
hr.Status.LastAppliedRevision = hr.Status.LastAttemptedRevision
857873
resetFailureCounts(&hr)
858874
return hr
@@ -963,13 +979,9 @@ func (in HelmRelease) GetMaxHistory() int {
963979
return *in.Spec.MaxHistory
964980
}
965981

966-
// GetDependsOn returns the types.NamespacedName of the HelmRelease, and a
967-
// dependency.CrossNamespaceDependencyReference slice it depends on.
968-
func (in HelmRelease) GetDependsOn() (types.NamespacedName, []dependency.CrossNamespaceDependencyReference) {
969-
return types.NamespacedName{
970-
Namespace: in.Namespace,
971-
Name: in.Namespace,
972-
}, in.Spec.DependsOn
982+
// GetDependsOn returns the list of dependencies across-namespaces.
983+
func (in HelmRelease) GetDependsOn() []meta.NamespacedObjectReference {
984+
return in.Spec.DependsOn
973985
}
974986

975987
// GetStatusConditions returns a pointer to the Status.Conditions slice

api/v2beta1/zz_generated.deepcopy.go

+2-2
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

+14-12
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,19 @@ spec:
4949
description: HelmReleaseSpec defines the desired state of a Helm release.
5050
properties:
5151
chart:
52-
description: Chart defines the template of the v1beta1.HelmChart that
52+
description: Chart defines the template of the v1beta2.HelmChart that
5353
should be created for this HelmRelease.
5454
properties:
5555
spec:
56-
description: Spec holds the template for the v1beta1.HelmChartSpec
56+
description: Spec holds the template for the v1beta2.HelmChartSpec
5757
for this HelmRelease.
5858
properties:
5959
chart:
6060
description: The name or path the Helm chart is available
6161
at in the SourceRef.
6262
type: string
6363
interval:
64-
description: Interval at which to check the v1beta1.Source
64+
description: Interval at which to check the v1beta2.Source
6565
for updates. Defaults to 'HelmReleaseSpec.Interval'.
6666
type: string
6767
reconcileStrategy:
@@ -75,7 +75,7 @@ spec:
7575
- Revision
7676
type: string
7777
sourceRef:
78-
description: The name and namespace of the v1beta1.Source
78+
description: The name and namespace of the v1beta2.Source
7979
the chart is available at.
8080
properties:
8181
apiVersion:
@@ -120,7 +120,7 @@ spec:
120120
version:
121121
default: '*'
122122
description: Version semver expression, ignored for charts
123-
from v1beta1.GitRepository and v1beta1.Bucket sources. Defaults
123+
from v1beta2.GitRepository and v1beta2.Bucket sources. Defaults
124124
to latest when omitted.
125125
type: string
126126
required:
@@ -131,18 +131,19 @@ spec:
131131
- spec
132132
type: object
133133
dependsOn:
134-
description: DependsOn may contain a dependency.CrossNamespaceDependencyReference
134+
description: DependsOn may contain a meta.NamespacedObjectReference
135135
slice with references to HelmRelease resources that must be ready
136136
before this HelmRelease can be reconciled.
137137
items:
138-
description: CrossNamespaceDependencyReference holds the reference
139-
to a dependency.
138+
description: NamespacedObjectReference contains enough information
139+
to locate the referenced Kubernetes resource object in any namespace.
140140
properties:
141141
name:
142-
description: Name holds the name reference of a dependency.
142+
description: Name of the referent.
143143
type: string
144144
namespace:
145-
description: Namespace holds the namespace reference of a dependency.
145+
description: Namespace of the referent, when not specified it
146+
acts as LocalObjectReference.
146147
type: string
147148
required:
148149
- name
@@ -249,7 +250,7 @@ spec:
249250
for reconciling the HelmRelease.
250251
properties:
251252
name:
252-
description: Name of the referent
253+
description: Name of the referent.
253254
type: string
254255
required:
255256
- name
@@ -750,7 +751,8 @@ spec:
750751
type: string
751752
lastHandledReconcileAt:
752753
description: LastHandledReconcileAt holds the value of the most recent
753-
reconcile request value, so a change can be detected.
754+
reconcile request value, so a change of the annotation value can
755+
be detected.
754756
type: string
755757
lastReleaseRevision:
756758
description: LastReleaseRevision is the revision of the last successful

config/default/kustomization.yaml

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ apiVersion: kustomize.config.k8s.io/v1beta1
22
kind: Kustomization
33
namespace: helm-system
44
resources:
5-
- https://github.com/fluxcd/source-controller/releases/download/v0.21.1/source-controller.crds.yaml
6-
- https://github.com/fluxcd/source-controller/releases/download/v0.21.1/source-controller.deployment.yaml
5+
- https://github.com/fluxcd/source-controller//config/crd/?ref=rewrite-dev
6+
- https://github.com/fluxcd/source-controller//config/manager/?ref=rewrite-dev
77
- ../crd
88
- ../rbac
99
- ../manager
1010
- namespace.yaml
11+
12+
images:
13+
- name: fluxcd/source-controller
14+
newTag: v1beta2-8011d096

config/samples/source_v1beta1_gitrepository.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
apiVersion: source.toolkit.fluxcd.io/v1beta1
1+
apiVersion: source.toolkit.fluxcd.io/v1beta2
22
kind: GitRepository
33
metadata:
44
name: podinfo

config/samples/source_v1beta1_helmrepository.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
apiVersion: source.toolkit.fluxcd.io/v1beta1
1+
apiVersion: source.toolkit.fluxcd.io/v1beta2
22
kind: HelmRepository
33
metadata:
44
name: podinfo

config/testdata/charts/crds/bootstrap/templates/git-repository.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
apiVersion: source.toolkit.fluxcd.io/v1beta1
2+
apiVersion: source.toolkit.fluxcd.io/v1beta2
33
kind: GitRepository
44
metadata:
55
name: this
@@ -13,4 +13,4 @@ spec:
1313
{{- end}}
1414
{{- if .Values.branch }}
1515
tag: "{{ .Values.tag }}"
16-
{{- end}}
16+
{{- end}}

config/testdata/sources/gitrepository.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
apiVersion: source.toolkit.fluxcd.io/v1beta1
1+
apiVersion: source.toolkit.fluxcd.io/v1beta2
22
kind: GitRepository
33
metadata:
44
name: podinfo

0 commit comments

Comments
 (0)