Skip to content

Commit 034ea18

Browse files
committed
Update controller to OCIRepository v1 (GA)
Signed-off-by: Stefan Prodan <[email protected]>
1 parent ff69170 commit 034ea18

File tree

14 files changed

+63
-72
lines changed

14 files changed

+63
-72
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ operator.
4343

4444
## Guides
4545

46-
* [Get started with GitOps Toolkit](https://fluxcd.io/flux/get-started/)
46+
* [Get started with Flux](https://fluxcd.io/flux/get-started/)
4747
* [Manage Helm Releases](https://fluxcd.io/flux/guides/helmreleases/)
4848
* [Setup Notifications](https://fluxcd.io/flux/guides/notifications/)
4949

config/default/kustomization.yaml

Lines changed: 2 additions & 2 deletions
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/v1.5.0/source-controller.crds.yaml
6-
- https://github.com/fluxcd/source-controller/releases/download/v1.5.0/source-controller.deployment.yaml
5+
- https://github.com/fluxcd/source-controller/releases/download/v1.6.0/source-controller.crds.yaml
6+
- https://github.com/fluxcd/source-controller/releases/download/v1.6.0/source-controller.deployment.yaml
77
- ../crd
88
- ../rbac
99
- ../manager

config/samples/source_v1beta2_ocirepository.yaml renamed to config/samples/source_v1_ocirepository.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
apiVersion: source.toolkit.fluxcd.io/v1beta2
1+
apiVersion: source.toolkit.fluxcd.io/v1
22
kind: OCIRepository
33
metadata:
44
name: podinfo

config/testdata/install-from-ocirepo-source/test.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
apiVersion: source.toolkit.fluxcd.io/v1beta2
2+
apiVersion: source.toolkit.fluxcd.io/v1
33
kind: OCIRepository
44
metadata:
55
name: podinfo-ocirepo
@@ -9,7 +9,7 @@ spec:
99
ref:
1010
tag: 6.6.0
1111
---
12-
apiVersion: helm.toolkit.fluxcd.io/v2beta2
12+
apiVersion: helm.toolkit.fluxcd.io/v2
1313
kind: HelmRelease
1414
metadata:
1515
name: podinfo-from-ocirepo

config/testdata/upgrade-from-ocirepo-source/install.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
apiVersion: source.toolkit.fluxcd.io/v1beta2
2+
apiVersion: source.toolkit.fluxcd.io/v1
33
kind: OCIRepository
44
metadata:
55
name: upgrade-from-ocirepo-source
@@ -9,7 +9,7 @@ spec:
99
ref:
1010
digest: "sha256:cdd538a0167e4b51152b71a477e51eb6737553510ce8797dbcc537e1342311bb"
1111
---
12-
apiVersion: helm.toolkit.fluxcd.io/v2beta2
12+
apiVersion: helm.toolkit.fluxcd.io/v2
1313
kind: HelmRelease
1414
metadata:
1515
name: upgrade-from-ocirepo-source

config/testdata/upgrade-from-ocirepo-source/upgrade.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
apiVersion: source.toolkit.fluxcd.io/v1beta2
2+
apiVersion: source.toolkit.fluxcd.io/v1
33
kind: OCIRepository
44
metadata:
55
name: upgrade-from-ocirepo-source

docs/spec/v2/helmreleases.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ HelmRelease object.
232232
#### OCIRepository reference example
233233

234234
```yaml
235-
apiVersion: source.toolkit.fluxcd.io/v1beta2
235+
apiVersion: source.toolkit.fluxcd.io/v1
236236
kind: OCIRepository
237237
metadata:
238238
name: podinfo

internal/controller/helmrelease_controller.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ import (
5656
"github.com/fluxcd/pkg/runtime/patch"
5757
"github.com/fluxcd/pkg/runtime/predicates"
5858
sourcev1 "github.com/fluxcd/source-controller/api/v1"
59-
sourcev1beta2 "github.com/fluxcd/source-controller/api/v1beta2"
6059

6160
"github.com/fluxcd/pkg/chartutil"
6261

@@ -143,7 +142,7 @@ func (r *HelmReleaseReconciler) SetupWithManager(ctx context.Context, mgr ctrl.M
143142
builder.WithPredicates(intpredicates.SourceRevisionChangePredicate{}),
144143
).
145144
Watches(
146-
&sourcev1beta2.OCIRepository{},
145+
&sourcev1.OCIRepository{},
147146
handler.EnqueueRequestsFromMapFunc(r.requestsForOCIRrepositoryChange),
148147
builder.WithPredicates(intpredicates.SourceRevisionChangePredicate{}),
149148
).
@@ -436,7 +435,7 @@ func (r *HelmReleaseReconciler) reconcileRelease(ctx context.Context, patchHelpe
436435
return jitter.JitteredRequeueInterval(ctrl.Result{RequeueAfter: obj.GetRequeueAfter()}), nil
437436
}
438437

439-
// reconcileDelete deletes the v1beta2.HelmChart of the v2.HelmRelease,
438+
// reconcileDelete deletes the v1.HelmChart of the v2.HelmRelease,
440439
// and uninstalls the Helm release if the resource has not been suspended.
441440
func (r *HelmReleaseReconciler) reconcileDelete(ctx context.Context, obj *v2.HelmRelease) (ctrl.Result, error) {
442441
// Only uninstall the release and delete the HelmChart resource if the
@@ -712,7 +711,7 @@ func (r *HelmReleaseReconciler) buildRESTClientGetter(ctx context.Context, obj *
712711
func (r *HelmReleaseReconciler) getSource(ctx context.Context, obj *v2.HelmRelease) (sourcev1.Source, error) {
713712
var name, namespace string
714713
if obj.HasChartRef() {
715-
if obj.Spec.ChartRef.Kind == sourcev1beta2.OCIRepositoryKind {
714+
if obj.Spec.ChartRef.Kind == sourcev1.OCIRepositoryKind {
716715
return r.getSourceFromOCIRef(ctx, obj)
717716
}
718717
name, namespace = obj.Spec.ChartRef.Name, obj.Spec.ChartRef.Namespace
@@ -743,11 +742,11 @@ func (r *HelmReleaseReconciler) getSourceFromOCIRef(ctx context.Context, obj *v2
743742
}
744743
ociRepoRef := types.NamespacedName{Namespace: namespace, Name: name}
745744

746-
if err := intacl.AllowsAccessTo(obj, sourcev1beta2.OCIRepositoryKind, ociRepoRef); err != nil {
745+
if err := intacl.AllowsAccessTo(obj, sourcev1.OCIRepositoryKind, ociRepoRef); err != nil {
747746
return nil, err
748747
}
749748

750-
or := sourcev1beta2.OCIRepository{}
749+
or := sourcev1.OCIRepository{}
751750
if err := r.Client.Get(ctx, ociRepoRef, &or); err != nil {
752751
return nil, err
753752
}
@@ -805,7 +804,7 @@ func (r *HelmReleaseReconciler) requestsForHelmChartChange(ctx context.Context,
805804
}
806805

807806
func (r *HelmReleaseReconciler) requestsForOCIRrepositoryChange(ctx context.Context, o client.Object) []reconcile.Request {
808-
or, ok := o.(*sourcev1beta2.OCIRepository)
807+
or, ok := o.(*sourcev1.OCIRepository)
809808
if !ok {
810809
err := fmt.Errorf("expected an OCIRepository, got %T", o)
811810
ctrl.LoggerFrom(ctx).Error(err, "failed to get requests for OCIRepository change")
@@ -907,7 +906,7 @@ func (r *HelmReleaseReconciler) mutateChartWithSourceRevision(chart *chart.Chart
907906
// If the source is an OCIRepository, we can try to mutate the chart version
908907
// with the artifact revision. The revision is either a <tag>@<digest> or
909908
// just a digest.
910-
obj, ok := source.(*sourcev1beta2.OCIRepository)
909+
obj, ok := source.(*sourcev1.OCIRepository)
911910
if !ok {
912911
// if not make sure to return an empty string to delete the digest of the
913912
// last attempted revision

0 commit comments

Comments
 (0)