From 8efdb51c7747a099aada56164403e50a7b5fe11a Mon Sep 17 00:00:00 2001 From: Hidde Beydals Date: Thu, 15 Aug 2019 12:30:02 +0200 Subject: [PATCH] Add support for HelmRelease v1 resources This commit adds support for HelmRelease v1 resources with backwards compatability for v1beta1 resources, it also reintroduces some of the removed `integrations/` packages, as those resources have been removed from the Helm operator. The v1 resource is prioritized over v1beta1 resources, as Flux is only aware of the resource kind and not the api version. The prioritization means that if there are two resources with the same namespace and name, Flux will only see the v1 resource. The fallback is based on returned errors from the API, this comes at a cost, as errors during the first try may actually be relevant. The version of `github.com/fluxcd/helm-operator` has been pinpointed on `1.0.0-rc1`. --- cluster/kubernetes/kubernetes.go | 20 +- cluster/kubernetes/patch.go | 2 +- .../{fluxhelmrelease.go => helmrelease.go} | 28 +- ...elmrelease_test.go => helmrelease_test.go} | 333 ++++++++++-------- cluster/kubernetes/resource/resource.go | 6 +- cluster/kubernetes/resourcekinds.go | 88 +++-- cluster/kubernetes/sync_test.go | 17 +- cluster/kubernetes/update_test.go | 60 +++- cmd/fluxd/main.go | 15 +- go.mod | 5 +- go.sum | 6 +- install/install_test.go | 2 +- .../apis/flux.weave.works/register.go | 5 + .../apis/flux.weave.works/v1beta1/doc.go | 10 + .../apis/flux.weave.works/v1beta1/register.go | 42 +++ .../apis/flux.weave.works/v1beta1/types.go | 299 ++++++++++++++++ .../flux.weave.works/v1beta1/types_test.go | 52 +++ .../v1beta1/zz_generated.deepcopy.go | 326 +++++++++++++++++ .../register.go | 5 + .../v1alpha2/doc.go | 5 + .../v1alpha2/register.go | 42 +++ .../v1alpha2/types.go | 68 ++++ .../v1alpha2/types_test.go | 52 +++ .../v1alpha2/zz_generated.deepcopy.go | 125 +++++++ .../client/clientset/versioned/clientset.go | 104 ++++++ .../client/clientset/versioned/doc.go | 20 ++ .../versioned/fake/clientset_generated.go | 84 +++++ .../client/clientset/versioned/fake/doc.go | 20 ++ .../clientset/versioned/fake/register.go | 58 +++ .../client/clientset/versioned/scheme/doc.go | 20 ++ .../clientset/versioned/scheme/register.go | 58 +++ .../typed/flux.weave.works/v1beta1/doc.go | 20 ++ .../flux.weave.works/v1beta1/fake/doc.go | 20 ++ .../fake/fake_flux.weave.works_client.go | 40 +++ .../v1beta1/fake/fake_helmrelease.go | 140 ++++++++ .../v1beta1/flux.weave.works_client.go | 90 +++++ .../v1beta1/generated_expansion.go | 21 ++ .../flux.weave.works/v1beta1/helmrelease.go | 191 ++++++++++ .../v1alpha2/doc.go | 20 ++ .../v1alpha2/fake/doc.go | 20 ++ .../v1alpha2/fake/fake_fluxhelmrelease.go | 128 +++++++ ...lm.integrations.flux.weave.works_client.go | 40 +++ .../v1alpha2/fluxhelmrelease.go | 174 +++++++++ .../v1alpha2/generated_expansion.go | 21 ++ ...lm.integrations.flux.weave.works_client.go | 90 +++++ .../informers/externalversions/factory.go | 186 ++++++++++ .../flux.weave.works/interface.go | 46 +++ .../flux.weave.works/v1beta1/helmrelease.go | 89 +++++ .../flux.weave.works/v1beta1/interface.go | 45 +++ .../informers/externalversions/generic.go | 67 ++++ .../interface.go | 46 +++ .../v1alpha2/fluxhelmrelease.go | 89 +++++ .../v1alpha2/interface.go | 45 +++ .../internalinterfaces/factory_interfaces.go | 40 +++ .../v1beta1/expansion_generated.go | 27 ++ .../flux.weave.works/v1beta1/helmrelease.go | 94 +++++ .../v1alpha2/expansion_generated.go | 27 ++ .../v1alpha2/fluxhelmrelease.go | 94 +++++ 58 files changed, 3679 insertions(+), 208 deletions(-) rename cluster/kubernetes/resource/{fluxhelmrelease.go => helmrelease.go} (86%) rename cluster/kubernetes/resource/{fluxhelmrelease_test.go => helmrelease_test.go} (76%) create mode 100644 integrations/apis/flux.weave.works/register.go create mode 100644 integrations/apis/flux.weave.works/v1beta1/doc.go create mode 100644 integrations/apis/flux.weave.works/v1beta1/register.go create mode 100644 integrations/apis/flux.weave.works/v1beta1/types.go create mode 100644 integrations/apis/flux.weave.works/v1beta1/types_test.go create mode 100644 integrations/apis/flux.weave.works/v1beta1/zz_generated.deepcopy.go create mode 100644 integrations/apis/helm.integrations.flux.weave.works/register.go create mode 100644 integrations/apis/helm.integrations.flux.weave.works/v1alpha2/doc.go create mode 100644 integrations/apis/helm.integrations.flux.weave.works/v1alpha2/register.go create mode 100644 integrations/apis/helm.integrations.flux.weave.works/v1alpha2/types.go create mode 100644 integrations/apis/helm.integrations.flux.weave.works/v1alpha2/types_test.go create mode 100644 integrations/apis/helm.integrations.flux.weave.works/v1alpha2/zz_generated.deepcopy.go create mode 100644 integrations/client/clientset/versioned/clientset.go create mode 100644 integrations/client/clientset/versioned/doc.go create mode 100644 integrations/client/clientset/versioned/fake/clientset_generated.go create mode 100644 integrations/client/clientset/versioned/fake/doc.go create mode 100644 integrations/client/clientset/versioned/fake/register.go create mode 100644 integrations/client/clientset/versioned/scheme/doc.go create mode 100644 integrations/client/clientset/versioned/scheme/register.go create mode 100644 integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/doc.go create mode 100644 integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/fake/doc.go create mode 100644 integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/fake/fake_flux.weave.works_client.go create mode 100644 integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/fake/fake_helmrelease.go create mode 100644 integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/flux.weave.works_client.go create mode 100644 integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/generated_expansion.go create mode 100644 integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/helmrelease.go create mode 100644 integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/doc.go create mode 100644 integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/fake/doc.go create mode 100644 integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/fake/fake_fluxhelmrelease.go create mode 100644 integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/fake/fake_helm.integrations.flux.weave.works_client.go create mode 100644 integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/fluxhelmrelease.go create mode 100644 integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/generated_expansion.go create mode 100644 integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/helm.integrations.flux.weave.works_client.go create mode 100644 integrations/client/informers/externalversions/factory.go create mode 100644 integrations/client/informers/externalversions/flux.weave.works/interface.go create mode 100644 integrations/client/informers/externalversions/flux.weave.works/v1beta1/helmrelease.go create mode 100644 integrations/client/informers/externalversions/flux.weave.works/v1beta1/interface.go create mode 100644 integrations/client/informers/externalversions/generic.go create mode 100644 integrations/client/informers/externalversions/helm.integrations.flux.weave.works/interface.go create mode 100644 integrations/client/informers/externalversions/helm.integrations.flux.weave.works/v1alpha2/fluxhelmrelease.go create mode 100644 integrations/client/informers/externalversions/helm.integrations.flux.weave.works/v1alpha2/interface.go create mode 100644 integrations/client/informers/externalversions/internalinterfaces/factory_interfaces.go create mode 100644 integrations/client/listers/flux.weave.works/v1beta1/expansion_generated.go create mode 100644 integrations/client/listers/flux.weave.works/v1beta1/helmrelease.go create mode 100644 integrations/client/listers/helm.integrations.flux.weave.works/v1alpha2/expansion_generated.go create mode 100644 integrations/client/listers/helm.integrations.flux.weave.works/v1alpha2/fluxhelmrelease.go diff --git a/cluster/kubernetes/kubernetes.go b/cluster/kubernetes/kubernetes.go index 069156cad7..5ec90e3d69 100644 --- a/cluster/kubernetes/kubernetes.go +++ b/cluster/kubernetes/kubernetes.go @@ -7,12 +7,12 @@ import ( "fmt" "sync" + hrclient "github.com/fluxcd/helm-operator/pkg/client/clientset/versioned" "github.com/go-kit/kit/log" "github.com/pkg/errors" "gopkg.in/yaml.v2" apiv1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" - fhrclient "github.com/fluxcd/helm-operator/pkg/client/clientset/versioned" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/discovery" k8sclientdynamic "k8s.io/client-go/dynamic" @@ -20,28 +20,34 @@ import ( "github.com/weaveworks/flux/cluster" kresource "github.com/weaveworks/flux/cluster/kubernetes/resource" - "github.com/weaveworks/flux/ssh" + fhrclient "github.com/weaveworks/flux/integrations/client/clientset/versioned" "github.com/weaveworks/flux/resource" + "github.com/weaveworks/flux/ssh" ) type coreClient k8sclient.Interface type dynamicClient k8sclientdynamic.Interface type fluxHelmClient fhrclient.Interface +type helmOperatorClient hrclient.Interface type discoveryClient discovery.DiscoveryInterface type ExtendedClient struct { coreClient dynamicClient fluxHelmClient + helmOperatorClient discoveryClient } -func MakeClusterClientset(core coreClient, dyn dynamicClient, fluxhelm fluxHelmClient, disco discoveryClient) ExtendedClient { +func MakeClusterClientset(core coreClient, dyn dynamicClient, fluxhelm fluxHelmClient, + helmop helmOperatorClient, disco discoveryClient) ExtendedClient { + return ExtendedClient{ - coreClient: core, - dynamicClient: dyn, - fluxHelmClient: fluxhelm, - discoveryClient: disco, + coreClient: core, + dynamicClient: dyn, + fluxHelmClient: fluxhelm, + helmOperatorClient: helmop, + discoveryClient: disco, } } diff --git a/cluster/kubernetes/patch.go b/cluster/kubernetes/patch.go index 50307e665d..349cbfe88e 100644 --- a/cluster/kubernetes/patch.go +++ b/cluster/kubernetes/patch.go @@ -109,7 +109,7 @@ func applyManifestPatch(originalManifests, patchManifests []byte, originalSource func getFullScheme() *runtime.Scheme { fullScheme := runtime.NewScheme() utilruntime.Must(k8sscheme.AddToScheme(fullScheme)) - // HelmRelease and FluxHelmRelease are intentionally not added to the scheme. + // HelmRelease and HelmRelease are intentionally not added to the scheme. // This is done for two reasons: // 1. The kubernetes strategic merge patcher chokes on the freeform // values under `values:`. diff --git a/cluster/kubernetes/resource/fluxhelmrelease.go b/cluster/kubernetes/resource/helmrelease.go similarity index 86% rename from cluster/kubernetes/resource/fluxhelmrelease.go rename to cluster/kubernetes/resource/helmrelease.go index 51a69b5b0a..beaae3888e 100644 --- a/cluster/kubernetes/resource/fluxhelmrelease.go +++ b/cluster/kubernetes/resource/helmrelease.go @@ -9,7 +9,7 @@ import ( ) // ReleaseContainerName is the name used when Flux interprets a -// FluxHelmRelease as having a container with an image, by virtue of +// HelmRelease as having a container with an image, by virtue of // having a `values` stanza with an image field: // // spec: @@ -20,11 +20,11 @@ import ( // The name refers to the source of the image value. const ReleaseContainerName = "chart-image" -// FluxHelmRelease echoes the generated type for the custom resource +// HelmRelease echoes the generated type for the custom resource // definition. It's here so we can 1. get `baseObject` in there, and // 3. control the YAML serialisation of fields, which we can't do // (easily?) with the generated type. -type FluxHelmRelease struct { +type HelmRelease struct { baseObject Spec struct { Values map[string]interface{} @@ -47,13 +47,13 @@ func sorted_keys(values map[string]interface{}) []string { return keys } -// FindFluxHelmReleaseContainers examines the Values from a -// FluxHelmRelease (manifest, or cluster resource, or otherwise) and +// FindHelmReleaseContainers examines the Values from a +// HelmRelease (manifest, or cluster resource, or otherwise) and // calls visit with each container name and image it finds, as well as // procedure for changing the image value. It will return an error if // it cannot interpret the values as specifying images, or if the // `visit` function itself returns an error. -func FindFluxHelmReleaseContainers(values map[string]interface{}, visit func(string, image.Ref, ImageSetter) error) error { +func FindHelmReleaseContainers(values map[string]interface{}, visit func(string, image.Ref, ImageSetter) error) error { // an image defined at the top-level is given a standard container name: if image, setter, ok := interpretAsContainer(stringMap(values)); ok { visit(ReleaseContainerName, image, setter) @@ -70,7 +70,7 @@ func FindFluxHelmReleaseContainers(values map[string]interface{}, visit func(str } // The following is some machinery for interpreting a -// FluxHelmRelease's `values` field as defining images to be +// HelmRelease's `values` field as defining images to be // interpolated into the chart templates. // // The top-level value is a map[string]interface{}, but beneath that, @@ -221,11 +221,11 @@ func interpretAsImage(m mapper) (image.Ref, ImageSetter, bool) { } // Containers returns the containers that are defined in the -// FluxHelmRelease. -func (fhr FluxHelmRelease) Containers() []resource.Container { +// HelmRelease. +func (hr HelmRelease) Containers() []resource.Container { var containers []resource.Container // If there's an error in interpreting, return what we have. - _ = FindFluxHelmReleaseContainers(fhr.Spec.Values, func(container string, image image.Ref, _ ImageSetter) error { + _ = FindHelmReleaseContainers(hr.Spec.Values, func(container string, image image.Ref, _ ImageSetter) error { containers = append(containers, resource.Container{ Name: container, Image: image, @@ -237,11 +237,11 @@ func (fhr FluxHelmRelease) Containers() []resource.Container { // SetContainerImage mutates this resource by setting the `image` // field of `values`, or a subvalue therein, per one of the -// interpretations in `FindFluxHelmReleaseContainers` above. NB we can +// interpretations in `FindHelmReleaseContainers` above. NB we can // get away with a value-typed receiver because we set a map entry. -func (fhr FluxHelmRelease) SetContainerImage(container string, ref image.Ref) error { +func (hr HelmRelease) SetContainerImage(container string, ref image.Ref) error { found := false - if err := FindFluxHelmReleaseContainers(fhr.Spec.Values, func(name string, image image.Ref, setter ImageSetter) error { + if err := FindHelmReleaseContainers(hr.Spec.Values, func(name string, image image.Ref, setter ImageSetter) error { if container == name { setter(ref) found = true @@ -251,7 +251,7 @@ func (fhr FluxHelmRelease) SetContainerImage(container string, ref image.Ref) er return err } if !found { - return fmt.Errorf("did not find container %s in FluxHelmRelease", container) + return fmt.Errorf("did not find container %s in HelmRelease", container) } return nil } diff --git a/cluster/kubernetes/resource/fluxhelmrelease_test.go b/cluster/kubernetes/resource/helmrelease_test.go similarity index 76% rename from cluster/kubernetes/resource/fluxhelmrelease_test.go rename to cluster/kubernetes/resource/helmrelease_test.go index 2ded990d07..ee424c6d76 100644 --- a/cluster/kubernetes/resource/fluxhelmrelease_test.go +++ b/cluster/kubernetes/resource/helmrelease_test.go @@ -8,17 +8,20 @@ import ( ) func TestParseImageOnlyFormat(t *testing.T) { - expectedImage := "bitnami/mariadb:10.1.30-r1" + expectedImage := "bitnami/ghost:1.21.5-r0" doc := `--- -apiVersion: helm.integrations.flux.weave.works/v1alpha2 -kind: FluxHelmRelease +apiVersion: helm.fluxcd.io/v1 +kind: HelmRelease metadata: - name: mariadb - namespace: maria + name: ghost + namespace: ghost labels: - chart: mariadb + chart: ghost spec: - chartGitPath: mariadb + chart: + git: git@github.com:fluxcd/flux-get-started + ref: master + path: charts/ghost values: first: post image: ` + expectedImage + ` @@ -30,16 +33,16 @@ spec: if err != nil { t.Fatal(err) } - res, ok := resources["maria:fluxhelmrelease/mariadb"] + res, ok := resources["ghost:helmrelease/ghost"] if !ok { t.Fatalf("expected resource not found; instead got %#v", resources) } - fhr, ok := res.(resource.Workload) + hr, ok := res.(resource.Workload) if !ok { t.Fatalf("expected resource to be a Workload, instead got %#v", res) } - containers := fhr.Containers() + containers := hr.Containers() if len(containers) != 1 { t.Errorf("expected 1 container; got %#v", containers) } @@ -50,20 +53,23 @@ spec: } func TestParseImageTagFormat(t *testing.T) { - expectedImageName := "bitnami/mariadb" - expectedImageTag := "10.1.30-r1" + expectedImageName := "bitnami/ghost" + expectedImageTag := "1.21.5-r0" expectedImage := expectedImageName + ":" + expectedImageTag doc := `--- -apiVersion: helm.integrations.flux.weave.works/v1alpha2 -kind: FluxHelmRelease +apiVersion: helm.fluxcd.io/v1 +kind: HelmRelease metadata: - name: mariadb - namespace: maria + name: ghost + namespace: ghost labels: - chart: mariadb + chart: ghost spec: - chartGitPath: mariadb + chart: + git: git@github.com:fluxcd/flux-get-started + ref: master + path: charts/ghostb values: first: post image: ` + expectedImageName + ` @@ -76,16 +82,16 @@ spec: if err != nil { t.Fatal(err) } - res, ok := resources["maria:fluxhelmrelease/mariadb"] + res, ok := resources["ghost:helmrelease/ghost"] if !ok { t.Fatalf("expected resource not found; instead got %#v", resources) } - fhr, ok := res.(resource.Workload) + hr, ok := res.(resource.Workload) if !ok { t.Fatalf("expected resource to be a Workload, instead got %#v", res) } - containers := fhr.Containers() + containers := hr.Containers() if len(containers) != 1 { t.Errorf("expected 1 container; got %#v", containers) } @@ -97,18 +103,23 @@ spec: func TestParseRegistryImageTagFormat(t *testing.T) { expectedRegistry := "registry.com" - expectedImageName := "bitnami/mariadb" - expectedImageTag := "10.1.30-r1" + expectedImageName := "bitnami/ghost" + expectedImageTag := "1.21.5-r0" expectedImage := expectedRegistry + "/" + expectedImageName + ":" + expectedImageTag doc := `--- -apiVersion: helm.integrations.flux.weave.works/v1alpha2 -kind: FluxHelmRelease +apiVersion: helm.fluxcd.io/v1 +kind: HelmRelease metadata: - name: mariadb - namespace: maria + name: ghost + namespace: ghost labels: - chart: mariadb + chart: ghost +spec: + chart: + git: git@github.com:fluxcd/flux-get-started + ref: master + path: charts/ghost spec: chartGitPath: mariadb values: @@ -124,16 +135,16 @@ spec: if err != nil { t.Fatal(err) } - res, ok := resources["maria:fluxhelmrelease/mariadb"] + res, ok := resources["ghost:helmrelease/ghost"] if !ok { t.Fatalf("expected resource not found; instead got %#v", resources) } - fhr, ok := res.(resource.Workload) + hr, ok := res.(resource.Workload) if !ok { t.Fatalf("expected resource to be a Workload, instead got %#v", res) } - containers := fhr.Containers() + containers := hr.Containers() if len(containers) != 1 { t.Errorf("expected 1 container; got %#v", containers) } @@ -145,17 +156,22 @@ spec: func TestParseRegistryImageFormat(t *testing.T) { expectedRegistry := "registry.com" - expectedImageName := "bitnami/mariadb:10.1.30-r1" + expectedImageName := "bitnami/ghost:1.21.5-r0" expectedImage := expectedRegistry + "/" + expectedImageName doc := `--- -apiVersion: helm.integrations.flux.weave.works/v1alpha2 -kind: FluxHelmRelease +apiVersion: helm.fluxcd.io/v1 +kind: HelmRelease metadata: - name: mariadb - namespace: maria + name: ghost + namespace: ghost labels: - chart: mariadb + chart: ghost +spec: + chart: + git: git@github.com:fluxcd/flux-get-started + ref: master + path: charts/ghost spec: chartGitPath: mariadb values: @@ -170,16 +186,16 @@ spec: if err != nil { t.Fatal(err) } - res, ok := resources["maria:fluxhelmrelease/mariadb"] + res, ok := resources["ghost:helmrelease/ghost"] if !ok { t.Fatalf("expected resource not found; instead got %#v", resources) } - fhr, ok := res.(resource.Workload) + hr, ok := res.(resource.Workload) if !ok { t.Fatalf("expected resource to be a Workload, instead got %#v", res) } - containers := fhr.Containers() + containers := hr.Containers() if len(containers) != 1 { t.Errorf("expected 1 container; got %#v", containers) } @@ -191,15 +207,20 @@ spec: func TestParseNamedImageFormat(t *testing.T) { expectedContainer := "db" - expectedImage := "bitnami/mariadb:10.1.30-r1" + expectedImage := "bitnami/ghost:1.21.5-r0" doc := `--- -apiVersion: helm.integrations.flux.weave.works/v1alpha2 -kind: FluxHelmRelease +apiVersion: helm.fluxcd.io/v1 +kind: HelmRelease metadata: - name: mariadb - namespace: maria + name: ghost + namespace: ghost labels: - chart: mariadb + chart: ghost +spec: + chart: + git: git@github.com:fluxcd/flux-get-started + ref: master + path: charts/ghost spec: chartGitPath: mariadb values: @@ -214,16 +235,16 @@ spec: if err != nil { t.Fatal(err) } - res, ok := resources["maria:fluxhelmrelease/mariadb"] + res, ok := resources["ghost:helmrelease/ghost"] if !ok { t.Fatalf("expected resource not found; instead got %#v", resources) } - fhr, ok := res.(resource.Workload) + hr, ok := res.(resource.Workload) if !ok { t.Fatalf("expected resource to be a Workload, instead got %#v", res) } - containers := fhr.Containers() + containers := hr.Containers() if len(containers) != 1 { t.Fatalf("expected 1 container; got %#v", containers) } @@ -236,11 +257,11 @@ spec: } newImage := containers[0].Image.WithNewTag("some-other-tag") - if err := fhr.SetContainerImage(expectedContainer, newImage); err != nil { + if err := hr.SetContainerImage(expectedContainer, newImage); err != nil { t.Error(err) } - containers = fhr.Containers() + containers = hr.Containers() if len(containers) != 1 { t.Fatalf("expected 1 container; got %#v", containers) } @@ -255,18 +276,23 @@ spec: func TestParseNamedImageTagFormat(t *testing.T) { expectedContainer := "db" - expectedImageName := "bitnami/mariadb" - expectedImageTag := "10.1.30-r1" + expectedImageName := "bitnami/ghost" + expectedImageTag := "1.21.5-r0" expectedImage := expectedImageName + ":" + expectedImageTag doc := `--- -apiVersion: helm.integrations.flux.weave.works/v1alpha2 -kind: FluxHelmRelease +apiVersion: helm.fluxcd.io/v1 +kind: HelmRelease metadata: - name: mariadb - namespace: maria + name: ghost + namespace: ghost labels: - chart: mariadb + chart: ghost +spec: + chart: + git: git@github.com:fluxcd/flux-get-started + ref: master + path: charts/ghost spec: chartGitPath: mariadb values: @@ -284,16 +310,16 @@ spec: if err != nil { t.Fatal(err) } - res, ok := resources["maria:fluxhelmrelease/mariadb"] + res, ok := resources["ghost:helmrelease/ghost"] if !ok { t.Fatalf("expected resource not found; instead got %#v", resources) } - fhr, ok := res.(resource.Workload) + hr, ok := res.(resource.Workload) if !ok { t.Fatalf("expected resource to be a Workload, instead got %#v", res) } - containers := fhr.Containers() + containers := hr.Containers() if len(containers) != 1 { t.Fatalf("expected 1 container; got %#v", containers) } @@ -306,11 +332,11 @@ spec: } newImage := containers[0].Image.WithNewTag("some-other-tag") - if err := fhr.SetContainerImage(expectedContainer, newImage); err != nil { + if err := hr.SetContainerImage(expectedContainer, newImage); err != nil { t.Error(err) } - containers = fhr.Containers() + containers = hr.Containers() if len(containers) != 1 { t.Fatalf("expected 1 container; got %#v", containers) } @@ -326,18 +352,23 @@ spec: func TestParseNamedRegistryImageTagFormat(t *testing.T) { expectedContainer := "db" expectedRegistry := "registry.com" - expectedImageName := "bitnami/mariadb" - expectedImageTag := "10.1.30-r1" + expectedImageName := "bitnami/ghost" + expectedImageTag := "1.21.5-r0" expectedImage := expectedRegistry + "/" + expectedImageName + ":" + expectedImageTag doc := `--- -apiVersion: helm.integrations.flux.weave.works/v1alpha2 -kind: FluxHelmRelease +apiVersion: helm.fluxcd.io/v1 +kind: HelmRelease metadata: - name: mariadb - namespace: maria + name: ghost + namespace: ghost labels: - chart: mariadb + chart: ghost +spec: + chart: + git: git@github.com:fluxcd/flux-get-started + ref: master + path: charts/ghost spec: chartGitPath: mariadb values: @@ -356,16 +387,16 @@ spec: if err != nil { t.Fatal(err) } - res, ok := resources["maria:fluxhelmrelease/mariadb"] + res, ok := resources["ghost:helmrelease/ghost"] if !ok { t.Fatalf("expected resource not found; instead got %#v", resources) } - fhr, ok := res.(resource.Workload) + hr, ok := res.(resource.Workload) if !ok { t.Fatalf("expected resource to be a Workload, instead got %#v", res) } - containers := fhr.Containers() + containers := hr.Containers() if len(containers) != 1 { t.Fatalf("expected 1 container; got %#v", containers) } @@ -379,11 +410,11 @@ spec: newImage := containers[0].Image.WithNewTag("some-other-tag") newImage.Domain = "someotherregistry.com" - if err := fhr.SetContainerImage(expectedContainer, newImage); err != nil { + if err := hr.SetContainerImage(expectedContainer, newImage); err != nil { t.Error(err) } - containers = fhr.Containers() + containers = hr.Containers() if len(containers) != 1 { t.Fatalf("expected 1 container; got %#v", containers) } @@ -399,19 +430,22 @@ spec: func TestParseNamedRegistryImageFormat(t *testing.T) { expectedContainer := "db" expectedRegistry := "registry.com" - expectedImageName := "bitnami/mariadb:10.1.30-r1" + expectedImageName := "bitnami/ghost:1.21.5-r0" expectedImage := expectedRegistry + "/" + expectedImageName doc := `--- -apiVersion: helm.integrations.flux.weave.works/v1alpha2 -kind: FluxHelmRelease +apiVersion: helm.fluxcd.io/v1 +kind: HelmRelease metadata: - name: mariadb - namespace: maria + name: ghost + namespace: ghost labels: - chart: mariadb + chart: ghost spec: - chartGitPath: mariadb + chart: + git: git@github.com:fluxcd/flux-get-started + ref: master + path: charts/ghost values: other: not: "containing image" @@ -427,16 +461,16 @@ spec: if err != nil { t.Fatal(err) } - res, ok := resources["maria:fluxhelmrelease/mariadb"] + res, ok := resources["ghost:helmrelease/ghost"] if !ok { t.Fatalf("expected resource not found; instead got %#v", resources) } - fhr, ok := res.(resource.Workload) + hr, ok := res.(resource.Workload) if !ok { t.Fatalf("expected resource to be a Workload, instead got %#v", res) } - containers := fhr.Containers() + containers := hr.Containers() if len(containers) != 1 { t.Fatalf("expected 1 container; got %#v", containers) } @@ -450,11 +484,11 @@ spec: newImage := containers[0].Image.WithNewTag("some-other-tag") newImage.Domain = "someotherregistry.com" - if err := fhr.SetContainerImage(expectedContainer, newImage); err != nil { + if err := hr.SetContainerImage(expectedContainer, newImage); err != nil { t.Error(err) } - containers = fhr.Containers() + containers = hr.Containers() if len(containers) != 1 { t.Fatalf("expected 1 container; got %#v", containers) } @@ -468,20 +502,23 @@ spec: } func TestParseImageObjectFormat(t *testing.T) { - expectedImageName := "bitnami/mariadb" - expectedImageTag := "10.1.30-r1" + expectedImageName := "bitnami/ghost" + expectedImageTag := "1.21.5-r0" expectedImage := expectedImageName + ":" + expectedImageTag doc := `--- -apiVersion: helm.integrations.flux.weave.works/v1alpha2 -kind: FluxHelmRelease +apiVersion: helm.fluxcd.io/v1 +kind: HelmRelease metadata: - name: mariadb - namespace: maria + name: ghost + namespace: ghost labels: - chart: mariadb + chart: ghost spec: - chartGitPath: mariadb + chart: + git: git@github.com:fluxcd/flux-get-started + ref: master + path: charts/ghost values: first: post image: @@ -495,16 +532,16 @@ spec: if err != nil { t.Fatal(err) } - res, ok := resources["maria:fluxhelmrelease/mariadb"] + res, ok := resources["ghost:helmrelease/ghost"] if !ok { t.Fatalf("expected resource not found; instead got %#v", resources) } - fhr, ok := res.(resource.Workload) + hr, ok := res.(resource.Workload) if !ok { t.Fatalf("expected resource to be a Workload, instead got %#v", res) } - containers := fhr.Containers() + containers := hr.Containers() if len(containers) != 1 { t.Errorf("expected 1 container; got %#v", containers) } @@ -516,20 +553,23 @@ spec: func TestParseNamedImageObjectFormat(t *testing.T) { expectedContainer := "db" - expectedImageName := "bitnami/mariadb" - expectedImageTag := "10.1.30-r1" + expectedImageName := "bitnami/ghost" + expectedImageTag := "1.21.5-r0" expectedImage := expectedImageName + ":" + expectedImageTag doc := `--- -apiVersion: helm.integrations.flux.weave.works/v1alpha2 -kind: FluxHelmRelease +apiVersion: helm.fluxcd.io/v1 +kind: HelmRelease metadata: - name: mariadb - namespace: maria + name: ghost + namespace: ghost labels: - chart: mariadb + chart: ghost spec: - chartGitPath: mariadb + chart: + git: git@github.com:fluxcd/flux-get-started + ref: master + path: charts/ghost values: other: not: "containing image" @@ -546,16 +586,16 @@ spec: if err != nil { t.Fatal(err) } - res, ok := resources["maria:fluxhelmrelease/mariadb"] + res, ok := resources["ghost:helmrelease/ghost"] if !ok { t.Fatalf("expected resource not found; instead got %#v", resources) } - fhr, ok := res.(resource.Workload) + hr, ok := res.(resource.Workload) if !ok { t.Fatalf("expected resource to be a Workload, instead got %#v", res) } - containers := fhr.Containers() + containers := hr.Containers() if len(containers) != 1 { t.Fatalf("expected 1 container; got %#v", containers) } @@ -568,11 +608,11 @@ spec: } newImage := containers[0].Image.WithNewTag("some-other-tag") - if err := fhr.SetContainerImage(expectedContainer, newImage); err != nil { + if err := hr.SetContainerImage(expectedContainer, newImage); err != nil { t.Error(err) } - containers = fhr.Containers() + containers = hr.Containers() if len(containers) != 1 { t.Fatalf("expected 1 container; got %#v", containers) } @@ -588,20 +628,23 @@ spec: func TestParseNamedImageObjectFormatWithRegistry(t *testing.T) { expectedContainer := "db" expectedRegistry := "registry.com" - expectedImageName := "bitnami/mariadb" - expectedImageTag := "10.1.30-r1" + expectedImageName := "bitnami/ghost" + expectedImageTag := "1.21.5-r0" expectedImage := expectedRegistry + "/" + expectedImageName + ":" + expectedImageTag doc := `--- -apiVersion: helm.integrations.flux.weave.works/v1alpha2 -kind: FluxHelmRelease +apiVersion: helm.fluxcd.io/v1 +kind: HelmRelease metadata: - name: mariadb - namespace: maria + name: ghost + namespace: ghost labels: - chart: mariadb + chart: ghost spec: - chartGitPath: mariadb + chart: + git: git@github.com:fluxcd/flux-get-started + ref: master + path: charts/ghost values: other: not: "containing image" @@ -619,16 +662,16 @@ spec: if err != nil { t.Fatal(err) } - res, ok := resources["maria:fluxhelmrelease/mariadb"] + res, ok := resources["ghost:helmrelease/ghost"] if !ok { t.Fatalf("expected resource not found; instead got %#v", resources) } - fhr, ok := res.(resource.Workload) + hr, ok := res.(resource.Workload) if !ok { t.Fatalf("expected resource to be a Workload, instead got %#v", res) } - containers := fhr.Containers() + containers := hr.Containers() if len(containers) != 1 { t.Fatalf("expected 1 container; got %#v", containers) } @@ -642,11 +685,11 @@ spec: newImage := containers[0].Image.WithNewTag("some-other-tag") newImage.Domain = "someotherregistry.com" - if err := fhr.SetContainerImage(expectedContainer, newImage); err != nil { + if err := hr.SetContainerImage(expectedContainer, newImage); err != nil { t.Error(err) } - containers = fhr.Containers() + containers = hr.Containers() if len(containers) != 1 { t.Fatalf("expected 1 container; got %#v", containers) } @@ -662,19 +705,22 @@ spec: func TestParseNamedImageObjectFormatWithRegistryWitoutTag(t *testing.T) { expectedContainer := "db" expectedRegistry := "registry.com" - expectedImageName := "bitnami/mariadb:10.1.30-r1" + expectedImageName := "bitnami/ghost:1.21.5-r0" expectedImage := expectedRegistry + "/" + expectedImageName doc := `--- -apiVersion: helm.integrations.flux.weave.works/v1alpha2 -kind: FluxHelmRelease +apiVersion: helm.fluxcd.io/v1 +kind: HelmRelease metadata: - name: mariadb - namespace: maria + name: ghost + namespace: ghost labels: - chart: mariadb + chart: ghost spec: - chartGitPath: mariadb + chart: + git: git@github.com:fluxcd/flux-get-started + ref: master + path: charts/ghost values: other: not: "containing image" @@ -691,16 +737,16 @@ spec: if err != nil { t.Fatal(err) } - res, ok := resources["maria:fluxhelmrelease/mariadb"] + res, ok := resources["ghost:helmrelease/ghost"] if !ok { t.Fatalf("expected resource not found; instead got %#v", resources) } - fhr, ok := res.(resource.Workload) + hr, ok := res.(resource.Workload) if !ok { t.Fatalf("expected resource to be a Workload, instead got %#v", res) } - containers := fhr.Containers() + containers := hr.Containers() if len(containers) != 1 { t.Fatalf("expected 1 container; got %#v", containers) } @@ -714,11 +760,11 @@ spec: newImage := containers[0].Image.WithNewTag("some-other-tag") newImage.Domain = "someotherregistry.com" - if err := fhr.SetContainerImage(expectedContainer, newImage); err != nil { + if err := hr.SetContainerImage(expectedContainer, newImage); err != nil { t.Error(err) } - containers = fhr.Containers() + containers = hr.Containers() if len(containers) != 1 { t.Fatalf("expected 1 container; got %#v", containers) } @@ -753,13 +799,16 @@ func TestParseAllFormatsInOne(t *testing.T) { } doc := `--- -apiVersion: helm.integrations.flux.weave.works/v1alpha2 -kind: FluxHelmRelease +apiVersion: helm.fluxcd.io/v1 +kind: HelmRelease metadata: name: test namespace: test spec: - chartGitPath: test + chart: + git: git@github.com:fluxcd/flux-get-started + ref: master + path: charts/ghost values: # top-level image image: ` + expected[0].image + ":" + expected[0].tag + ` @@ -802,16 +851,16 @@ spec: if err != nil { t.Fatal(err) } - res, ok := resources["test:fluxhelmrelease/test"] + res, ok := resources["test:helmrelease/test"] if !ok { t.Fatalf("expected resource not found; instead got %#v", resources) } - fhr, ok := res.(resource.Workload) + hr, ok := res.(resource.Workload) if !ok { t.Fatalf("expected resource to be a Workload, instead got %#v", res) } - containers := fhr.Containers() + containers := hr.Containers() if len(containers) != len(expected) { t.Fatalf("expected %d containers, got %d", len(expected), len(containers)) } diff --git a/cluster/kubernetes/resource/resource.go b/cluster/kubernetes/resource/resource.go index 8031042748..cb8b358492 100644 --- a/cluster/kubernetes/resource/resource.go +++ b/cluster/kubernetes/resource/resource.go @@ -197,11 +197,11 @@ func unmarshalKind(base baseObject, bytes []byte) (KubeManifest, error) { unmarshalList(base, &raw, &list) return &list, nil case base.Kind == "FluxHelmRelease" || base.Kind == "HelmRelease": - var fhr = FluxHelmRelease{baseObject: base} - if err := yaml.Unmarshal(bytes, &fhr); err != nil { + var hr = HelmRelease{baseObject: base} + if err := yaml.Unmarshal(bytes, &hr); err != nil { return nil, err } - return &fhr, nil + return &hr, nil case base.Kind == "": // If there is an empty resource (due to eg an introduced comment), // we are returning nil for the resource and nil for an error diff --git a/cluster/kubernetes/resourcekinds.go b/cluster/kubernetes/resourcekinds.go index 0dd170b968..f133b89654 100644 --- a/cluster/kubernetes/resourcekinds.go +++ b/cluster/kubernetes/resourcekinds.go @@ -4,23 +4,24 @@ import ( "context" "strings" + hr_v1 "github.com/fluxcd/helm-operator/pkg/apis/helm.fluxcd.io/v1" apiapps "k8s.io/api/apps/v1" apibatch "k8s.io/api/batch/v1beta1" apiv1 "k8s.io/api/core/v1" - fhr_v1beta1 "github.com/fluxcd/helm-operator/pkg/apis/flux.weave.works/v1beta1" - fhr_v1alpha2 "github.com/fluxcd/helm-operator/pkg/apis/helm.integrations.flux.weave.works/v1alpha2" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/weaveworks/flux/cluster" kresource "github.com/weaveworks/flux/cluster/kubernetes/resource" "github.com/weaveworks/flux/image" + hr_v1beta1 "github.com/weaveworks/flux/integrations/apis/flux.weave.works/v1beta1" + fhr_v1alpha2 "github.com/weaveworks/flux/integrations/apis/helm.integrations.flux.weave.works/v1alpha2" "github.com/weaveworks/flux/policy" "github.com/weaveworks/flux/resource" ) // AntecedentAnnotation is an annotation on a resource indicating that // the cause of that resource (indirectly, via a Helm release) is a -// FluxHelmRelease. We use this rather than the `OwnerReference` type +// HelmRelease. We use this rather than the `OwnerReference` type // built into Kubernetes so that there are no garbage-collection // implications. The value is expected to be a serialised // `resource.ID`. @@ -402,7 +403,7 @@ func makeCronJobWorkload(cronJob *apibatch.CronJob) workload { } ///////////////////////////////////////////////////////////////////////////// -// helm.integrations.flux.weave.works/v1alpha2 FluxHelmRelease +// helm.integrations.flux.weave.works/v1alpha2 HelmRelease type fluxHelmReleaseKind struct{} @@ -435,7 +436,7 @@ func (fhr *fluxHelmReleaseKind) getWorkloads(ctx context.Context, c *Cluster, na } func makeFluxHelmReleaseWorkload(fluxHelmRelease *fhr_v1alpha2.FluxHelmRelease) workload { - containers := createK8sFHRContainers(fluxHelmRelease.Spec.Values) + containers := createK8sHRContainers(fluxHelmRelease.Spec.Values) podTemplate := apiv1.PodTemplateSpec{ ObjectMeta: fluxHelmRelease.ObjectMeta, @@ -446,7 +447,7 @@ func makeFluxHelmReleaseWorkload(fluxHelmRelease *fhr_v1alpha2.FluxHelmRelease) } // apiVersion & kind must be set, since TypeMeta is not populated fluxHelmRelease.APIVersion = "helm.integrations.flux.weave.works/v1alpha2" - fluxHelmRelease.Kind = "FluxHelmRelease" + fluxHelmRelease.Kind = "HelmRelease" return workload{ status: fluxHelmRelease.Status.ReleaseStatus, podTemplate: podTemplate, @@ -455,11 +456,11 @@ func makeFluxHelmReleaseWorkload(fluxHelmRelease *fhr_v1alpha2.FluxHelmRelease) } // createK8sContainers creates a list of k8s containers by -// interpreting the FluxHelmRelease resource. The interpretation is +// interpreting the HelmRelease resource. The interpretation is // analogous to that in cluster/kubernetes/resource/fluxhelmrelease.go -func createK8sFHRContainers(values map[string]interface{}) []apiv1.Container { +func createK8sHRContainers(values map[string]interface{}) []apiv1.Container { var containers []apiv1.Container - _ = kresource.FindFluxHelmReleaseContainers(values, func(name string, image image.Ref, _ kresource.ImageSetter) error { + _ = kresource.FindHelmReleaseContainers(values, func(name string, image image.Ref, _ kresource.ImageSetter) error { containers = append(containers, apiv1.Container{ Name: name, Image: image.String(), @@ -471,39 +472,66 @@ func createK8sFHRContainers(values map[string]interface{}) []apiv1.Container { ///////////////////////////////////////////////////////////////////////////// // flux.weave.works/v1beta1 HelmRelease +// flux.fluxcd.io/v1 HelmRelease type helmReleaseKind struct{} +// getWorkload attempts to resolve a HelmRelease, it does so by first +// requesting the v1 version, and falling back to v1beta1 if this gives +// no result. In case the latter also fails it returns the error. +// TODO(hidde): this creates a new problem, as it will always return +// the error for the v1beta1 resource. Which may not be accurate in +// case v1beta1 is not active in the cluster at all. One potential +// solution may be to collect both errors and see if one outweighs +// the other. func (hr *helmReleaseKind) getWorkload(ctx context.Context, c *Cluster, namespace, name string) (workload, error) { if err := ctx.Err(); err != nil { return workload{}, err } + if helmRelease, err := c.client.HelmV1().HelmReleases(name).Get(name, meta_v1.GetOptions{}); err == nil { + return makeHelmReleaseStableWorkload(helmRelease), err + } helmRelease, err := c.client.FluxV1beta1().HelmReleases(namespace).Get(name, meta_v1.GetOptions{}) if err != nil { return workload{}, err } - return makeHelmReleaseWorkload(helmRelease), nil + return makeHelmReleaseBetaWorkload(helmRelease), nil } +// getWorkloads collects v1 and v1beta1 HelmRelease workloads, if the +// same workload (by name) is found for two versions, only the v1 +// version is returned. This is so that the workload results returned +// by this method are always valid for `getWorkload` and return the +// same resource. +// TODO(hidde): again, the cost of backwards compatibility is silencing +// errors. func (hr *helmReleaseKind) getWorkloads(ctx context.Context, c *Cluster, namespace string) ([]workload, error) { if err := ctx.Err(); err != nil { return nil, err } - helmReleases, err := c.client.FluxV1beta1().HelmReleases(namespace).List(meta_v1.ListOptions{}) - if err != nil { - return nil, err - } - + var names map[string]bool var workloads []workload - for i, _ := range helmReleases.Items { - workloads = append(workloads, makeHelmReleaseWorkload(&helmReleases.Items[i])) + if helmReleases, err := c.client.HelmV1().HelmReleases(namespace).List(meta_v1.ListOptions{}); err == nil { + for i, _ := range helmReleases.Items { + workload := makeHelmReleaseStableWorkload(&helmReleases.Items[i]) + workloads = append(workloads, workload) + names[workload.GetName()] = true + } + } + if helmReleases, err := c.client.FluxV1beta1().HelmReleases(namespace).List(meta_v1.ListOptions{}); err == nil { + for i, _ := range helmReleases.Items { + workload := makeHelmReleaseBetaWorkload(&helmReleases.Items[i]) + if names[workload.GetName()] { + continue + } + workloads = append(workloads, workload) + } } - return workloads, nil } -func makeHelmReleaseWorkload(helmRelease *fhr_v1beta1.HelmRelease) workload { - containers := createK8sFHRContainers(helmRelease.Spec.Values) +func makeHelmReleaseBetaWorkload(helmRelease *hr_v1beta1.HelmRelease) workload { + containers := createK8sHRContainers(helmRelease.Spec.Values) podTemplate := apiv1.PodTemplateSpec{ ObjectMeta: helmRelease.ObjectMeta, @@ -521,3 +549,23 @@ func makeHelmReleaseWorkload(helmRelease *fhr_v1beta1.HelmRelease) workload { k8sObject: helmRelease, } } + +func makeHelmReleaseStableWorkload(helmRelease *hr_v1.HelmRelease) workload { + containers := createK8sHRContainers(helmRelease.Spec.Values) + + podTemplate := apiv1.PodTemplateSpec{ + ObjectMeta: helmRelease.ObjectMeta, + Spec: apiv1.PodSpec{ + Containers: containers, + ImagePullSecrets: []apiv1.LocalObjectReference{}, + }, + } + // apiVersion & kind must be set, since TypeMeta is not populated + helmRelease.APIVersion = "helm.fluxcd.io/v1" + helmRelease.Kind = "HelmRelease" + return workload{ + status: helmRelease.Status.ReleaseStatus, + podTemplate: podTemplate, + k8sObject: helmRelease, + } +} diff --git a/cluster/kubernetes/sync_test.go b/cluster/kubernetes/sync_test.go index 6210c8614d..f14bbdd121 100644 --- a/cluster/kubernetes/sync_test.go +++ b/cluster/kubernetes/sync_test.go @@ -7,12 +7,12 @@ import ( "strings" "testing" + helmopfake "github.com/fluxcd/helm-operator/pkg/client/clientset/versioned/fake" "github.com/ghodss/yaml" "github.com/go-kit/kit/log" "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" crdfake "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/fake" - fluxfake "github.com/fluxcd/helm-operator/pkg/client/clientset/versioned/fake" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" @@ -27,6 +27,7 @@ import ( "github.com/weaveworks/flux/cluster" kresource "github.com/weaveworks/flux/cluster/kubernetes/resource" + fhrfake "github.com/weaveworks/flux/integrations/client/clientset/versioned/fake" "github.com/weaveworks/flux/resource" "github.com/weaveworks/flux/sync" ) @@ -62,7 +63,8 @@ func fakeClients() (ExtendedClient, func()) { } coreClient := corefake.NewSimpleClientset(&corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: defaultTestNamespace}}) - fluxClient := fluxfake.NewSimpleClientset() + fhrClient := fhrfake.NewSimpleClientset() + hrClient := helmopfake.NewSimpleClientset() dynamicClient := dynamicfake.NewSimpleDynamicClient(scheme) crdClient := crdfake.NewSimpleClientset() shutdown := make(chan struct{}) @@ -75,7 +77,7 @@ func fakeClients() (ExtendedClient, func()) { coreClient.Fake.Resources = apiResources if debug { - for _, fake := range []*k8s_testing.Fake{&coreClient.Fake, &fluxClient.Fake, &dynamicClient.Fake} { + for _, fake := range []*k8s_testing.Fake{&coreClient.Fake, &fhrClient.Fake, &hrClient.Fake, &dynamicClient.Fake} { fake.PrependReactor("*", "*", func(action k8s_testing.Action) (bool, runtime.Object, error) { gvr := action.GetResource() fmt.Printf("[DEBUG] action: %s ns:%s %s/%s %s\n", action.GetVerb(), action.GetNamespace(), gvr.Group, gvr.Version, gvr.Resource) @@ -85,10 +87,11 @@ func fakeClients() (ExtendedClient, func()) { } ec := ExtendedClient{ - coreClient: coreClient, - fluxHelmClient: fluxClient, - dynamicClient: dynamicClient, - discoveryClient: discoveryClient, + coreClient: coreClient, + fluxHelmClient: fhrClient, + helmOperatorClient: hrClient, + dynamicClient: dynamicClient, + discoveryClient: discoveryClient, } return ec, func() { close(shutdown) } diff --git a/cluster/kubernetes/update_test.go b/cluster/kubernetes/update_test.go index f5ae8c8c9a..15aef62a5a 100644 --- a/cluster/kubernetes/update_test.go +++ b/cluster/kubernetes/update_test.go @@ -52,7 +52,8 @@ func TestUpdates(t *testing.T) { {"FluxHelmRelease (v1alpha2; simple image encoding)", case11resource, case11containers, case11image, case11, case11out}, {"FluxHelmRelease (v1alpha2; multi image encoding)", case12resource, case12containers, case12image, case12, case12out}, {"HelmRelease (v1beta1; image with port number)", case13resource, case13containers, case13image, case13, case13out}, - {"initContainer", case14resource, case14containers, case14image, case14, case14out}, + {"HelmRelease (v1)", case14resource, case14containers, case14image, case14, case14out}, + {"initContainer", case15resource, case15containers, case15image, case15, case15out}, } { t.Run(c.name, func(t *testing.T) { testUpdate(t, c) @@ -922,6 +923,55 @@ spec: ` const case14 = `--- +apiVersion: helm.fluxcd.io/v1 +kind: HelmRelease +metadata: + name: mariadb + namespace: maria +spec: + chart: + repository: https://example.com/charts + name: mariadb + version: 1.1.2 + values: + mariadb: + image: localhost/mariadb + tag: 10.1.30-r1 + persistence: + enabled: false + workProperly: true + sidecar: + image: sidecar:v1 +` + +const case14resource = "maria:helmrelease/mariadb" +const case14image = "localhost/mariadb:10.1.33" + +var case14containers = []string{"mariadb"} + +const case14out = `--- +apiVersion: helm.fluxcd.io/v1 +kind: HelmRelease +metadata: + name: mariadb + namespace: maria +spec: + chart: + repository: https://example.com/charts + name: mariadb + version: 1.1.2 + values: + mariadb: + image: localhost/mariadb + tag: 10.1.33 + persistence: + enabled: false + workProperly: true + sidecar: + image: sidecar:v1 +` + +const case15 = `--- apiVersion: extensions/v1beta1 kind: Deployment metadata: @@ -938,12 +988,12 @@ spec: image: 'weaveworks/weave-kube:2.2.0' ` -const case14resource = "default:deployment/weave" -const case14image = "weaveworks/weave-kube:2.2.1" +const case15resource = "default:deployment/weave" +const case15image = "weaveworks/weave-kube:2.2.1" -var case14containers = []string{"weave"} +var case15containers = []string{"weave"} -const case14out = `--- +const case15out = `--- apiVersion: extensions/v1beta1 kind: Deployment metadata: diff --git a/cmd/fluxd/main.go b/cmd/fluxd/main.go index 1306d046bd..54e88ae38a 100644 --- a/cmd/fluxd/main.go +++ b/cmd/fluxd/main.go @@ -16,11 +16,11 @@ import ( "syscall" "time" + helmopclient "github.com/fluxcd/helm-operator/pkg/client/clientset/versioned" "github.com/go-kit/kit/log" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/spf13/pflag" crd "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" - integrations "github.com/fluxcd/helm-operator/pkg/client/clientset/versioned" k8serrors "k8s.io/apimachinery/pkg/api/errors" k8sruntime "k8s.io/apimachinery/pkg/util/runtime" k8sclientdynamic "k8s.io/client-go/dynamic" @@ -39,6 +39,7 @@ import ( "github.com/weaveworks/flux/http/client" daemonhttp "github.com/weaveworks/flux/http/daemon" "github.com/weaveworks/flux/image" + hrclient "github.com/weaveworks/flux/integrations/client/clientset/versioned" "github.com/weaveworks/flux/job" "github.com/weaveworks/flux/manifests" "github.com/weaveworks/flux/registry" @@ -363,9 +364,15 @@ func main() { os.Exit(1) } - integrationsClientset, err := integrations.NewForConfig(restClientConfig) + fhrClientset, err := hrclient.NewForConfig(restClientConfig) if err != nil { - logger.Log("error", fmt.Sprintf("Error building integrations clientset: %v", err)) + logger.Log("error", fmt.Sprintf("Error building hrclient clientset: %v", err)) + os.Exit(1) + } + + hrClientset, err := helmopclient.NewForConfig(restClientConfig) + if err != nil { + logger.Log("error", fmt.Sprintf("Error building helm operator clientset: %v", err)) os.Exit(1) } @@ -427,7 +434,7 @@ func main() { } logger.Log("kubectl", kubectl) - client := kubernetes.MakeClusterClientset(clientset, dynamicClientset, integrationsClientset, discoClientset) + client := kubernetes.MakeClusterClientset(clientset, dynamicClientset, fhrClientset, hrClientset, discoClientset) kubectlApplier := kubernetes.NewKubectl(kubectl, restClientConfig) allowedNamespaces := append(*k8sNamespaceWhitelist, *k8sAllowNamespace...) k8sInst := kubernetes.NewCluster(client, kubectlApplier, sshKeyRing, logger, allowedNamespaces, *registryExcludeImage) diff --git a/go.mod b/go.mod index a16316b3ad..25400bec7e 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/bradfitz/gomemcache v0.0.0-20190329173943-551aad21a668 github.com/docker/distribution v0.0.0-00010101000000-000000000000 github.com/evanphx/json-patch v4.1.0+incompatible - github.com/fluxcd/helm-operator v0.0.0-20190806135400-402019a4607f + github.com/fluxcd/helm-operator v0.0.0-20190814123334-a25fa8de4c0a github.com/ghodss/yaml v1.0.0 github.com/go-kit/kit v0.9.0 github.com/golang/gddo v0.0.0-20190312205958-5a2505f3dbf0 @@ -16,7 +16,7 @@ require ( github.com/gorilla/mux v1.7.1 github.com/gorilla/websocket v1.4.0 github.com/imdario/mergo v0.3.7 - github.com/instrumenta/kubeval v0.0.0-20190720105720-70e32d660927 + github.com/instrumenta/kubeval v0.0.0-20190804145309-805845b47dfc github.com/justinbarrick/go-k8s-portforward v1.0.4-0.20190722134107-d79fe1b9d79d github.com/opencontainers/go-digest v1.0.0-rc1 github.com/opentracing-contrib/go-stdlib v0.0.0-20190519235532-cf7a6c988dc9 // indirect @@ -39,6 +39,7 @@ require ( k8s.io/apiextensions-apiserver v0.0.0-20190315093550-53c4693659ed k8s.io/apimachinery v0.0.0-20190404173353-6a84e37a896d k8s.io/client-go v11.0.0+incompatible + k8s.io/helm v2.13.1+incompatible k8s.io/klog v0.3.3 ) diff --git a/go.sum b/go.sum index bd78f84897..22b3f7cdf4 100644 --- a/go.sum +++ b/go.sum @@ -63,8 +63,8 @@ github.com/evanphx/json-patch v4.1.0+incompatible h1:K1MDoo4AZ4wU0GIU/fPmtZg7Vpz github.com/evanphx/json-patch v4.1.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fluxcd/helm-operator v0.0.0-20190806135400-402019a4607f h1:iqjej1opOBU/urytW+LhM2a+A4fZMdTs9ninMHXG7jo= -github.com/fluxcd/helm-operator v0.0.0-20190806135400-402019a4607f/go.mod h1:q6RV7Y/Igpw9lb7jz8NEkwCD6VxQMocuCcQeKFj1XwY= +github.com/fluxcd/helm-operator v0.0.0-20190814123334-a25fa8de4c0a h1:FJhntWBibmxfBa59foMJy7XyEU9AVl3PYPIS4vkRJ3A= +github.com/fluxcd/helm-operator v0.0.0-20190814123334-a25fa8de4c0a/go.mod h1:qBr+Yiqv9T2EjBsYzJNFQJ83b0ALM+aCJhxtPWyOP+E= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= @@ -164,6 +164,8 @@ github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NH github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/instrumenta/kubeval v0.0.0-20190720105720-70e32d660927 h1:r1cvxQYvoKyFHUbPpDRAJw4QRvfyWyR55cp3mS1fklc= github.com/instrumenta/kubeval v0.0.0-20190720105720-70e32d660927/go.mod h1:HeTbS2psckzaIy3V3lGbcCvSGP9f9MvrQV6s9IWGy0w= +github.com/instrumenta/kubeval v0.0.0-20190804145309-805845b47dfc h1:2wBB02X45LugTLC2M5DtxFCAOK4+jgeV4Gtx1lPZu+4= +github.com/instrumenta/kubeval v0.0.0-20190804145309-805845b47dfc/go.mod h1:bpiMYvNpVxWjdJsS0hDRu9TrobT5GfWCZwJseGUstxE= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/json-iterator/go v0.0.0-20180701071628-ab8a2e0c74be h1:AHimNtVIpiBjPUhEF5KNCkrUyqTSA5zWUl8sQ2bfGBE= diff --git a/install/install_test.go b/install/install_test.go index f12dfbc17a..f8a32c6f49 100644 --- a/install/install_test.go +++ b/install/install_test.go @@ -12,7 +12,7 @@ func testFillInTemplates(t *testing.T, params TemplateParameters) { assert.NoError(t, err) assert.Len(t, manifests, 5) for fileName, contents := range manifests { - validationResults, err := kubeval.Validate(contents, fileName) + validationResults, err := kubeval.Validate(contents) assert.NoError(t, err) for _, result := range validationResults { if len(result.Errors) > 0 { diff --git a/integrations/apis/flux.weave.works/register.go b/integrations/apis/flux.weave.works/register.go new file mode 100644 index 0000000000..050fc98a91 --- /dev/null +++ b/integrations/apis/flux.weave.works/register.go @@ -0,0 +1,5 @@ +package fluxintegrations + +const ( + GroupName = "flux.weave.works" +) diff --git a/integrations/apis/flux.weave.works/v1beta1/doc.go b/integrations/apis/flux.weave.works/v1beta1/doc.go new file mode 100644 index 0000000000..9c1abedfd2 --- /dev/null +++ b/integrations/apis/flux.weave.works/v1beta1/doc.go @@ -0,0 +1,10 @@ +// +k8s:deepcopy-gen=package,register +// +groupName=flux.weave.works +// Package v1beta1 is the v1beta1 version of the API. The prior +// version was helm.integrations.flux.weave.works/v1alpha2. +// +// This version has breaking changes, but since it is in a different +// API group entirely, it can coexist with the old version. You may +// need to take care to use the full kind (including the group) to +// refer to resources, e.g., `fluxhelmrelease.flux.weave.works`. +package v1beta1 diff --git a/integrations/apis/flux.weave.works/v1beta1/register.go b/integrations/apis/flux.weave.works/v1beta1/register.go new file mode 100644 index 0000000000..47165c1991 --- /dev/null +++ b/integrations/apis/flux.weave.works/v1beta1/register.go @@ -0,0 +1,42 @@ +package v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + + fluxintegrations "github.com/weaveworks/flux/integrations/apis/flux.weave.works" +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: fluxintegrations.GroupName, Version: "v1beta1"} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + // SchemeBuilder will stay in k8s.io/kubernetes. + SchemeBuilder runtime.SchemeBuilder + localSchemeBuilder = &SchemeBuilder + // AddToScheme will stay in k8s.io/kubernetes. + AddToScheme = localSchemeBuilder.AddToScheme +) + +func init() { + // We only register manually written functions here. The registration of the + // generated functions takes place in the generated files. The separation + // makes the code compile even when the generated files are missing. + localSchemeBuilder.Register(addKnownTypes) +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &HelmRelease{}, + &HelmReleaseList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/integrations/apis/flux.weave.works/v1beta1/types.go b/integrations/apis/flux.weave.works/v1beta1/types.go new file mode 100644 index 0000000000..c4fb83536a --- /dev/null +++ b/integrations/apis/flux.weave.works/v1beta1/types.go @@ -0,0 +1,299 @@ +package v1beta1 + +import ( + "fmt" + "strings" + + "github.com/ghodss/yaml" + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/helm/pkg/chartutil" + + "github.com/weaveworks/flux/resource" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// HelmRelease represents custom resource associated with a Helm Chart +type HelmRelease struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata"` + + Spec HelmReleaseSpec `json:"spec"` + Status HelmReleaseStatus `json:"status"` +} + +// ResourceID returns an ID made from the identifying parts of the +// resource, as a convenience for Flux, which uses them +// everywhere. +func (hr HelmRelease) ResourceID() resource.ID { + return resource.MakeID(hr.Namespace, "HelmRelease", hr.Name) +} + +// ReleaseName returns the configured release name, or constructs and +// returns one based on the namespace and name of the HelmRelease. +// When the HelmRelease's metadata.namespace and spec.targetNamespace +// differ, both are used in the generated name. +// This name is used for naming and operating on the release in Helm. +func (hr HelmRelease) ReleaseName() string { + if hr.Spec.ReleaseName == "" { + namespace := hr.GetDefaultedNamespace() + targetNamespace := hr.GetTargetNamespace() + + if namespace != targetNamespace { + // prefix the releaseName with the administering HelmRelease namespace as well + return fmt.Sprintf("%s-%s-%s", namespace, targetNamespace, hr.Name) + } + return fmt.Sprintf("%s-%s", targetNamespace, hr.Name) + } + + return hr.Spec.ReleaseName +} + +// GetDefaultedNamespace returns the HelmRelease's namespace +// defaulting to the "default" if not set. +func (hr HelmRelease) GetDefaultedNamespace() string { + if hr.GetNamespace() == "" { + return "default" + } + return hr.Namespace +} + +// GetTargetNamespace returns the configured release targetNamespace +// defaulting to the namespace of the HelmRelease if not set. +func (hr HelmRelease) GetTargetNamespace() string { + if hr.Spec.TargetNamespace == "" { + return hr.GetDefaultedNamespace() + } + return hr.Spec.TargetNamespace +} + +// ValuesFromSource represents a source of values. +// Only one of its fields may be set. +type ValuesFromSource struct { + // Selects a key of a ConfigMap. + // +optional + ConfigMapKeyRef *v1.ConfigMapKeySelector `json:"configMapKeyRef,omitempty"` + // Selects a key of a Secret. + // +optional + SecretKeyRef *v1.SecretKeySelector `json:"secretKeyRef,omitempty"` + // Selects an URL. + // +optional + ExternalSourceRef *ExternalSourceSelector `json:"externalSourceRef,omitempty"` + // Selects a file from git source helm chart. + // +optional + ChartFileRef *ChartFileSelector `json:"chartFileRef,omitempty"` +} + +type ChartFileSelector struct { + Path string `json:"path"` + // Do not fail if chart file could not be retrieved + // +optional + Optional *bool `json:"optional,omitempty"` +} + +type ExternalSourceSelector struct { + URL string `json:"url"` + // Do not fail if external source could not be retrieved + // +optional + Optional *bool `json:"optional,omitempty"` +} + +type ChartSource struct { + // one of the following... + // +optional + *GitChartSource + // +optional + *RepoChartSource +} + +type GitChartSource struct { + GitURL string `json:"git"` + Ref string `json:"ref"` + Path string `json:"path"` + // Do not run 'dep' update (assume requirements.yaml is already fulfilled) + // +optional + SkipDepUpdate bool `json:"skipDepUpdate,omitempty"` +} + +// DefaultGitRef is the ref assumed if the Ref field is not given in +// a GitChartSource +const DefaultGitRef = "master" + +func (s GitChartSource) RefOrDefault() string { + if s.Ref == "" { + return DefaultGitRef + } + return s.Ref +} + +type RepoChartSource struct { + RepoURL string `json:"repository"` + Name string `json:"name"` + Version string `json:"version"` + // An authentication secret for accessing the chart repo + // +optional + ChartPullSecret *v1.LocalObjectReference `json:"chartPullSecret,omitempty"` +} + +// CleanRepoURL returns the RepoURL but ensures it ends with a trailing slash +func (s RepoChartSource) CleanRepoURL() string { + cleanURL := strings.TrimRight(s.RepoURL, "/") + return cleanURL + "/" +} + +type Rollback struct { + Enable bool `json:"enable,omitempty"` + Force bool `json:"force,omitempty"` + Recreate bool `json:"recreate,omitempty"` + DisableHooks bool `json:"disableHooks,omitempty"` + Timeout *int64 `json:"timeout,omitempty"` + Wait bool `json:"wait,omitempty"` +} + +func (r Rollback) GetTimeout() int64 { + if r.Timeout == nil { + return 300 + } + return *r.Timeout +} + +// HelmReleaseSpec is the spec for a HelmRelease resource +type HelmReleaseSpec struct { + ChartSource `json:"chart"` + ReleaseName string `json:"releaseName,omitempty"` + ValueFileSecrets []v1.LocalObjectReference `json:"valueFileSecrets,omitempty"` + ValuesFrom []ValuesFromSource `json:"valuesFrom,omitempty"` + HelmValues `json:",inline"` + // Override the target namespace, defaults to metadata.namespace + // +optional + TargetNamespace string `json:"targetNamespace,omitempty"` + // Install or upgrade timeout in seconds + // +optional + Timeout *int64 `json:"timeout,omitempty"` + // Reset values on helm upgrade + // +optional + ResetValues bool `json:"resetValues,omitempty"` + // Force resource update through delete/recreate, allows recovery from a failed state + // +optional + ForceUpgrade bool `json:"forceUpgrade,omitempty"` + // Enable rollback and configure options + // +optional + Rollback Rollback `json:"rollback,omitempty"` +} + +// GetTimeout returns the install or upgrade timeout (defaults to 300s) +func (r HelmRelease) GetTimeout() int64 { + if r.Spec.Timeout == nil { + return 300 + } + return *r.Spec.Timeout +} + +// GetValuesFromSources maintains backwards compatibility with +// ValueFileSecrets by merging them into the ValuesFrom array. +func (r HelmRelease) GetValuesFromSources() []ValuesFromSource { + valuesFrom := r.Spec.ValuesFrom + // Maintain backwards compatibility with ValueFileSecrets + if r.Spec.ValueFileSecrets != nil { + var secretKeyRefs []ValuesFromSource + for _, ref := range r.Spec.ValueFileSecrets { + s := &v1.SecretKeySelector{LocalObjectReference: ref} + secretKeyRefs = append(secretKeyRefs, ValuesFromSource{SecretKeyRef: s}) + } + valuesFrom = append(secretKeyRefs, valuesFrom...) + } + return valuesFrom +} + +type HelmReleaseStatus struct { + // ReleaseName is the name as either supplied or generated. + // +optional + ReleaseName string `json:"releaseName"` + + // ReleaseStatus is the status as given by Helm for the release + // managed by this resource. + ReleaseStatus string `json:"releaseStatus"` + + // ObservedGeneration is the most recent generation observed by + // the controller. + ObservedGeneration int64 `json:"observedGeneration"` + + // ValuesChecksum holds the SHA256 checksum of the last applied + // values. + ValuesChecksum string `json:"valuesChecksum"` + + // Revision would define what Git hash or Chart version has currently + // been deployed. + // +optional + Revision string `json:"revision,omitempty"` + + // Conditions contains observations of the resource's state, e.g., + // has the chart which it refers to been fetched. + // +optional + // +patchMergeKey=type + // +patchStrategy=merge + Conditions []HelmReleaseCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"` +} + +type HelmReleaseCondition struct { + Type HelmReleaseConditionType `json:"type"` + Status v1.ConditionStatus `json:"status"` + // +optional + LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"` + // +optional + LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"` + // +optional + Reason string `json:"reason,omitempty"` + // +optional + Message string `json:"message,omitempty"` +} + +type HelmReleaseConditionType string + +const ( + // ChartFetched means the chart to which the HelmRelease refers + // has been fetched successfully + HelmReleaseChartFetched HelmReleaseConditionType = "ChartFetched" + // Released means the chart release, as specified in this + // HelmRelease, has been processed by Helm. + HelmReleaseReleased HelmReleaseConditionType = "Released" + // RolledBack means the chart to which the HelmRelease refers + // has been rolled back + HelmReleaseRolledBack HelmReleaseConditionType = "RolledBack" +) + +// FluxHelmValues embeds chartutil.Values so we can implement deepcopy on map[string]interface{} +// +k8s:deepcopy-gen=false +type HelmValues struct { + chartutil.Values `json:"values,omitempty"` +} + +// DeepCopyInto implements deepcopy-gen method for use in generated code +func (in *HelmValues) DeepCopyInto(out *HelmValues) { + if in == nil { + return + } + + b, err := yaml.Marshal(in.Values) + if err != nil { + return + } + var values chartutil.Values + err = yaml.Unmarshal(b, &values) + if err != nil { + return + } + out.Values = values +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// HelmReleaseList is a list of HelmRelease resources +type HelmReleaseList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []HelmRelease `json:"items"` +} diff --git a/integrations/apis/flux.weave.works/v1beta1/types_test.go b/integrations/apis/flux.weave.works/v1beta1/types_test.go new file mode 100644 index 0000000000..02ae0c9ccf --- /dev/null +++ b/integrations/apis/flux.weave.works/v1beta1/types_test.go @@ -0,0 +1,52 @@ +package v1beta1 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestHelmValues(t *testing.T) { + testCases := []struct { + original *HelmValues + transformer func(v *HelmValues) *HelmValues + expectedCopy *HelmValues + expectedOriginal *HelmValues + }{ + // reassignment + { + original: nil, + transformer: func(v *HelmValues) *HelmValues { + return &HelmValues{} + }, + expectedCopy: &HelmValues{}, + expectedOriginal: nil, + }, + // mutation + { + original: &HelmValues{Values: map[string]interface{}{}}, + transformer: func(v *HelmValues) *HelmValues { + v.Values["foo"] = "bar" + return v + }, + expectedCopy: &HelmValues{Values: map[string]interface{}{"foo": "bar"}}, + expectedOriginal: &HelmValues{Values: map[string]interface{}{}}, + }, + { + original: &HelmValues{Values: map[string]interface{}{"foo": map[string]interface{}{"bar": "baz"}}}, + transformer: func(v *HelmValues) *HelmValues { + v.Values["foo"] = map[string]interface{}{"bar": "oof"} + return v + }, + expectedCopy: &HelmValues{Values: map[string]interface{}{"foo": map[string]interface{}{"bar": "oof"}}}, + expectedOriginal: &HelmValues{Values: map[string]interface{}{"foo": map[string]interface{}{"bar": "baz"}}}, + }, + } + + for i, tc := range testCases { + output := &HelmValues{} + tc.original.DeepCopyInto(output) + assert.Exactly(t, tc.expectedCopy, tc.transformer(output), "copy was not mutated. test case: %d", i) + assert.Exactly(t, tc.expectedOriginal, tc.original, "original was mutated. test case: %d", i) + } +} diff --git a/integrations/apis/flux.weave.works/v1beta1/zz_generated.deepcopy.go b/integrations/apis/flux.weave.works/v1beta1/zz_generated.deepcopy.go new file mode 100644 index 0000000000..bf121d906c --- /dev/null +++ b/integrations/apis/flux.weave.works/v1beta1/zz_generated.deepcopy.go @@ -0,0 +1,326 @@ +// +build !ignore_autogenerated + +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1beta1 + +import ( + v1 "k8s.io/api/core/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ChartFileSelector) DeepCopyInto(out *ChartFileSelector) { + *out = *in + if in.Optional != nil { + in, out := &in.Optional, &out.Optional + *out = new(bool) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChartFileSelector. +func (in *ChartFileSelector) DeepCopy() *ChartFileSelector { + if in == nil { + return nil + } + out := new(ChartFileSelector) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ChartSource) DeepCopyInto(out *ChartSource) { + *out = *in + if in.GitChartSource != nil { + in, out := &in.GitChartSource, &out.GitChartSource + *out = new(GitChartSource) + **out = **in + } + if in.RepoChartSource != nil { + in, out := &in.RepoChartSource, &out.RepoChartSource + *out = new(RepoChartSource) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChartSource. +func (in *ChartSource) DeepCopy() *ChartSource { + if in == nil { + return nil + } + out := new(ChartSource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ExternalSourceSelector) DeepCopyInto(out *ExternalSourceSelector) { + *out = *in + if in.Optional != nil { + in, out := &in.Optional, &out.Optional + *out = new(bool) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExternalSourceSelector. +func (in *ExternalSourceSelector) DeepCopy() *ExternalSourceSelector { + if in == nil { + return nil + } + out := new(ExternalSourceSelector) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GitChartSource) DeepCopyInto(out *GitChartSource) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GitChartSource. +func (in *GitChartSource) DeepCopy() *GitChartSource { + if in == nil { + return nil + } + out := new(GitChartSource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HelmRelease) DeepCopyInto(out *HelmRelease) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmRelease. +func (in *HelmRelease) DeepCopy() *HelmRelease { + if in == nil { + return nil + } + out := new(HelmRelease) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *HelmRelease) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HelmReleaseCondition) DeepCopyInto(out *HelmReleaseCondition) { + *out = *in + in.LastUpdateTime.DeepCopyInto(&out.LastUpdateTime) + in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmReleaseCondition. +func (in *HelmReleaseCondition) DeepCopy() *HelmReleaseCondition { + if in == nil { + return nil + } + out := new(HelmReleaseCondition) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HelmReleaseList) DeepCopyInto(out *HelmReleaseList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]HelmRelease, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmReleaseList. +func (in *HelmReleaseList) DeepCopy() *HelmReleaseList { + if in == nil { + return nil + } + out := new(HelmReleaseList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *HelmReleaseList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HelmReleaseSpec) DeepCopyInto(out *HelmReleaseSpec) { + *out = *in + in.ChartSource.DeepCopyInto(&out.ChartSource) + if in.ValueFileSecrets != nil { + in, out := &in.ValueFileSecrets, &out.ValueFileSecrets + *out = make([]v1.LocalObjectReference, len(*in)) + copy(*out, *in) + } + if in.ValuesFrom != nil { + in, out := &in.ValuesFrom, &out.ValuesFrom + *out = make([]ValuesFromSource, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + in.HelmValues.DeepCopyInto(&out.HelmValues) + if in.Timeout != nil { + in, out := &in.Timeout, &out.Timeout + *out = new(int64) + **out = **in + } + in.Rollback.DeepCopyInto(&out.Rollback) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmReleaseSpec. +func (in *HelmReleaseSpec) DeepCopy() *HelmReleaseSpec { + if in == nil { + return nil + } + out := new(HelmReleaseSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HelmReleaseStatus) DeepCopyInto(out *HelmReleaseStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]HelmReleaseCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmReleaseStatus. +func (in *HelmReleaseStatus) DeepCopy() *HelmReleaseStatus { + if in == nil { + return nil + } + out := new(HelmReleaseStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RepoChartSource) DeepCopyInto(out *RepoChartSource) { + *out = *in + if in.ChartPullSecret != nil { + in, out := &in.ChartPullSecret, &out.ChartPullSecret + *out = new(v1.LocalObjectReference) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RepoChartSource. +func (in *RepoChartSource) DeepCopy() *RepoChartSource { + if in == nil { + return nil + } + out := new(RepoChartSource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Rollback) DeepCopyInto(out *Rollback) { + *out = *in + if in.Timeout != nil { + in, out := &in.Timeout, &out.Timeout + *out = new(int64) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Rollback. +func (in *Rollback) DeepCopy() *Rollback { + if in == nil { + return nil + } + out := new(Rollback) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ValuesFromSource) DeepCopyInto(out *ValuesFromSource) { + *out = *in + if in.ConfigMapKeyRef != nil { + in, out := &in.ConfigMapKeyRef, &out.ConfigMapKeyRef + *out = new(v1.ConfigMapKeySelector) + (*in).DeepCopyInto(*out) + } + if in.SecretKeyRef != nil { + in, out := &in.SecretKeyRef, &out.SecretKeyRef + *out = new(v1.SecretKeySelector) + (*in).DeepCopyInto(*out) + } + if in.ExternalSourceRef != nil { + in, out := &in.ExternalSourceRef, &out.ExternalSourceRef + *out = new(ExternalSourceSelector) + (*in).DeepCopyInto(*out) + } + if in.ChartFileRef != nil { + in, out := &in.ChartFileRef, &out.ChartFileRef + *out = new(ChartFileSelector) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ValuesFromSource. +func (in *ValuesFromSource) DeepCopy() *ValuesFromSource { + if in == nil { + return nil + } + out := new(ValuesFromSource) + in.DeepCopyInto(out) + return out +} diff --git a/integrations/apis/helm.integrations.flux.weave.works/register.go b/integrations/apis/helm.integrations.flux.weave.works/register.go new file mode 100644 index 0000000000..3904814b4a --- /dev/null +++ b/integrations/apis/helm.integrations.flux.weave.works/register.go @@ -0,0 +1,5 @@ +package fluxintegrations + +const ( + GroupName = "helm.integrations.flux.weave.works" +) diff --git a/integrations/apis/helm.integrations.flux.weave.works/v1alpha2/doc.go b/integrations/apis/helm.integrations.flux.weave.works/v1alpha2/doc.go new file mode 100644 index 0000000000..7a0d950141 --- /dev/null +++ b/integrations/apis/helm.integrations.flux.weave.works/v1alpha2/doc.go @@ -0,0 +1,5 @@ +// +k8s:deepcopy-gen=package,register + +// Package v1 is the v1 version of the API. +// +groupName=helm.integrations.flux.weave.works +package v1alpha2 diff --git a/integrations/apis/helm.integrations.flux.weave.works/v1alpha2/register.go b/integrations/apis/helm.integrations.flux.weave.works/v1alpha2/register.go new file mode 100644 index 0000000000..79b92c1b10 --- /dev/null +++ b/integrations/apis/helm.integrations.flux.weave.works/v1alpha2/register.go @@ -0,0 +1,42 @@ +package v1alpha2 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + + fluxintegrations "github.com/weaveworks/flux/integrations/apis/helm.integrations.flux.weave.works" +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: fluxintegrations.GroupName, Version: "v1alpha2"} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + // SchemeBuilder will stay in k8s.io/kubernetes. + SchemeBuilder runtime.SchemeBuilder + localSchemeBuilder = &SchemeBuilder + // AddToScheme will stay in k8s.io/kubernetes. + AddToScheme = localSchemeBuilder.AddToScheme +) + +func init() { + // We only register manually written functions here. The registration of the + // generated functions takes place in the generated files. The separation + // makes the code compile even when the generated files are missing. + localSchemeBuilder.Register(addKnownTypes) +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &FluxHelmRelease{}, + &FluxHelmReleaseList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/integrations/apis/helm.integrations.flux.weave.works/v1alpha2/types.go b/integrations/apis/helm.integrations.flux.weave.works/v1alpha2/types.go new file mode 100644 index 0000000000..e898cdfbcc --- /dev/null +++ b/integrations/apis/helm.integrations.flux.weave.works/v1alpha2/types.go @@ -0,0 +1,68 @@ +package v1alpha2 + +import ( + "github.com/ghodss/yaml" + "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/helm/pkg/chartutil" +) + +// +genclient +// +genclient:noStatus +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// FluxHelmRelease represents custom resource associated with a Helm Chart +type FluxHelmRelease struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata"` + + Spec FluxHelmReleaseSpec `json:"spec"` + Status FluxHelmReleaseStatus `json:"status"` +} + +// FluxHelmReleaseSpec is the spec for a FluxHelmRelease resource +// FluxHelmReleaseSpec +type FluxHelmReleaseSpec struct { + ChartGitPath string `json:"chartGitPath"` + ReleaseName string `json:"releaseName,omitempty"` + ValueFileSecrets []v1.LocalObjectReference `json:"valueFileSecrets,omitempty"` + FluxHelmValues `json:",inline"` +} + +type FluxHelmReleaseStatus struct { + ReleaseStatus string `json:"releaseStatus"` +} + +// FluxHelmValues embeds chartutil.Values so we can implement deepcopy on map[string]interface{} +// +k8s:deepcopy-gen=false +type FluxHelmValues struct { + chartutil.Values `json:"values,omitempty"` +} + +// DeepCopyInto implements deepcopy-gen method for use in generated code +func (in *FluxHelmValues) DeepCopyInto(out *FluxHelmValues) { + if in == nil { + return + } + + b, err := yaml.Marshal(in.Values) + if err != nil { + return + } + var values chartutil.Values + err = yaml.Unmarshal(b, &values) + if err != nil { + return + } + out.Values = values +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// FluxHelmReleaseList is a list of FluxHelmRelease resources +type FluxHelmReleaseList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []FluxHelmRelease `json:"items"` +} diff --git a/integrations/apis/helm.integrations.flux.weave.works/v1alpha2/types_test.go b/integrations/apis/helm.integrations.flux.weave.works/v1alpha2/types_test.go new file mode 100644 index 0000000000..2c9b668e38 --- /dev/null +++ b/integrations/apis/helm.integrations.flux.weave.works/v1alpha2/types_test.go @@ -0,0 +1,52 @@ +package v1alpha2 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestFluxHelmValues(t *testing.T) { + testCases := []struct { + original *FluxHelmValues + transformer func(v *FluxHelmValues) *FluxHelmValues + expectedCopy *FluxHelmValues + expectedOriginal *FluxHelmValues + }{ + // reassignment + { + original: nil, + transformer: func(v *FluxHelmValues) *FluxHelmValues { + return &FluxHelmValues{} + }, + expectedCopy: &FluxHelmValues{}, + expectedOriginal: nil, + }, + // mutation + { + original: &FluxHelmValues{Values: map[string]interface{}{}}, + transformer: func(v *FluxHelmValues) *FluxHelmValues { + v.Values["foo"] = "bar" + return v + }, + expectedCopy: &FluxHelmValues{Values: map[string]interface{}{"foo": "bar"}}, + expectedOriginal: &FluxHelmValues{Values: map[string]interface{}{}}, + }, + { + original: &FluxHelmValues{Values: map[string]interface{}{"foo": map[string]interface{}{"bar": "baz"}}}, + transformer: func(v *FluxHelmValues) *FluxHelmValues { + v.Values["foo"] = map[string]interface{}{"bar": "oof"} + return v + }, + expectedCopy: &FluxHelmValues{Values: map[string]interface{}{"foo": map[string]interface{}{"bar": "oof"}}}, + expectedOriginal: &FluxHelmValues{Values: map[string]interface{}{"foo": map[string]interface{}{"bar": "baz"}}}, + }, + } + + for i, tc := range testCases { + output := &FluxHelmValues{} + tc.original.DeepCopyInto(output) + assert.Exactly(t, tc.expectedCopy, tc.transformer(output), "copy was not mutated. test case: %d", i) + assert.Exactly(t, tc.expectedOriginal, tc.original, "original was mutated. test case: %d", i) + } +} diff --git a/integrations/apis/helm.integrations.flux.weave.works/v1alpha2/zz_generated.deepcopy.go b/integrations/apis/helm.integrations.flux.weave.works/v1alpha2/zz_generated.deepcopy.go new file mode 100644 index 0000000000..a1ac33d994 --- /dev/null +++ b/integrations/apis/helm.integrations.flux.weave.works/v1alpha2/zz_generated.deepcopy.go @@ -0,0 +1,125 @@ +// +build !ignore_autogenerated + +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + v1 "k8s.io/api/core/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FluxHelmRelease) DeepCopyInto(out *FluxHelmRelease) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FluxHelmRelease. +func (in *FluxHelmRelease) DeepCopy() *FluxHelmRelease { + if in == nil { + return nil + } + out := new(FluxHelmRelease) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *FluxHelmRelease) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FluxHelmReleaseList) DeepCopyInto(out *FluxHelmReleaseList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]FluxHelmRelease, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FluxHelmReleaseList. +func (in *FluxHelmReleaseList) DeepCopy() *FluxHelmReleaseList { + if in == nil { + return nil + } + out := new(FluxHelmReleaseList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *FluxHelmReleaseList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FluxHelmReleaseSpec) DeepCopyInto(out *FluxHelmReleaseSpec) { + *out = *in + if in.ValueFileSecrets != nil { + in, out := &in.ValueFileSecrets, &out.ValueFileSecrets + *out = make([]v1.LocalObjectReference, len(*in)) + copy(*out, *in) + } + in.FluxHelmValues.DeepCopyInto(&out.FluxHelmValues) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FluxHelmReleaseSpec. +func (in *FluxHelmReleaseSpec) DeepCopy() *FluxHelmReleaseSpec { + if in == nil { + return nil + } + out := new(FluxHelmReleaseSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FluxHelmReleaseStatus) DeepCopyInto(out *FluxHelmReleaseStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FluxHelmReleaseStatus. +func (in *FluxHelmReleaseStatus) DeepCopy() *FluxHelmReleaseStatus { + if in == nil { + return nil + } + out := new(FluxHelmReleaseStatus) + in.DeepCopyInto(out) + return out +} diff --git a/integrations/client/clientset/versioned/clientset.go b/integrations/client/clientset/versioned/clientset.go new file mode 100644 index 0000000000..010d737d56 --- /dev/null +++ b/integrations/client/clientset/versioned/clientset.go @@ -0,0 +1,104 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package versioned + +import ( + fluxv1beta1 "github.com/weaveworks/flux/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1" + helmv1alpha2 "github.com/weaveworks/flux/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2" + discovery "k8s.io/client-go/discovery" + rest "k8s.io/client-go/rest" + flowcontrol "k8s.io/client-go/util/flowcontrol" +) + +type Interface interface { + Discovery() discovery.DiscoveryInterface + FluxV1beta1() fluxv1beta1.FluxV1beta1Interface + HelmV1alpha2() helmv1alpha2.HelmV1alpha2Interface +} + +// Clientset contains the clients for groups. Each group has exactly one +// version included in a Clientset. +type Clientset struct { + *discovery.DiscoveryClient + fluxV1beta1 *fluxv1beta1.FluxV1beta1Client + helmV1alpha2 *helmv1alpha2.HelmV1alpha2Client +} + +// FluxV1beta1 retrieves the FluxV1beta1Client +func (c *Clientset) FluxV1beta1() fluxv1beta1.FluxV1beta1Interface { + return c.fluxV1beta1 +} + +// HelmV1alpha2 retrieves the HelmV1alpha2Client +func (c *Clientset) HelmV1alpha2() helmv1alpha2.HelmV1alpha2Interface { + return c.helmV1alpha2 +} + +// Discovery retrieves the DiscoveryClient +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + if c == nil { + return nil + } + return c.DiscoveryClient +} + +// NewForConfig creates a new Clientset for the given config. +func NewForConfig(c *rest.Config) (*Clientset, error) { + configShallowCopy := *c + if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { + configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) + } + var cs Clientset + var err error + cs.fluxV1beta1, err = fluxv1beta1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } + cs.helmV1alpha2, err = helmv1alpha2.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } + + cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) + if err != nil { + return nil, err + } + return &cs, nil +} + +// NewForConfigOrDie creates a new Clientset for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *Clientset { + var cs Clientset + cs.fluxV1beta1 = fluxv1beta1.NewForConfigOrDie(c) + cs.helmV1alpha2 = helmv1alpha2.NewForConfigOrDie(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) + return &cs +} + +// New creates a new Clientset for the given RESTClient. +func New(c rest.Interface) *Clientset { + var cs Clientset + cs.fluxV1beta1 = fluxv1beta1.New(c) + cs.helmV1alpha2 = helmv1alpha2.New(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClient(c) + return &cs +} diff --git a/integrations/client/clientset/versioned/doc.go b/integrations/client/clientset/versioned/doc.go new file mode 100644 index 0000000000..ccada3242c --- /dev/null +++ b/integrations/client/clientset/versioned/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated clientset. +package versioned diff --git a/integrations/client/clientset/versioned/fake/clientset_generated.go b/integrations/client/clientset/versioned/fake/clientset_generated.go new file mode 100644 index 0000000000..3b345f9cd2 --- /dev/null +++ b/integrations/client/clientset/versioned/fake/clientset_generated.go @@ -0,0 +1,84 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + clientset "github.com/weaveworks/flux/integrations/client/clientset/versioned" + fluxv1beta1 "github.com/weaveworks/flux/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1" + fakefluxv1beta1 "github.com/weaveworks/flux/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/fake" + helmv1alpha2 "github.com/weaveworks/flux/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2" + fakehelmv1alpha2 "github.com/weaveworks/flux/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/fake" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/discovery" + fakediscovery "k8s.io/client-go/discovery/fake" + "k8s.io/client-go/testing" +) + +// NewSimpleClientset returns a clientset that will respond with the provided objects. +// It's backed by a very simple object tracker that processes creates, updates and deletions as-is, +// without applying any validations and/or defaults. It shouldn't be considered a replacement +// for a real clientset and is mostly useful in simple unit tests. +func NewSimpleClientset(objects ...runtime.Object) *Clientset { + o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder()) + for _, obj := range objects { + if err := o.Add(obj); err != nil { + panic(err) + } + } + + cs := &Clientset{} + cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake} + cs.AddReactor("*", "*", testing.ObjectReaction(o)) + cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) { + gvr := action.GetResource() + ns := action.GetNamespace() + watch, err := o.Watch(gvr, ns) + if err != nil { + return false, nil, err + } + return true, watch, nil + }) + + return cs +} + +// Clientset implements clientset.Interface. Meant to be embedded into a +// struct to get a default implementation. This makes faking out just the method +// you want to test easier. +type Clientset struct { + testing.Fake + discovery *fakediscovery.FakeDiscovery +} + +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + return c.discovery +} + +var _ clientset.Interface = &Clientset{} + +// FluxV1beta1 retrieves the FluxV1beta1Client +func (c *Clientset) FluxV1beta1() fluxv1beta1.FluxV1beta1Interface { + return &fakefluxv1beta1.FakeFluxV1beta1{Fake: &c.Fake} +} + +// HelmV1alpha2 retrieves the HelmV1alpha2Client +func (c *Clientset) HelmV1alpha2() helmv1alpha2.HelmV1alpha2Interface { + return &fakehelmv1alpha2.FakeHelmV1alpha2{Fake: &c.Fake} +} diff --git a/integrations/client/clientset/versioned/fake/doc.go b/integrations/client/clientset/versioned/fake/doc.go new file mode 100644 index 0000000000..616d74179a --- /dev/null +++ b/integrations/client/clientset/versioned/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated fake clientset. +package fake diff --git a/integrations/client/clientset/versioned/fake/register.go b/integrations/client/clientset/versioned/fake/register.go new file mode 100644 index 0000000000..7873866041 --- /dev/null +++ b/integrations/client/clientset/versioned/fake/register.go @@ -0,0 +1,58 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + fluxv1beta1 "github.com/weaveworks/flux/integrations/apis/flux.weave.works/v1beta1" + helmv1alpha2 "github.com/weaveworks/flux/integrations/apis/helm.integrations.flux.weave.works/v1alpha2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" +) + +var scheme = runtime.NewScheme() +var codecs = serializer.NewCodecFactory(scheme) +var parameterCodec = runtime.NewParameterCodec(scheme) +var localSchemeBuilder = runtime.SchemeBuilder{ + fluxv1beta1.AddToScheme, + helmv1alpha2.AddToScheme, +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) + utilruntime.Must(AddToScheme(scheme)) +} diff --git a/integrations/client/clientset/versioned/scheme/doc.go b/integrations/client/clientset/versioned/scheme/doc.go new file mode 100644 index 0000000000..3de8cc2eaf --- /dev/null +++ b/integrations/client/clientset/versioned/scheme/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package contains the scheme of the automatically generated clientset. +package scheme diff --git a/integrations/client/clientset/versioned/scheme/register.go b/integrations/client/clientset/versioned/scheme/register.go new file mode 100644 index 0000000000..43b98f7e5a --- /dev/null +++ b/integrations/client/clientset/versioned/scheme/register.go @@ -0,0 +1,58 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package scheme + +import ( + fluxv1beta1 "github.com/weaveworks/flux/integrations/apis/flux.weave.works/v1beta1" + helmv1alpha2 "github.com/weaveworks/flux/integrations/apis/helm.integrations.flux.weave.works/v1alpha2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" +) + +var Scheme = runtime.NewScheme() +var Codecs = serializer.NewCodecFactory(Scheme) +var ParameterCodec = runtime.NewParameterCodec(Scheme) +var localSchemeBuilder = runtime.SchemeBuilder{ + fluxv1beta1.AddToScheme, + helmv1alpha2.AddToScheme, +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) + utilruntime.Must(AddToScheme(Scheme)) +} diff --git a/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/doc.go b/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/doc.go new file mode 100644 index 0000000000..eae31cb792 --- /dev/null +++ b/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1beta1 diff --git a/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/fake/doc.go b/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/fake/doc.go new file mode 100644 index 0000000000..c13844a4df --- /dev/null +++ b/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/fake/fake_flux.weave.works_client.go b/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/fake/fake_flux.weave.works_client.go new file mode 100644 index 0000000000..c68f07f5c5 --- /dev/null +++ b/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/fake/fake_flux.weave.works_client.go @@ -0,0 +1,40 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1beta1 "github.com/weaveworks/flux/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeFluxV1beta1 struct { + *testing.Fake +} + +func (c *FakeFluxV1beta1) HelmReleases(namespace string) v1beta1.HelmReleaseInterface { + return &FakeHelmReleases{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeFluxV1beta1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/fake/fake_helmrelease.go b/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/fake/fake_helmrelease.go new file mode 100644 index 0000000000..130923d9d5 --- /dev/null +++ b/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/fake/fake_helmrelease.go @@ -0,0 +1,140 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1beta1 "github.com/weaveworks/flux/integrations/apis/flux.weave.works/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeHelmReleases implements HelmReleaseInterface +type FakeHelmReleases struct { + Fake *FakeFluxV1beta1 + ns string +} + +var helmreleasesResource = schema.GroupVersionResource{Group: "flux.weave.works", Version: "v1beta1", Resource: "helmreleases"} + +var helmreleasesKind = schema.GroupVersionKind{Group: "flux.weave.works", Version: "v1beta1", Kind: "HelmRelease"} + +// Get takes name of the helmRelease, and returns the corresponding helmRelease object, and an error if there is any. +func (c *FakeHelmReleases) Get(name string, options v1.GetOptions) (result *v1beta1.HelmRelease, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(helmreleasesResource, c.ns, name), &v1beta1.HelmRelease{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.HelmRelease), err +} + +// List takes label and field selectors, and returns the list of HelmReleases that match those selectors. +func (c *FakeHelmReleases) List(opts v1.ListOptions) (result *v1beta1.HelmReleaseList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(helmreleasesResource, helmreleasesKind, c.ns, opts), &v1beta1.HelmReleaseList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta1.HelmReleaseList{ListMeta: obj.(*v1beta1.HelmReleaseList).ListMeta} + for _, item := range obj.(*v1beta1.HelmReleaseList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested helmReleases. +func (c *FakeHelmReleases) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(helmreleasesResource, c.ns, opts)) + +} + +// Create takes the representation of a helmRelease and creates it. Returns the server's representation of the helmRelease, and an error, if there is any. +func (c *FakeHelmReleases) Create(helmRelease *v1beta1.HelmRelease) (result *v1beta1.HelmRelease, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(helmreleasesResource, c.ns, helmRelease), &v1beta1.HelmRelease{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.HelmRelease), err +} + +// Update takes the representation of a helmRelease and updates it. Returns the server's representation of the helmRelease, and an error, if there is any. +func (c *FakeHelmReleases) Update(helmRelease *v1beta1.HelmRelease) (result *v1beta1.HelmRelease, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(helmreleasesResource, c.ns, helmRelease), &v1beta1.HelmRelease{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.HelmRelease), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeHelmReleases) UpdateStatus(helmRelease *v1beta1.HelmRelease) (*v1beta1.HelmRelease, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(helmreleasesResource, "status", c.ns, helmRelease), &v1beta1.HelmRelease{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.HelmRelease), err +} + +// Delete takes name of the helmRelease and deletes it. Returns an error if one occurs. +func (c *FakeHelmReleases) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(helmreleasesResource, c.ns, name), &v1beta1.HelmRelease{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeHelmReleases) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(helmreleasesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1beta1.HelmReleaseList{}) + return err +} + +// Patch applies the patch and returns the patched helmRelease. +func (c *FakeHelmReleases) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.HelmRelease, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(helmreleasesResource, c.ns, name, pt, data, subresources...), &v1beta1.HelmRelease{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.HelmRelease), err +} diff --git a/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/flux.weave.works_client.go b/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/flux.weave.works_client.go new file mode 100644 index 0000000000..3759740ca6 --- /dev/null +++ b/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/flux.weave.works_client.go @@ -0,0 +1,90 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1beta1 + +import ( + v1beta1 "github.com/weaveworks/flux/integrations/apis/flux.weave.works/v1beta1" + "github.com/weaveworks/flux/integrations/client/clientset/versioned/scheme" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + rest "k8s.io/client-go/rest" +) + +type FluxV1beta1Interface interface { + RESTClient() rest.Interface + HelmReleasesGetter +} + +// FluxV1beta1Client is used to interact with features provided by the flux.weave.works group. +type FluxV1beta1Client struct { + restClient rest.Interface +} + +func (c *FluxV1beta1Client) HelmReleases(namespace string) HelmReleaseInterface { + return newHelmReleases(c, namespace) +} + +// NewForConfig creates a new FluxV1beta1Client for the given config. +func NewForConfig(c *rest.Config) (*FluxV1beta1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &FluxV1beta1Client{client}, nil +} + +// NewForConfigOrDie creates a new FluxV1beta1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *FluxV1beta1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new FluxV1beta1Client for the given RESTClient. +func New(c rest.Interface) *FluxV1beta1Client { + return &FluxV1beta1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1beta1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs} + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FluxV1beta1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/generated_expansion.go b/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/generated_expansion.go new file mode 100644 index 0000000000..ce3536ace7 --- /dev/null +++ b/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1beta1 + +type HelmReleaseExpansion interface{} diff --git a/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/helmrelease.go b/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/helmrelease.go new file mode 100644 index 0000000000..bd81cd27eb --- /dev/null +++ b/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/helmrelease.go @@ -0,0 +1,191 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "time" + + v1beta1 "github.com/weaveworks/flux/integrations/apis/flux.weave.works/v1beta1" + scheme "github.com/weaveworks/flux/integrations/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// HelmReleasesGetter has a method to return a HelmReleaseInterface. +// A group's client should implement this interface. +type HelmReleasesGetter interface { + HelmReleases(namespace string) HelmReleaseInterface +} + +// HelmReleaseInterface has methods to work with HelmRelease resources. +type HelmReleaseInterface interface { + Create(*v1beta1.HelmRelease) (*v1beta1.HelmRelease, error) + Update(*v1beta1.HelmRelease) (*v1beta1.HelmRelease, error) + UpdateStatus(*v1beta1.HelmRelease) (*v1beta1.HelmRelease, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1beta1.HelmRelease, error) + List(opts v1.ListOptions) (*v1beta1.HelmReleaseList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.HelmRelease, err error) + HelmReleaseExpansion +} + +// helmReleases implements HelmReleaseInterface +type helmReleases struct { + client rest.Interface + ns string +} + +// newHelmReleases returns a HelmReleases +func newHelmReleases(c *FluxV1beta1Client, namespace string) *helmReleases { + return &helmReleases{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the helmRelease, and returns the corresponding helmRelease object, and an error if there is any. +func (c *helmReleases) Get(name string, options v1.GetOptions) (result *v1beta1.HelmRelease, err error) { + result = &v1beta1.HelmRelease{} + err = c.client.Get(). + Namespace(c.ns). + Resource("helmreleases"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of HelmReleases that match those selectors. +func (c *helmReleases) List(opts v1.ListOptions) (result *v1beta1.HelmReleaseList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.HelmReleaseList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("helmreleases"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested helmReleases. +func (c *helmReleases) Watch(opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("helmreleases"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a helmRelease and creates it. Returns the server's representation of the helmRelease, and an error, if there is any. +func (c *helmReleases) Create(helmRelease *v1beta1.HelmRelease) (result *v1beta1.HelmRelease, err error) { + result = &v1beta1.HelmRelease{} + err = c.client.Post(). + Namespace(c.ns). + Resource("helmreleases"). + Body(helmRelease). + Do(). + Into(result) + return +} + +// Update takes the representation of a helmRelease and updates it. Returns the server's representation of the helmRelease, and an error, if there is any. +func (c *helmReleases) Update(helmRelease *v1beta1.HelmRelease) (result *v1beta1.HelmRelease, err error) { + result = &v1beta1.HelmRelease{} + err = c.client.Put(). + Namespace(c.ns). + Resource("helmreleases"). + Name(helmRelease.Name). + Body(helmRelease). + Do(). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + +func (c *helmReleases) UpdateStatus(helmRelease *v1beta1.HelmRelease) (result *v1beta1.HelmRelease, err error) { + result = &v1beta1.HelmRelease{} + err = c.client.Put(). + Namespace(c.ns). + Resource("helmreleases"). + Name(helmRelease.Name). + SubResource("status"). + Body(helmRelease). + Do(). + Into(result) + return +} + +// Delete takes name of the helmRelease and deletes it. Returns an error if one occurs. +func (c *helmReleases) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("helmreleases"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *helmReleases) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + var timeout time.Duration + if listOptions.TimeoutSeconds != nil { + timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("helmreleases"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched helmRelease. +func (c *helmReleases) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.HelmRelease, err error) { + result = &v1beta1.HelmRelease{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("helmreleases"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/doc.go b/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/doc.go new file mode 100644 index 0000000000..36dbcad74f --- /dev/null +++ b/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha2 diff --git a/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/fake/doc.go b/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/fake/doc.go new file mode 100644 index 0000000000..c13844a4df --- /dev/null +++ b/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/fake/fake_fluxhelmrelease.go b/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/fake/fake_fluxhelmrelease.go new file mode 100644 index 0000000000..41afb74177 --- /dev/null +++ b/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/fake/fake_fluxhelmrelease.go @@ -0,0 +1,128 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha2 "github.com/weaveworks/flux/integrations/apis/helm.integrations.flux.weave.works/v1alpha2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeFluxHelmReleases implements FluxHelmReleaseInterface +type FakeFluxHelmReleases struct { + Fake *FakeHelmV1alpha2 + ns string +} + +var fluxhelmreleasesResource = schema.GroupVersionResource{Group: "helm.integrations.flux.weave.works", Version: "v1alpha2", Resource: "fluxhelmreleases"} + +var fluxhelmreleasesKind = schema.GroupVersionKind{Group: "helm.integrations.flux.weave.works", Version: "v1alpha2", Kind: "FluxHelmRelease"} + +// Get takes name of the fluxHelmRelease, and returns the corresponding fluxHelmRelease object, and an error if there is any. +func (c *FakeFluxHelmReleases) Get(name string, options v1.GetOptions) (result *v1alpha2.FluxHelmRelease, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(fluxhelmreleasesResource, c.ns, name), &v1alpha2.FluxHelmRelease{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.FluxHelmRelease), err +} + +// List takes label and field selectors, and returns the list of FluxHelmReleases that match those selectors. +func (c *FakeFluxHelmReleases) List(opts v1.ListOptions) (result *v1alpha2.FluxHelmReleaseList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(fluxhelmreleasesResource, fluxhelmreleasesKind, c.ns, opts), &v1alpha2.FluxHelmReleaseList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha2.FluxHelmReleaseList{ListMeta: obj.(*v1alpha2.FluxHelmReleaseList).ListMeta} + for _, item := range obj.(*v1alpha2.FluxHelmReleaseList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested fluxHelmReleases. +func (c *FakeFluxHelmReleases) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(fluxhelmreleasesResource, c.ns, opts)) + +} + +// Create takes the representation of a fluxHelmRelease and creates it. Returns the server's representation of the fluxHelmRelease, and an error, if there is any. +func (c *FakeFluxHelmReleases) Create(fluxHelmRelease *v1alpha2.FluxHelmRelease) (result *v1alpha2.FluxHelmRelease, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(fluxhelmreleasesResource, c.ns, fluxHelmRelease), &v1alpha2.FluxHelmRelease{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.FluxHelmRelease), err +} + +// Update takes the representation of a fluxHelmRelease and updates it. Returns the server's representation of the fluxHelmRelease, and an error, if there is any. +func (c *FakeFluxHelmReleases) Update(fluxHelmRelease *v1alpha2.FluxHelmRelease) (result *v1alpha2.FluxHelmRelease, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(fluxhelmreleasesResource, c.ns, fluxHelmRelease), &v1alpha2.FluxHelmRelease{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.FluxHelmRelease), err +} + +// Delete takes name of the fluxHelmRelease and deletes it. Returns an error if one occurs. +func (c *FakeFluxHelmReleases) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(fluxhelmreleasesResource, c.ns, name), &v1alpha2.FluxHelmRelease{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeFluxHelmReleases) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(fluxhelmreleasesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha2.FluxHelmReleaseList{}) + return err +} + +// Patch applies the patch and returns the patched fluxHelmRelease. +func (c *FakeFluxHelmReleases) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha2.FluxHelmRelease, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(fluxhelmreleasesResource, c.ns, name, pt, data, subresources...), &v1alpha2.FluxHelmRelease{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.FluxHelmRelease), err +} diff --git a/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/fake/fake_helm.integrations.flux.weave.works_client.go b/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/fake/fake_helm.integrations.flux.weave.works_client.go new file mode 100644 index 0000000000..45826fc4bf --- /dev/null +++ b/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/fake/fake_helm.integrations.flux.weave.works_client.go @@ -0,0 +1,40 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha2 "github.com/weaveworks/flux/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeHelmV1alpha2 struct { + *testing.Fake +} + +func (c *FakeHelmV1alpha2) FluxHelmReleases(namespace string) v1alpha2.FluxHelmReleaseInterface { + return &FakeFluxHelmReleases{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeHelmV1alpha2) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/fluxhelmrelease.go b/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/fluxhelmrelease.go new file mode 100644 index 0000000000..98728757ce --- /dev/null +++ b/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/fluxhelmrelease.go @@ -0,0 +1,174 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + "time" + + v1alpha2 "github.com/weaveworks/flux/integrations/apis/helm.integrations.flux.weave.works/v1alpha2" + scheme "github.com/weaveworks/flux/integrations/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// FluxHelmReleasesGetter has a method to return a FluxHelmReleaseInterface. +// A group's client should implement this interface. +type FluxHelmReleasesGetter interface { + FluxHelmReleases(namespace string) FluxHelmReleaseInterface +} + +// FluxHelmReleaseInterface has methods to work with FluxHelmRelease resources. +type FluxHelmReleaseInterface interface { + Create(*v1alpha2.FluxHelmRelease) (*v1alpha2.FluxHelmRelease, error) + Update(*v1alpha2.FluxHelmRelease) (*v1alpha2.FluxHelmRelease, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha2.FluxHelmRelease, error) + List(opts v1.ListOptions) (*v1alpha2.FluxHelmReleaseList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha2.FluxHelmRelease, err error) + FluxHelmReleaseExpansion +} + +// fluxHelmReleases implements FluxHelmReleaseInterface +type fluxHelmReleases struct { + client rest.Interface + ns string +} + +// newFluxHelmReleases returns a FluxHelmReleases +func newFluxHelmReleases(c *HelmV1alpha2Client, namespace string) *fluxHelmReleases { + return &fluxHelmReleases{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the fluxHelmRelease, and returns the corresponding fluxHelmRelease object, and an error if there is any. +func (c *fluxHelmReleases) Get(name string, options v1.GetOptions) (result *v1alpha2.FluxHelmRelease, err error) { + result = &v1alpha2.FluxHelmRelease{} + err = c.client.Get(). + Namespace(c.ns). + Resource("fluxhelmreleases"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of FluxHelmReleases that match those selectors. +func (c *fluxHelmReleases) List(opts v1.ListOptions) (result *v1alpha2.FluxHelmReleaseList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha2.FluxHelmReleaseList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("fluxhelmreleases"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested fluxHelmReleases. +func (c *fluxHelmReleases) Watch(opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("fluxhelmreleases"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a fluxHelmRelease and creates it. Returns the server's representation of the fluxHelmRelease, and an error, if there is any. +func (c *fluxHelmReleases) Create(fluxHelmRelease *v1alpha2.FluxHelmRelease) (result *v1alpha2.FluxHelmRelease, err error) { + result = &v1alpha2.FluxHelmRelease{} + err = c.client.Post(). + Namespace(c.ns). + Resource("fluxhelmreleases"). + Body(fluxHelmRelease). + Do(). + Into(result) + return +} + +// Update takes the representation of a fluxHelmRelease and updates it. Returns the server's representation of the fluxHelmRelease, and an error, if there is any. +func (c *fluxHelmReleases) Update(fluxHelmRelease *v1alpha2.FluxHelmRelease) (result *v1alpha2.FluxHelmRelease, err error) { + result = &v1alpha2.FluxHelmRelease{} + err = c.client.Put(). + Namespace(c.ns). + Resource("fluxhelmreleases"). + Name(fluxHelmRelease.Name). + Body(fluxHelmRelease). + Do(). + Into(result) + return +} + +// Delete takes name of the fluxHelmRelease and deletes it. Returns an error if one occurs. +func (c *fluxHelmReleases) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("fluxhelmreleases"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *fluxHelmReleases) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + var timeout time.Duration + if listOptions.TimeoutSeconds != nil { + timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("fluxhelmreleases"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched fluxHelmRelease. +func (c *fluxHelmReleases) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha2.FluxHelmRelease, err error) { + result = &v1alpha2.FluxHelmRelease{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("fluxhelmreleases"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/generated_expansion.go b/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/generated_expansion.go new file mode 100644 index 0000000000..d1237ad0f7 --- /dev/null +++ b/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha2 + +type FluxHelmReleaseExpansion interface{} diff --git a/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/helm.integrations.flux.weave.works_client.go b/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/helm.integrations.flux.weave.works_client.go new file mode 100644 index 0000000000..24ea6e781b --- /dev/null +++ b/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha2/helm.integrations.flux.weave.works_client.go @@ -0,0 +1,90 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + v1alpha2 "github.com/weaveworks/flux/integrations/apis/helm.integrations.flux.weave.works/v1alpha2" + "github.com/weaveworks/flux/integrations/client/clientset/versioned/scheme" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + rest "k8s.io/client-go/rest" +) + +type HelmV1alpha2Interface interface { + RESTClient() rest.Interface + FluxHelmReleasesGetter +} + +// HelmV1alpha2Client is used to interact with features provided by the helm.integrations.flux.weave.works group. +type HelmV1alpha2Client struct { + restClient rest.Interface +} + +func (c *HelmV1alpha2Client) FluxHelmReleases(namespace string) FluxHelmReleaseInterface { + return newFluxHelmReleases(c, namespace) +} + +// NewForConfig creates a new HelmV1alpha2Client for the given config. +func NewForConfig(c *rest.Config) (*HelmV1alpha2Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &HelmV1alpha2Client{client}, nil +} + +// NewForConfigOrDie creates a new HelmV1alpha2Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *HelmV1alpha2Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new HelmV1alpha2Client for the given RESTClient. +func New(c rest.Interface) *HelmV1alpha2Client { + return &HelmV1alpha2Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha2.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs} + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *HelmV1alpha2Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/integrations/client/informers/externalversions/factory.go b/integrations/client/informers/externalversions/factory.go new file mode 100644 index 0000000000..78037cdb39 --- /dev/null +++ b/integrations/client/informers/externalversions/factory.go @@ -0,0 +1,186 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package externalversions + +import ( + reflect "reflect" + sync "sync" + time "time" + + versioned "github.com/weaveworks/flux/integrations/client/clientset/versioned" + fluxweaveworks "github.com/weaveworks/flux/integrations/client/informers/externalversions/flux.weave.works" + helmintegrationsfluxweaveworks "github.com/weaveworks/flux/integrations/client/informers/externalversions/helm.integrations.flux.weave.works" + internalinterfaces "github.com/weaveworks/flux/integrations/client/informers/externalversions/internalinterfaces" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" +) + +// SharedInformerOption defines the functional option type for SharedInformerFactory. +type SharedInformerOption func(*sharedInformerFactory) *sharedInformerFactory + +type sharedInformerFactory struct { + client versioned.Interface + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc + lock sync.Mutex + defaultResync time.Duration + customResync map[reflect.Type]time.Duration + + informers map[reflect.Type]cache.SharedIndexInformer + // startedInformers is used for tracking which informers have been started. + // This allows Start() to be called multiple times safely. + startedInformers map[reflect.Type]bool +} + +// WithCustomResyncConfig sets a custom resync period for the specified informer types. +func WithCustomResyncConfig(resyncConfig map[v1.Object]time.Duration) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + for k, v := range resyncConfig { + factory.customResync[reflect.TypeOf(k)] = v + } + return factory + } +} + +// WithTweakListOptions sets a custom filter on all listers of the configured SharedInformerFactory. +func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.tweakListOptions = tweakListOptions + return factory + } +} + +// WithNamespace limits the SharedInformerFactory to the specified namespace. +func WithNamespace(namespace string) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.namespace = namespace + return factory + } +} + +// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces. +func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory { + return NewSharedInformerFactoryWithOptions(client, defaultResync) +} + +// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory. +// Listers obtained via this SharedInformerFactory will be subject to the same filters +// as specified here. +// Deprecated: Please use NewSharedInformerFactoryWithOptions instead +func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory { + return NewSharedInformerFactoryWithOptions(client, defaultResync, WithNamespace(namespace), WithTweakListOptions(tweakListOptions)) +} + +// NewSharedInformerFactoryWithOptions constructs a new instance of a SharedInformerFactory with additional options. +func NewSharedInformerFactoryWithOptions(client versioned.Interface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory { + factory := &sharedInformerFactory{ + client: client, + namespace: v1.NamespaceAll, + defaultResync: defaultResync, + informers: make(map[reflect.Type]cache.SharedIndexInformer), + startedInformers: make(map[reflect.Type]bool), + customResync: make(map[reflect.Type]time.Duration), + } + + // Apply all options + for _, opt := range options { + factory = opt(factory) + } + + return factory +} + +// Start initializes all requested informers. +func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) { + f.lock.Lock() + defer f.lock.Unlock() + + for informerType, informer := range f.informers { + if !f.startedInformers[informerType] { + go informer.Run(stopCh) + f.startedInformers[informerType] = true + } + } +} + +// WaitForCacheSync waits for all started informers' cache were synced. +func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool { + informers := func() map[reflect.Type]cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informers := map[reflect.Type]cache.SharedIndexInformer{} + for informerType, informer := range f.informers { + if f.startedInformers[informerType] { + informers[informerType] = informer + } + } + return informers + }() + + res := map[reflect.Type]bool{} + for informType, informer := range informers { + res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced) + } + return res +} + +// InternalInformerFor returns the SharedIndexInformer for obj using an internal +// client. +func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informerType := reflect.TypeOf(obj) + informer, exists := f.informers[informerType] + if exists { + return informer + } + + resyncPeriod, exists := f.customResync[informerType] + if !exists { + resyncPeriod = f.defaultResync + } + + informer = newFunc(f.client, resyncPeriod) + f.informers[informerType] = informer + + return informer +} + +// SharedInformerFactory provides shared informers for resources in all known +// API group versions. +type SharedInformerFactory interface { + internalinterfaces.SharedInformerFactory + ForResource(resource schema.GroupVersionResource) (GenericInformer, error) + WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool + + Flux() fluxweaveworks.Interface + Helm() helmintegrationsfluxweaveworks.Interface +} + +func (f *sharedInformerFactory) Flux() fluxweaveworks.Interface { + return fluxweaveworks.New(f, f.namespace, f.tweakListOptions) +} + +func (f *sharedInformerFactory) Helm() helmintegrationsfluxweaveworks.Interface { + return helmintegrationsfluxweaveworks.New(f, f.namespace, f.tweakListOptions) +} diff --git a/integrations/client/informers/externalversions/flux.weave.works/interface.go b/integrations/client/informers/externalversions/flux.weave.works/interface.go new file mode 100644 index 0000000000..e58d9c2d96 --- /dev/null +++ b/integrations/client/informers/externalversions/flux.weave.works/interface.go @@ -0,0 +1,46 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package flux + +import ( + v1beta1 "github.com/weaveworks/flux/integrations/client/informers/externalversions/flux.weave.works/v1beta1" + internalinterfaces "github.com/weaveworks/flux/integrations/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1beta1 provides access to shared informers for resources in V1beta1. + V1beta1() v1beta1.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1beta1 returns a new v1beta1.Interface. +func (g *group) V1beta1() v1beta1.Interface { + return v1beta1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/integrations/client/informers/externalversions/flux.weave.works/v1beta1/helmrelease.go b/integrations/client/informers/externalversions/flux.weave.works/v1beta1/helmrelease.go new file mode 100644 index 0000000000..86555f2af2 --- /dev/null +++ b/integrations/client/informers/externalversions/flux.weave.works/v1beta1/helmrelease.go @@ -0,0 +1,89 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1beta1 + +import ( + time "time" + + fluxweaveworksv1beta1 "github.com/weaveworks/flux/integrations/apis/flux.weave.works/v1beta1" + versioned "github.com/weaveworks/flux/integrations/client/clientset/versioned" + internalinterfaces "github.com/weaveworks/flux/integrations/client/informers/externalversions/internalinterfaces" + v1beta1 "github.com/weaveworks/flux/integrations/client/listers/flux.weave.works/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// HelmReleaseInformer provides access to a shared informer and lister for +// HelmReleases. +type HelmReleaseInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1beta1.HelmReleaseLister +} + +type helmReleaseInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewHelmReleaseInformer constructs a new informer for HelmRelease type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewHelmReleaseInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredHelmReleaseInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredHelmReleaseInformer constructs a new informer for HelmRelease type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredHelmReleaseInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.FluxV1beta1().HelmReleases(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.FluxV1beta1().HelmReleases(namespace).Watch(options) + }, + }, + &fluxweaveworksv1beta1.HelmRelease{}, + resyncPeriod, + indexers, + ) +} + +func (f *helmReleaseInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredHelmReleaseInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *helmReleaseInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&fluxweaveworksv1beta1.HelmRelease{}, f.defaultInformer) +} + +func (f *helmReleaseInformer) Lister() v1beta1.HelmReleaseLister { + return v1beta1.NewHelmReleaseLister(f.Informer().GetIndexer()) +} diff --git a/integrations/client/informers/externalversions/flux.weave.works/v1beta1/interface.go b/integrations/client/informers/externalversions/flux.weave.works/v1beta1/interface.go new file mode 100644 index 0000000000..db575bbf9a --- /dev/null +++ b/integrations/client/informers/externalversions/flux.weave.works/v1beta1/interface.go @@ -0,0 +1,45 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1beta1 + +import ( + internalinterfaces "github.com/weaveworks/flux/integrations/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // HelmReleases returns a HelmReleaseInformer. + HelmReleases() HelmReleaseInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// HelmReleases returns a HelmReleaseInformer. +func (v *version) HelmReleases() HelmReleaseInformer { + return &helmReleaseInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/integrations/client/informers/externalversions/generic.go b/integrations/client/informers/externalversions/generic.go new file mode 100644 index 0000000000..f2056f1607 --- /dev/null +++ b/integrations/client/informers/externalversions/generic.go @@ -0,0 +1,67 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package externalversions + +import ( + "fmt" + + v1beta1 "github.com/weaveworks/flux/integrations/apis/flux.weave.works/v1beta1" + v1alpha2 "github.com/weaveworks/flux/integrations/apis/helm.integrations.flux.weave.works/v1alpha2" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" +) + +// GenericInformer is type of SharedIndexInformer which will locate and delegate to other +// sharedInformers based on type +type GenericInformer interface { + Informer() cache.SharedIndexInformer + Lister() cache.GenericLister +} + +type genericInformer struct { + informer cache.SharedIndexInformer + resource schema.GroupResource +} + +// Informer returns the SharedIndexInformer. +func (f *genericInformer) Informer() cache.SharedIndexInformer { + return f.informer +} + +// Lister returns the GenericLister. +func (f *genericInformer) Lister() cache.GenericLister { + return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource) +} + +// ForResource gives generic access to a shared informer of the matching type +// TODO extend this to unknown resources with a client pool +func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { + switch resource { + // Group=flux.weave.works, Version=v1beta1 + case v1beta1.SchemeGroupVersion.WithResource("helmreleases"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Flux().V1beta1().HelmReleases().Informer()}, nil + + // Group=helm.integrations.flux.weave.works, Version=v1alpha2 + case v1alpha2.SchemeGroupVersion.WithResource("fluxhelmreleases"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Helm().V1alpha2().FluxHelmReleases().Informer()}, nil + + } + + return nil, fmt.Errorf("no informer found for %v", resource) +} diff --git a/integrations/client/informers/externalversions/helm.integrations.flux.weave.works/interface.go b/integrations/client/informers/externalversions/helm.integrations.flux.weave.works/interface.go new file mode 100644 index 0000000000..82c2da05ce --- /dev/null +++ b/integrations/client/informers/externalversions/helm.integrations.flux.weave.works/interface.go @@ -0,0 +1,46 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package helm + +import ( + v1alpha2 "github.com/weaveworks/flux/integrations/client/informers/externalversions/helm.integrations.flux.weave.works/v1alpha2" + internalinterfaces "github.com/weaveworks/flux/integrations/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1alpha2 provides access to shared informers for resources in V1alpha2. + V1alpha2() v1alpha2.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1alpha2 returns a new v1alpha2.Interface. +func (g *group) V1alpha2() v1alpha2.Interface { + return v1alpha2.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/integrations/client/informers/externalversions/helm.integrations.flux.weave.works/v1alpha2/fluxhelmrelease.go b/integrations/client/informers/externalversions/helm.integrations.flux.weave.works/v1alpha2/fluxhelmrelease.go new file mode 100644 index 0000000000..8625bc62c2 --- /dev/null +++ b/integrations/client/informers/externalversions/helm.integrations.flux.weave.works/v1alpha2/fluxhelmrelease.go @@ -0,0 +1,89 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + time "time" + + helmintegrationsfluxweaveworksv1alpha2 "github.com/weaveworks/flux/integrations/apis/helm.integrations.flux.weave.works/v1alpha2" + versioned "github.com/weaveworks/flux/integrations/client/clientset/versioned" + internalinterfaces "github.com/weaveworks/flux/integrations/client/informers/externalversions/internalinterfaces" + v1alpha2 "github.com/weaveworks/flux/integrations/client/listers/helm.integrations.flux.weave.works/v1alpha2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// FluxHelmReleaseInformer provides access to a shared informer and lister for +// FluxHelmReleases. +type FluxHelmReleaseInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha2.FluxHelmReleaseLister +} + +type fluxHelmReleaseInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewFluxHelmReleaseInformer constructs a new informer for FluxHelmRelease type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFluxHelmReleaseInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredFluxHelmReleaseInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredFluxHelmReleaseInformer constructs a new informer for FluxHelmRelease type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredFluxHelmReleaseInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.HelmV1alpha2().FluxHelmReleases(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.HelmV1alpha2().FluxHelmReleases(namespace).Watch(options) + }, + }, + &helmintegrationsfluxweaveworksv1alpha2.FluxHelmRelease{}, + resyncPeriod, + indexers, + ) +} + +func (f *fluxHelmReleaseInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredFluxHelmReleaseInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *fluxHelmReleaseInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&helmintegrationsfluxweaveworksv1alpha2.FluxHelmRelease{}, f.defaultInformer) +} + +func (f *fluxHelmReleaseInformer) Lister() v1alpha2.FluxHelmReleaseLister { + return v1alpha2.NewFluxHelmReleaseLister(f.Informer().GetIndexer()) +} diff --git a/integrations/client/informers/externalversions/helm.integrations.flux.weave.works/v1alpha2/interface.go b/integrations/client/informers/externalversions/helm.integrations.flux.weave.works/v1alpha2/interface.go new file mode 100644 index 0000000000..3a5c4bcbee --- /dev/null +++ b/integrations/client/informers/externalversions/helm.integrations.flux.weave.works/v1alpha2/interface.go @@ -0,0 +1,45 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + internalinterfaces "github.com/weaveworks/flux/integrations/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // FluxHelmReleases returns a FluxHelmReleaseInformer. + FluxHelmReleases() FluxHelmReleaseInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// FluxHelmReleases returns a FluxHelmReleaseInformer. +func (v *version) FluxHelmReleases() FluxHelmReleaseInformer { + return &fluxHelmReleaseInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/integrations/client/informers/externalversions/internalinterfaces/factory_interfaces.go b/integrations/client/informers/externalversions/internalinterfaces/factory_interfaces.go new file mode 100644 index 0000000000..dfb2cff8bc --- /dev/null +++ b/integrations/client/informers/externalversions/internalinterfaces/factory_interfaces.go @@ -0,0 +1,40 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package internalinterfaces + +import ( + time "time" + + versioned "github.com/weaveworks/flux/integrations/client/clientset/versioned" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + cache "k8s.io/client-go/tools/cache" +) + +// NewInformerFunc takes versioned.Interface and time.Duration to return a SharedIndexInformer. +type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer + +// SharedInformerFactory a small interface to allow for adding an informer without an import cycle +type SharedInformerFactory interface { + Start(stopCh <-chan struct{}) + InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer +} + +// TweakListOptionsFunc is a function that transforms a v1.ListOptions. +type TweakListOptionsFunc func(*v1.ListOptions) diff --git a/integrations/client/listers/flux.weave.works/v1beta1/expansion_generated.go b/integrations/client/listers/flux.weave.works/v1beta1/expansion_generated.go new file mode 100644 index 0000000000..0797a7439b --- /dev/null +++ b/integrations/client/listers/flux.weave.works/v1beta1/expansion_generated.go @@ -0,0 +1,27 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1beta1 + +// HelmReleaseListerExpansion allows custom methods to be added to +// HelmReleaseLister. +type HelmReleaseListerExpansion interface{} + +// HelmReleaseNamespaceListerExpansion allows custom methods to be added to +// HelmReleaseNamespaceLister. +type HelmReleaseNamespaceListerExpansion interface{} diff --git a/integrations/client/listers/flux.weave.works/v1beta1/helmrelease.go b/integrations/client/listers/flux.weave.works/v1beta1/helmrelease.go new file mode 100644 index 0000000000..dd87ed8d4a --- /dev/null +++ b/integrations/client/listers/flux.weave.works/v1beta1/helmrelease.go @@ -0,0 +1,94 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1beta1 + +import ( + v1beta1 "github.com/weaveworks/flux/integrations/apis/flux.weave.works/v1beta1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// HelmReleaseLister helps list HelmReleases. +type HelmReleaseLister interface { + // List lists all HelmReleases in the indexer. + List(selector labels.Selector) (ret []*v1beta1.HelmRelease, err error) + // HelmReleases returns an object that can list and get HelmReleases. + HelmReleases(namespace string) HelmReleaseNamespaceLister + HelmReleaseListerExpansion +} + +// helmReleaseLister implements the HelmReleaseLister interface. +type helmReleaseLister struct { + indexer cache.Indexer +} + +// NewHelmReleaseLister returns a new HelmReleaseLister. +func NewHelmReleaseLister(indexer cache.Indexer) HelmReleaseLister { + return &helmReleaseLister{indexer: indexer} +} + +// List lists all HelmReleases in the indexer. +func (s *helmReleaseLister) List(selector labels.Selector) (ret []*v1beta1.HelmRelease, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.HelmRelease)) + }) + return ret, err +} + +// HelmReleases returns an object that can list and get HelmReleases. +func (s *helmReleaseLister) HelmReleases(namespace string) HelmReleaseNamespaceLister { + return helmReleaseNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// HelmReleaseNamespaceLister helps list and get HelmReleases. +type HelmReleaseNamespaceLister interface { + // List lists all HelmReleases in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1beta1.HelmRelease, err error) + // Get retrieves the HelmRelease from the indexer for a given namespace and name. + Get(name string) (*v1beta1.HelmRelease, error) + HelmReleaseNamespaceListerExpansion +} + +// helmReleaseNamespaceLister implements the HelmReleaseNamespaceLister +// interface. +type helmReleaseNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all HelmReleases in the indexer for a given namespace. +func (s helmReleaseNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.HelmRelease, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.HelmRelease)) + }) + return ret, err +} + +// Get retrieves the HelmRelease from the indexer for a given namespace and name. +func (s helmReleaseNamespaceLister) Get(name string) (*v1beta1.HelmRelease, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1beta1.Resource("helmrelease"), name) + } + return obj.(*v1beta1.HelmRelease), nil +} diff --git a/integrations/client/listers/helm.integrations.flux.weave.works/v1alpha2/expansion_generated.go b/integrations/client/listers/helm.integrations.flux.weave.works/v1alpha2/expansion_generated.go new file mode 100644 index 0000000000..fb01867ba9 --- /dev/null +++ b/integrations/client/listers/helm.integrations.flux.weave.works/v1alpha2/expansion_generated.go @@ -0,0 +1,27 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha2 + +// FluxHelmReleaseListerExpansion allows custom methods to be added to +// FluxHelmReleaseLister. +type FluxHelmReleaseListerExpansion interface{} + +// FluxHelmReleaseNamespaceListerExpansion allows custom methods to be added to +// FluxHelmReleaseNamespaceLister. +type FluxHelmReleaseNamespaceListerExpansion interface{} diff --git a/integrations/client/listers/helm.integrations.flux.weave.works/v1alpha2/fluxhelmrelease.go b/integrations/client/listers/helm.integrations.flux.weave.works/v1alpha2/fluxhelmrelease.go new file mode 100644 index 0000000000..00f512d7e1 --- /dev/null +++ b/integrations/client/listers/helm.integrations.flux.weave.works/v1alpha2/fluxhelmrelease.go @@ -0,0 +1,94 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + v1alpha2 "github.com/weaveworks/flux/integrations/apis/helm.integrations.flux.weave.works/v1alpha2" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// FluxHelmReleaseLister helps list FluxHelmReleases. +type FluxHelmReleaseLister interface { + // List lists all FluxHelmReleases in the indexer. + List(selector labels.Selector) (ret []*v1alpha2.FluxHelmRelease, err error) + // FluxHelmReleases returns an object that can list and get FluxHelmReleases. + FluxHelmReleases(namespace string) FluxHelmReleaseNamespaceLister + FluxHelmReleaseListerExpansion +} + +// fluxHelmReleaseLister implements the FluxHelmReleaseLister interface. +type fluxHelmReleaseLister struct { + indexer cache.Indexer +} + +// NewFluxHelmReleaseLister returns a new FluxHelmReleaseLister. +func NewFluxHelmReleaseLister(indexer cache.Indexer) FluxHelmReleaseLister { + return &fluxHelmReleaseLister{indexer: indexer} +} + +// List lists all FluxHelmReleases in the indexer. +func (s *fluxHelmReleaseLister) List(selector labels.Selector) (ret []*v1alpha2.FluxHelmRelease, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha2.FluxHelmRelease)) + }) + return ret, err +} + +// FluxHelmReleases returns an object that can list and get FluxHelmReleases. +func (s *fluxHelmReleaseLister) FluxHelmReleases(namespace string) FluxHelmReleaseNamespaceLister { + return fluxHelmReleaseNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// FluxHelmReleaseNamespaceLister helps list and get FluxHelmReleases. +type FluxHelmReleaseNamespaceLister interface { + // List lists all FluxHelmReleases in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha2.FluxHelmRelease, err error) + // Get retrieves the FluxHelmRelease from the indexer for a given namespace and name. + Get(name string) (*v1alpha2.FluxHelmRelease, error) + FluxHelmReleaseNamespaceListerExpansion +} + +// fluxHelmReleaseNamespaceLister implements the FluxHelmReleaseNamespaceLister +// interface. +type fluxHelmReleaseNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all FluxHelmReleases in the indexer for a given namespace. +func (s fluxHelmReleaseNamespaceLister) List(selector labels.Selector) (ret []*v1alpha2.FluxHelmRelease, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha2.FluxHelmRelease)) + }) + return ret, err +} + +// Get retrieves the FluxHelmRelease from the indexer for a given namespace and name. +func (s fluxHelmReleaseNamespaceLister) Get(name string) (*v1alpha2.FluxHelmRelease, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha2.Resource("fluxhelmrelease"), name) + } + return obj.(*v1alpha2.FluxHelmRelease), nil +}