Skip to content

Commit d038382

Browse files
authored
Merge pull request #421 from fluxcd/runtime-meta-rc
2 parents 76fc39a + 6bd29a7 commit d038382

23 files changed

+217
-227
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.1
98
k8s.io/apiextensions-apiserver v0.23.1
10-
k8s.io/apimachinery v0.23.1
9+
k8s.io/apimachinery v0.23.4
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

+13-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"
@@ -64,7 +64,7 @@ type PostRenderer struct {
6464

6565
// HelmReleaseSpec defines the desired state of a Helm release.
6666
type HelmReleaseSpec struct {
67-
// Chart defines the template of the v1beta1.HelmChart that should be created
67+
// Chart defines the template of the v1beta2.HelmChart that should be created
6868
// for this HelmRelease.
6969
// +required
7070
Chart HelmChartTemplate `json:"chart"`
@@ -107,11 +107,11 @@ type HelmReleaseSpec struct {
107107
// +optional
108108
StorageNamespace string `json:"storageNamespace,omitempty"`
109109

110-
// DependsOn may contain a dependency.CrossNamespaceDependencyReference slice with
110+
// DependsOn may contain a meta.NamespacedObjectReference slice with
111111
// references to HelmRelease resources that must be ready before this HelmRelease
112112
// can be reconciled.
113113
// +optional
114-
DependsOn []dependency.CrossNamespaceDependencyReference `json:"dependsOn,omitempty"`
114+
DependsOn []meta.NamespacedObjectReference `json:"dependsOn,omitempty"`
115115

116116
// Timeout is the time to wait for any individual Kubernetes operation (like Jobs
117117
// for hooks) during the performance of a Helm action. Defaults to '5m0s'.
@@ -221,32 +221,32 @@ type KubeConfig struct {
221221
}
222222

223223
// HelmChartTemplate defines the template from which the controller will
224-
// generate a v1beta1.HelmChart object in the same namespace as the referenced
225-
// v1beta1.Source.
224+
// generate a v1beta2.HelmChart object in the same namespace as the referenced
225+
// v1beta2.Source.
226226
type HelmChartTemplate struct {
227-
// Spec holds the template for the v1beta1.HelmChartSpec for this HelmRelease.
227+
// Spec holds the template for the v1beta2.HelmChartSpec for this HelmRelease.
228228
// +required
229229
Spec HelmChartTemplateSpec `json:"spec"`
230230
}
231231

232232
// HelmChartTemplateSpec defines the template from which the controller will
233-
// generate a v1beta1.HelmChartSpec object.
233+
// generate a v1beta2.HelmChartSpec object.
234234
type HelmChartTemplateSpec struct {
235235
// The name or path the Helm chart is available at in the SourceRef.
236236
// +required
237237
Chart string `json:"chart"`
238238

239-
// Version semver expression, ignored for charts from v1beta1.GitRepository and
240-
// v1beta1.Bucket sources. Defaults to latest when omitted.
239+
// Version semver expression, ignored for charts from v1beta2.GitRepository and
240+
// v1beta2.Bucket sources. Defaults to latest when omitted.
241241
// +kubebuilder:default:=*
242242
// +optional
243243
Version string `json:"version,omitempty"`
244244

245-
// The name and namespace of the v1beta1.Source the chart is available at.
245+
// The name and namespace of the v1beta2.Source the chart is available at.
246246
// +required
247247
SourceRef CrossNamespaceObjectReference `json:"sourceRef"`
248248

249-
// Interval at which to check the v1beta1.Source for updates. Defaults to
249+
// Interval at which to check the v1beta2.Source for updates. Defaults to
250250
// 'HelmReleaseSpec.Interval'.
251251
// +optional
252252
Interval *metav1.Duration `json:"interval,omitempty"`
@@ -276,7 +276,7 @@ type HelmChartTemplateSpec struct {
276276
ValuesFile string `json:"valuesFile,omitempty"`
277277
}
278278

279-
// GetInterval returns the configured interval for the v1beta1.HelmChart,
279+
// GetInterval returns the configured interval for the v1beta2.HelmChart,
280280
// or the given default.
281281
func (in HelmChartTemplate) GetInterval(defaultInterval metav1.Duration) metav1.Duration {
282282
if in.Spec.Interval == nil {
@@ -286,7 +286,7 @@ func (in HelmChartTemplate) GetInterval(defaultInterval metav1.Duration) metav1.
286286
}
287287

288288
// GetNamespace returns the namespace targeted namespace for the
289-
// v1beta1.HelmChart, or the given default.
289+
// v1beta2.HelmChart, or the given default.
290290
func (in HelmChartTemplate) GetNamespace(defaultNamespace string) string {
291291
if in.Spec.SourceRef.Namespace == "" {
292292
return defaultNamespace
@@ -841,23 +841,39 @@ func (in HelmReleaseStatus) GetHelmChart() (string, string) {
841841
// 'Unknown' for meta.ProgressingReason.
842842
func HelmReleaseProgressing(hr HelmRelease) HelmRelease {
843843
hr.Status.Conditions = []metav1.Condition{}
844-
meta.SetResourceCondition(&hr, meta.ReadyCondition, metav1.ConditionUnknown, meta.ProgressingReason,
845-
"Reconciliation in progress")
844+
newCondition := metav1.Condition{
845+
Type: meta.ReadyCondition,
846+
Status: metav1.ConditionUnknown,
847+
Reason: meta.ProgressingReason,
848+
Message: "Reconciliation in progress",
849+
}
850+
apimeta.SetStatusCondition(hr.GetStatusConditions(), newCondition)
846851
resetFailureCounts(&hr)
847852
return hr
848853
}
849854

850855
// HelmReleaseNotReady registers a failed reconciliation of the given HelmRelease.
851856
func HelmReleaseNotReady(hr HelmRelease, reason, message string) HelmRelease {
852-
meta.SetResourceCondition(&hr, meta.ReadyCondition, metav1.ConditionFalse, reason, message)
857+
newCondition := metav1.Condition{
858+
Type: meta.ReadyCondition,
859+
Status: metav1.ConditionFalse,
860+
Reason: reason,
861+
Message: message,
862+
}
863+
apimeta.SetStatusCondition(hr.GetStatusConditions(), newCondition)
853864
hr.Status.Failures++
854865
return hr
855866
}
856867

857868
// HelmReleaseReady registers a successful reconciliation of the given HelmRelease.
858869
func HelmReleaseReady(hr HelmRelease) HelmRelease {
859-
meta.SetResourceCondition(&hr, meta.ReadyCondition, metav1.ConditionTrue, meta.ReconciliationSucceededReason,
860-
"Release reconciliation succeeded")
870+
newCondition := metav1.Condition{
871+
Type: meta.ReadyCondition,
872+
Status: metav1.ConditionTrue,
873+
Reason: ReconciliationSucceededReason,
874+
Message: "Release reconciliation succeeded",
875+
}
876+
apimeta.SetStatusCondition(hr.GetStatusConditions(), newCondition)
861877
hr.Status.LastAppliedRevision = hr.Status.LastAttemptedRevision
862878
resetFailureCounts(&hr)
863879
return hr
@@ -968,13 +984,9 @@ func (in HelmRelease) GetMaxHistory() int {
968984
return *in.Spec.MaxHistory
969985
}
970986

971-
// GetDependsOn returns the types.NamespacedName of the HelmRelease, and a
972-
// dependency.CrossNamespaceDependencyReference slice it depends on.
973-
func (in HelmRelease) GetDependsOn() (types.NamespacedName, []dependency.CrossNamespaceDependencyReference) {
974-
return types.NamespacedName{
975-
Namespace: in.Namespace,
976-
Name: in.Namespace,
977-
}, in.Spec.DependsOn
987+
// GetDependsOn returns the list of dependencies across-namespaces.
988+
func (in HelmRelease) GetDependsOn() []meta.NamespacedObjectReference {
989+
return in.Spec.DependsOn
978990
}
979991

980992
// 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
@@ -805,7 +806,8 @@ spec:
805806
type: string
806807
lastHandledReconcileAt:
807808
description: LastHandledReconcileAt holds the value of the most recent
808-
reconcile request value, so a change can be detected.
809+
reconcile request value, so a change of the annotation value can
810+
be detected.
809811
type: string
810812
lastReleaseRevision:
811813
description: LastReleaseRevision is the revision of the last successful

config/default/kustomization.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ 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/releases/download/v0.22.0/source-controller.crds.yaml
6+
- https://github.com/fluxcd/source-controller/releases/download/v0.22.0/source-controller.deployment.yaml
77
- ../crd
88
- ../rbac
99
- ../manager

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)