Skip to content

Commit

Permalink
fix: backwards compatibility to HelmRelease v2beta1
Browse files Browse the repository at this point in the history
  • Loading branch information
laszlocph committed Mar 5, 2024
1 parent 1d6541a commit d49a41e
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion pkg/controllers/helmreleaseController.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

var helmReleaseResource = schema.GroupVersionResource{
Group: "helm.toolkit.fluxcd.io",
Version: "v2beta2",
Version: "v2beta1",
Resource: "helmreleases",
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/flux/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime/schema"

helmv2 "github.com/fluxcd/helm-controller/api/v2beta2"
helmv2 "github.com/fluxcd/helm-controller/api/v2beta1"
autov1 "github.com/fluxcd/image-automation-controller/api/v1beta1"
imagev1 "github.com/fluxcd/image-reflector-controller/api/v1beta2"
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1"
Expand Down
16 changes: 8 additions & 8 deletions pkg/flux/flux.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"sort"
"strings"

helmv2beta2 "github.com/fluxcd/helm-controller/api/v2beta2"
helmv2beta1 "github.com/fluxcd/helm-controller/api/v2beta1"
kustomizationv1 "github.com/fluxcd/kustomize-controller/api/v1"
sourcev1 "github.com/fluxcd/source-controller/api/v1"
sourcev1beta2 "github.com/fluxcd/source-controller/api/v1beta2"
Expand Down Expand Up @@ -56,7 +56,7 @@ var (

helmReleaseGVR = schema.GroupVersionResource{
Group: "helm.toolkit.fluxcd.io",
Version: "v2beta2",
Version: "v2beta1",
Resource: "helmreleases",
}
)
Expand Down Expand Up @@ -233,8 +233,8 @@ func inventory(dc *dynamic.DynamicClient) ([]object.ObjMetadata, error) {
return inventory, nil
}

func helmReleases(dc *dynamic.DynamicClient) ([]helmv2beta2.HelmRelease, error) {
releases := []helmv2beta2.HelmRelease{}
func helmReleases(dc *dynamic.DynamicClient) ([]helmv2beta1.HelmRelease, error) {
releases := []helmv2beta1.HelmRelease{}

helmReleases, err := dc.Resource(helmReleaseGVR).
Namespace("").
Expand All @@ -245,7 +245,7 @@ func helmReleases(dc *dynamic.DynamicClient) ([]helmv2beta2.HelmRelease, error)

for _, h := range helmReleases.Items {
unstructured := h.UnstructuredContent()
var helmRelease helmv2beta2.HelmRelease
var helmRelease helmv2beta1.HelmRelease
err = runtime.DefaultUnstructuredConverter.FromUnstructured(unstructured, &helmRelease)
if err != nil {
return nil, err
Expand All @@ -259,7 +259,7 @@ func helmReleases(dc *dynamic.DynamicClient) ([]helmv2beta2.HelmRelease, error)

func helmStatusWithResources(
releases []*rspb.Release,
hr helmv2beta2.HelmRelease,
hr helmv2beta1.HelmRelease,
) (kube.ResourceList, error) {
var release *rspb.Release
version := -1
Expand Down Expand Up @@ -300,7 +300,7 @@ func State(c *kubernetes.Clientset, dc *dynamic.DynamicClient) (*FluxState, erro
OCIRepositories: []sourcev1beta2.OCIRepository{},
Buckets: []sourcev1beta2.Bucket{},
Kustomizations: []kustomizationv1.Kustomization{},
HelmReleases: []helmv2beta2.HelmRelease{},
HelmReleases: []helmv2beta1.HelmRelease{},
FluxServices: []Service{},
}

Expand Down Expand Up @@ -379,7 +379,7 @@ func State(c *kubernetes.Clientset, dc *dynamic.DynamicClient) (*FluxState, erro
}
for _, h := range helmReleases.Items {
unstructured := h.UnstructuredContent()
var helmRelease helmv2beta2.HelmRelease
var helmRelease helmv2beta1.HelmRelease
err = runtime.DefaultUnstructuredConverter.FromUnstructured(unstructured, &helmRelease)
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions pkg/flux/helmrelease.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ package flux
import (
"fmt"

helmv2beta2 "github.com/fluxcd/helm-controller/api/v2beta2"
helmv2beta1 "github.com/fluxcd/helm-controller/api/v2beta1"
"sigs.k8s.io/controller-runtime/pkg/client"
)

type helmReleaseAdapter struct {
*helmv2beta2.HelmRelease
*helmv2beta1.HelmRelease
}

func (h helmReleaseAdapter) asClientObject() client.Object {
Expand Down
12 changes: 6 additions & 6 deletions pkg/flux/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"context"
"time"

helmv2 "github.com/fluxcd/helm-controller/api/v2beta2"
helmv2beta1 "github.com/fluxcd/helm-controller/api/v2beta1"
kustomizationv1 "github.com/fluxcd/kustomize-controller/api/v1"
"github.com/fluxcd/pkg/apis/meta"
sourcev1 "github.com/fluxcd/source-controller/api/v1"
Expand Down Expand Up @@ -64,9 +64,9 @@ func NewReconcileCommand(resource string) *reconcileCommand {
}
case "helmrelease":
return &reconcileCommand{
object: helmReleaseAdapter{&helmv2.HelmRelease{}},
groupVersion: helmv2.GroupVersion,
kind: helmv2.HelmReleaseKind,
object: helmReleaseAdapter{&helmv2beta1.HelmRelease{}},
groupVersion: helmv2beta1.GroupVersion,
kind: helmv2beta1.HelmReleaseKind,
}
case sourcev1.GitRepositoryKind:
return &reconcileCommand{
Expand Down Expand Up @@ -96,7 +96,7 @@ func (r *reconcileCommand) Run(config *rest.Config, namespace, name string) {
sourcev1.AddToScheme(scheme)
sourcev1beta2.AddToScheme(scheme)
kustomizationv1.AddToScheme(scheme)
helmv2.AddToScheme(scheme)
helmv2beta1.AddToScheme(scheme)

kubeClient, err := client.NewWithWatch(config, client.Options{
Scheme: scheme,
Expand Down Expand Up @@ -194,7 +194,7 @@ func requestReconciliation(
annotations[meta.ReconcileRequestAnnotation] = ts

// HelmRelease specific annotations to force a release.
if gvk.Kind == helmv2.HelmReleaseKind {
if gvk.Kind == helmv2beta1.HelmReleaseKind {
annotations["reconcile.fluxcd.io/forceAt"] = ts
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/flux/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package flux
import (
"time"

helmv2beta2 "github.com/fluxcd/helm-controller/api/v2beta2"
helmv2beta1 "github.com/fluxcd/helm-controller/api/v2beta1"
kustomizationv1 "github.com/fluxcd/kustomize-controller/api/v1"
sourcev1 "github.com/fluxcd/source-controller/api/v1"
sourcev1beta2 "github.com/fluxcd/source-controller/api/v1beta2"
Expand All @@ -16,7 +16,7 @@ type FluxState struct {
OCIRepositories []sourcev1beta2.OCIRepository `json:"ociRepositories"`
Buckets []sourcev1beta2.Bucket `json:"buckets"`
Kustomizations []kustomizationv1.Kustomization `json:"kustomizations"`
HelmReleases []helmv2beta2.HelmRelease `json:"helmReleases"`
HelmReleases []helmv2beta1.HelmRelease `json:"helmReleases"`
FluxServices []Service `json:"fluxServices"`
}

Expand Down

0 comments on commit d49a41e

Please sign in to comment.