From fe921ba6bc360cb19257aa50dc399bef4d2cbc14 Mon Sep 17 00:00:00 2001 From: Michael Bridgen Date: Tue, 30 Oct 2018 17:08:46 +0000 Subject: [PATCH] Support both new and old custom resources Instead of requiring people to cut across from the old version of the helm operator to the new, support both in fluxd. This means you can not only have different versions of the custom resources, you can keep running the old operator, while you transition to the new. To keep the `kind` part of Resource IDs unambiguous, I have renamed the new custom resource to `HelmRelease` (it was already in the API `flux.weave.works/v1beta`). This is the same as the kind bitnami's helm operator uses, but the `apiVersion` is different (so Kubernetes won't confuse them), and it's unlikely you'd be running both operators. --- cluster/kubernetes/resource/resource.go | 2 +- cluster/kubernetes/resourcekinds.go | 65 +++++++- cmd/helm-operator/main.go | 10 +- deploy-helm/flux-helm-release-crd.yaml | 10 +- .../apis/flux.weave.works/v1beta1/register.go | 4 +- .../apis/flux.weave.works/v1beta1/types.go | 46 +++--- .../flux.weave.works/v1beta1/types_test.go | 34 ++-- .../v1beta1/zz_generated.deepcopy.go | 82 +++++----- .../fake/fake_flux.weave.works_client.go | 4 +- .../v1beta1/fake/fake_fluxhelmrelease.go | 125 -------------- .../v1beta1/fake/fake_helmrelease.go | 125 ++++++++++++++ .../v1beta1/flux.weave.works_client.go | 6 +- .../v1beta1/fluxhelmrelease.go | 154 ------------------ .../v1beta1/generated_expansion.go | 2 +- .../flux.weave.works/v1beta1/helmrelease.go | 154 ++++++++++++++++++ .../{fluxhelmrelease.go => helmrelease.go} | 38 ++--- .../flux.weave.works/v1beta1/interface.go | 10 +- .../informers/externalversions/generic.go | 4 +- .../v1beta1/expansion_generated.go | 12 +- .../v1beta1/fluxhelmrelease.go | 91 ----------- .../flux.weave.works/v1beta1/helmrelease.go | 91 +++++++++++ integrations/helm/chartsync/chartsync.go | 74 ++++----- integrations/helm/operator/operator.go | 42 ++--- integrations/helm/release/release.go | 16 +- integrations/helm/status/conditions.go | 8 +- integrations/helm/status/status.go | 12 +- site/helm-integration.md | 38 ++--- 27 files changed, 654 insertions(+), 605 deletions(-) delete mode 100644 integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/fake/fake_fluxhelmrelease.go create mode 100644 integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/fake/fake_helmrelease.go delete mode 100644 integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/fluxhelmrelease.go create mode 100644 integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/helmrelease.go rename integrations/client/informers/externalversions/flux.weave.works/v1beta1/{fluxhelmrelease.go => helmrelease.go} (56%) delete mode 100644 integrations/client/listers/flux.weave.works/v1beta1/fluxhelmrelease.go create mode 100644 integrations/client/listers/flux.weave.works/v1beta1/helmrelease.go diff --git a/cluster/kubernetes/resource/resource.go b/cluster/kubernetes/resource/resource.go index 31c2e8987..f73d90b67 100644 --- a/cluster/kubernetes/resource/resource.go +++ b/cluster/kubernetes/resource/resource.go @@ -118,7 +118,7 @@ func unmarshalKind(base baseObject, bytes []byte) (resource.Resource, error) { var list List unmarshalList(base, &raw, &list) return &list, nil - case "FluxHelmRelease": + case "FluxHelmRelease", "HelmRelease": var fhr = FluxHelmRelease{baseObject: base} if err := yaml.Unmarshal(bytes, &fhr); err != nil { return nil, err diff --git a/cluster/kubernetes/resourcekinds.go b/cluster/kubernetes/resourcekinds.go index ba961d0d8..ea4608aae 100644 --- a/cluster/kubernetes/resourcekinds.go +++ b/cluster/kubernetes/resourcekinds.go @@ -11,6 +11,7 @@ import ( kresource "github.com/weaveworks/flux/cluster/kubernetes/resource" "github.com/weaveworks/flux/image" fhr_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/resource" ) @@ -39,6 +40,7 @@ func init() { resourceKinds["daemonset"] = &daemonSetKind{} resourceKinds["deployment"] = &deploymentKind{} resourceKinds["statefulset"] = &statefulSetKind{} + resourceKinds["helmrelease"] = &helmReleaseKind{} resourceKinds["fluxhelmrelease"] = &fluxHelmReleaseKind{} } @@ -370,16 +372,15 @@ func makeCronJobPodController(cronJob *apibatch.CronJob) podController { type fluxHelmReleaseKind struct{} func (fhr *fluxHelmReleaseKind) getPodController(c *Cluster, namespace, name string) (podController, error) { - fluxHelmRelease, err := c.client.FluxV1beta1().FluxHelmReleases(namespace).Get(name, meta_v1.GetOptions{}) + fluxHelmRelease, err := c.client.HelmV1alpha2().FluxHelmReleases(namespace).Get(name, meta_v1.GetOptions{}) if err != nil { return podController{}, err } - return makeFluxHelmReleasePodController(fluxHelmRelease), nil } func (fhr *fluxHelmReleaseKind) getPodControllers(c *Cluster, namespace string) ([]podController, error) { - fluxHelmReleases, err := c.client.FluxV1beta1().FluxHelmReleases(namespace).List(meta_v1.ListOptions{}) + fluxHelmReleases, err := c.client.HelmV1alpha2().FluxHelmReleases(namespace).List(meta_v1.ListOptions{}) if err != nil { return nil, err } @@ -392,8 +393,8 @@ func (fhr *fluxHelmReleaseKind) getPodControllers(c *Cluster, namespace string) return podControllers, nil } -func makeFluxHelmReleasePodController(fluxHelmRelease *fhr_v1beta1.FluxHelmRelease) podController { - containers := createK8sFHRContainers(fluxHelmRelease.Spec) +func makeFluxHelmReleasePodController(fluxHelmRelease *fhr_v1alpha2.FluxHelmRelease) podController { + containers := createK8sFHRContainers(fluxHelmRelease.Spec.Values) podTemplate := apiv1.PodTemplateSpec{ ObjectMeta: fluxHelmRelease.ObjectMeta, @@ -404,7 +405,7 @@ func makeFluxHelmReleasePodController(fluxHelmRelease *fhr_v1beta1.FluxHelmRelea } return podController{ - apiVersion: "flux.weave.works/v1beta1", + apiVersion: "helm.integrations.flux.weave.works/v1alpha2", kind: "FluxHelmRelease", name: fluxHelmRelease.ObjectMeta.Name, status: fluxHelmRelease.Status.ReleaseStatus, @@ -416,9 +417,9 @@ func makeFluxHelmReleasePodController(fluxHelmRelease *fhr_v1beta1.FluxHelmRelea // createK8sContainers creates a list of k8s containers by // interpreting the FluxHelmRelease resource. The interpretation is // analogous to that in cluster/kubernetes/resource/fluxhelmrelease.go -func createK8sFHRContainers(spec fhr_v1beta1.FluxHelmReleaseSpec) []apiv1.Container { +func createK8sFHRContainers(values map[string]interface{}) []apiv1.Container { var containers []apiv1.Container - _ = kresource.FindFluxHelmReleaseContainers(spec.Values, func(name string, image image.Ref, _ kresource.ImageSetter) error { + _ = kresource.FindFluxHelmReleaseContainers(values, func(name string, image image.Ref, _ kresource.ImageSetter) error { containers = append(containers, apiv1.Container{ Name: name, Image: image.String(), @@ -427,3 +428,51 @@ func createK8sFHRContainers(spec fhr_v1beta1.FluxHelmReleaseSpec) []apiv1.Contai }) return containers } + +///////////////////////////////////////////////////////////////////////////// +// flux.weave.works/v1beta1 HelmRelease + +type helmReleaseKind struct{} + +func (hr *helmReleaseKind) getPodController(c *Cluster, namespace, name string) (podController, error) { + helmRelease, err := c.client.FluxV1beta1().HelmReleases(namespace).Get(name, meta_v1.GetOptions{}) + if err != nil { + return podController{}, err + } + return makeHelmReleasePodController(helmRelease), nil +} + +func (hr *helmReleaseKind) getPodControllers(c *Cluster, namespace string) ([]podController, error) { + helmReleases, err := c.client.FluxV1beta1().HelmReleases(namespace).List(meta_v1.ListOptions{}) + if err != nil { + return nil, err + } + + var podControllers []podController + for _, f := range helmReleases.Items { + podControllers = append(podControllers, makeHelmReleasePodController(&f)) + } + + return podControllers, nil +} + +func makeHelmReleasePodController(helmRelease *fhr_v1beta1.HelmRelease) podController { + containers := createK8sFHRContainers(helmRelease.Spec.Values) + + podTemplate := apiv1.PodTemplateSpec{ + ObjectMeta: helmRelease.ObjectMeta, + Spec: apiv1.PodSpec{ + Containers: containers, + ImagePullSecrets: []apiv1.LocalObjectReference{}, + }, + } + + return podController{ + apiVersion: "flux.weave.works/v1beta1", + kind: "HelmRelease", + name: helmRelease.ObjectMeta.Name, + status: helmRelease.Status.ReleaseStatus, + podTemplate: podTemplate, + k8sObject: helmRelease, + } +} diff --git a/cmd/helm-operator/main.go b/cmd/helm-operator/main.go index 2d6c56619..ee521e1e1 100644 --- a/cmd/helm-operator/main.go +++ b/cmd/helm-operator/main.go @@ -89,7 +89,7 @@ func init() { tillerTLSCACert = fs.String("tiller-tls-ca-cert-path", "", "path to CA certificate file used to validate the Tiller server; required if tiller-tls-verify is enabled") tillerTLSHostname = fs.String("tiller-tls-hostname", "", "server name used to verify the hostname on the returned certificates from the server") - chartsSyncInterval = fs.Duration("charts-sync-interval", 3*time.Minute, "period on which to reconcile the Helm releases with FluxHelmRelease resources") + chartsSyncInterval = fs.Duration("charts-sync-interval", 3*time.Minute, "period on which to reconcile the Helm releases with HelmRelease resources") logReleaseDiffs = fs.Bool("log-release-diffs", false, "log the diff when a chart release diverges; potentially insecure") updateDependencies = fs.Bool("update-chart-deps", true, "Update chart dependencies before installing/upgrading a release") @@ -171,11 +171,11 @@ func main() { }) // The status updater, to keep track the release status for each - // FluxHelmRelease. It runs as a separate loop for now. + // HelmRelease. It runs as a separate loop for now. statusUpdater := status.New(ifClient, kubeClient, helmClient) go statusUpdater.Loop(shutdown, log.With(logger, "component", "annotator")) - // release instance is needed during the sync of Charts changes and during the sync of FluxHelmRelease changes + // release instance is needed during the sync of Charts changes and during the sync of HelmRelease changes rel := release.New(log.With(logger, "component", "release"), helmClient) // CHARTS CHANGES SYNC ------------------------------------------------------------------ chartSync := chartsync.New(log.With(logger, "component", "chartsync"), @@ -189,8 +189,8 @@ func main() { // SharedInformerFactory sets up informer, that maps resource type to a cache shared informer. // operator attaches event handler to the informer and syncs the informer cache ifInformerFactory := ifinformers.NewSharedInformerFactory(ifClient, 30*time.Second) - // Reference to shared index informers for the FluxHelmRelease - fhrInformer := ifInformerFactory.Flux().V1beta1().FluxHelmReleases() + // Reference to shared index informers for the HelmRelease + fhrInformer := ifInformerFactory.Flux().V1beta1().HelmReleases() opr := operator.New(log.With(logger, "component", "operator"), *logReleaseDiffs, kubeClient, fhrInformer, chartSync) // Starts handling k8s events related to the given resource kind diff --git a/deploy-helm/flux-helm-release-crd.yaml b/deploy-helm/flux-helm-release-crd.yaml index 986fa93eb..b41682ce6 100644 --- a/deploy-helm/flux-helm-release-crd.yaml +++ b/deploy-helm/flux-helm-release-crd.yaml @@ -2,15 +2,15 @@ apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: - name: fluxhelmreleases.flux.weave.works + name: helmreleases.flux.weave.works spec: group: flux.weave.works names: - kind: FluxHelmRelease - listKind: FluxHelmReleaseList - plural: fluxhelmreleases + kind: HelmRelease + listKind: HelmReleaseList + plural: helmreleases shortNames: - - fhr + - hr scope: Namespaced version: v1beta1 versions: diff --git a/integrations/apis/flux.weave.works/v1beta1/register.go b/integrations/apis/flux.weave.works/v1beta1/register.go index 596325efd..47165c199 100644 --- a/integrations/apis/flux.weave.works/v1beta1/register.go +++ b/integrations/apis/flux.weave.works/v1beta1/register.go @@ -34,8 +34,8 @@ func init() { // Adds the list of known types to api.Scheme. func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, - &FluxHelmRelease{}, - &FluxHelmReleaseList{}, + &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 index da4ce1418..4b4b42f12 100644 --- a/integrations/apis/flux.weave.works/v1beta1/types.go +++ b/integrations/apis/flux.weave.works/v1beta1/types.go @@ -14,19 +14,19 @@ import ( // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // FluxHelmRelease represents custom resource associated with a Helm Chart -type FluxHelmRelease struct { +type HelmRelease struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata"` - Spec FluxHelmReleaseSpec `json:"spec"` - Status FluxHelmReleaseStatus `json:"status"` + 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 (fhr FluxHelmRelease) ResourceID() flux.ResourceID { - return flux.MakeResourceID(fhr.Namespace, "FluxHelmRelease", fhr.Name) +func (fhr HelmRelease) ResourceID() flux.ResourceID { + return flux.MakeResourceID(fhr.Namespace, "HelmRelease", fhr.Name) } type ChartSource struct { @@ -64,15 +64,15 @@ type RepoChartSource struct { // FluxHelmReleaseSpec is the spec for a FluxHelmRelease resource // FluxHelmReleaseSpec -type FluxHelmReleaseSpec struct { +type HelmReleaseSpec struct { ChartSource `json:"chart"` ReleaseName string `json:"releaseName,omitempty"` ValueFileSecrets []v1.LocalObjectReference `json:"valueFileSecrets,omitempty"` - FluxHelmValues `json:",inline"` + HelmValues `json:",inline"` } -type FluxHelmReleaseStatus struct { +type HelmReleaseStatus struct { // ReleaseName is the name as either supplied or generated. // +optional ReleaseName string `json:"releaseName"` @@ -86,12 +86,12 @@ type FluxHelmReleaseStatus struct { // +optional // +patchMergeKey=type // +patchStrategy=merge - Conditions []FluxHelmReleaseCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"` + Conditions []HelmReleaseCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"` } -type FluxHelmReleaseCondition struct { - Type FluxHelmReleaseConditionType `json:"type"` - Status v1.ConditionStatus `json:"status"` +type HelmReleaseCondition struct { + Type HelmReleaseConditionType `json:"type"` + Status v1.ConditionStatus `json:"status"` // +optional LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"` // +optional @@ -100,25 +100,25 @@ type FluxHelmReleaseCondition struct { Message string `json:"message,omitempty"` } -type FluxHelmReleaseConditionType string +type HelmReleaseConditionType string const ( - // ChartFetched means the chart to which the FluxHelmRelease - // refers has been fetched successfully - FluxHelmReleaseChartFetched FluxHelmReleaseConditionType = "ChartFetched" + // 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 - // FluxHelmRelease, has been processed by Helm. - FluxHelmReleaseReleased FluxHelmReleaseConditionType = "Released" + // HelmRelease, has been processed by Helm. + HelmReleaseReleased HelmReleaseConditionType = "Released" ) // FluxHelmValues embeds chartutil.Values so we can implement deepcopy on map[string]interface{} // +k8s:deepcopy-gen=false -type FluxHelmValues struct { +type HelmValues struct { chartutil.Values `json:"values,omitempty"` } // DeepCopyInto implements deepcopy-gen method for use in generated code -func (in *FluxHelmValues) DeepCopyInto(out *FluxHelmValues) { +func (in *HelmValues) DeepCopyInto(out *HelmValues) { if in == nil { return } @@ -137,10 +137,10 @@ func (in *FluxHelmValues) DeepCopyInto(out *FluxHelmValues) { // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// FluxHelmReleaseList is a list of FluxHelmRelease resources -type FluxHelmReleaseList struct { +// HelmReleaseList is a list of FluxHelmRelease resources +type HelmReleaseList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata"` - Items []FluxHelmRelease `json:"items"` + 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 index 36ac79fdb..02ae0c9cc 100644 --- a/integrations/apis/flux.weave.works/v1beta1/types_test.go +++ b/integrations/apis/flux.weave.works/v1beta1/types_test.go @@ -6,45 +6,45 @@ import ( "github.com/stretchr/testify/assert" ) -func TestFluxHelmValues(t *testing.T) { +func TestHelmValues(t *testing.T) { testCases := []struct { - original *FluxHelmValues - transformer func(v *FluxHelmValues) *FluxHelmValues - expectedCopy *FluxHelmValues - expectedOriginal *FluxHelmValues + original *HelmValues + transformer func(v *HelmValues) *HelmValues + expectedCopy *HelmValues + expectedOriginal *HelmValues }{ // reassignment { original: nil, - transformer: func(v *FluxHelmValues) *FluxHelmValues { - return &FluxHelmValues{} + transformer: func(v *HelmValues) *HelmValues { + return &HelmValues{} }, - expectedCopy: &FluxHelmValues{}, + expectedCopy: &HelmValues{}, expectedOriginal: nil, }, // mutation { - original: &FluxHelmValues{Values: map[string]interface{}{}}, - transformer: func(v *FluxHelmValues) *FluxHelmValues { + original: &HelmValues{Values: map[string]interface{}{}}, + transformer: func(v *HelmValues) *HelmValues { v.Values["foo"] = "bar" return v }, - expectedCopy: &FluxHelmValues{Values: map[string]interface{}{"foo": "bar"}}, - expectedOriginal: &FluxHelmValues{Values: map[string]interface{}{}}, + expectedCopy: &HelmValues{Values: map[string]interface{}{"foo": "bar"}}, + expectedOriginal: &HelmValues{Values: map[string]interface{}{}}, }, { - original: &FluxHelmValues{Values: map[string]interface{}{"foo": map[string]interface{}{"bar": "baz"}}}, - transformer: func(v *FluxHelmValues) *FluxHelmValues { + 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: &FluxHelmValues{Values: map[string]interface{}{"foo": map[string]interface{}{"bar": "oof"}}}, - expectedOriginal: &FluxHelmValues{Values: map[string]interface{}{"foo": map[string]interface{}{"bar": "baz"}}}, + 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 := &FluxHelmValues{} + 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 index 66a71cf5b..c0a249777 100644 --- a/integrations/apis/flux.weave.works/v1beta1/zz_generated.deepcopy.go +++ b/integrations/apis/flux.weave.works/v1beta1/zz_generated.deepcopy.go @@ -60,7 +60,23 @@ func (in *ChartSource) DeepCopy() *ChartSource { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FluxHelmRelease) DeepCopyInto(out *FluxHelmRelease) { +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) @@ -69,18 +85,18 @@ func (in *FluxHelmRelease) DeepCopyInto(out *FluxHelmRelease) { return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FluxHelmRelease. -func (in *FluxHelmRelease) DeepCopy() *FluxHelmRelease { +// 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(FluxHelmRelease) + out := new(HelmRelease) 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 { +func (in *HelmRelease) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } else { @@ -89,30 +105,30 @@ func (in *FluxHelmRelease) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FluxHelmReleaseCondition) DeepCopyInto(out *FluxHelmReleaseCondition) { +func (in *HelmReleaseCondition) DeepCopyInto(out *HelmReleaseCondition) { *out = *in in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FluxHelmReleaseCondition. -func (in *FluxHelmReleaseCondition) DeepCopy() *FluxHelmReleaseCondition { +// 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(FluxHelmReleaseCondition) + 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 *FluxHelmReleaseList) DeepCopyInto(out *FluxHelmReleaseList) { +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([]FluxHelmRelease, len(*in)) + *out = make([]HelmRelease, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -120,18 +136,18 @@ func (in *FluxHelmReleaseList) DeepCopyInto(out *FluxHelmReleaseList) { return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FluxHelmReleaseList. -func (in *FluxHelmReleaseList) DeepCopy() *FluxHelmReleaseList { +// 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(FluxHelmReleaseList) + out := new(HelmReleaseList) 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 { +func (in *HelmReleaseList) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } else { @@ -140,7 +156,7 @@ func (in *FluxHelmReleaseList) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FluxHelmReleaseSpec) DeepCopyInto(out *FluxHelmReleaseSpec) { +func (in *HelmReleaseSpec) DeepCopyInto(out *HelmReleaseSpec) { *out = *in in.ChartSource.DeepCopyInto(&out.ChartSource) if in.ValueFileSecrets != nil { @@ -148,26 +164,26 @@ func (in *FluxHelmReleaseSpec) DeepCopyInto(out *FluxHelmReleaseSpec) { *out = make([]v1.LocalObjectReference, len(*in)) copy(*out, *in) } - in.FluxHelmValues.DeepCopyInto(&out.FluxHelmValues) + in.HelmValues.DeepCopyInto(&out.HelmValues) return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FluxHelmReleaseSpec. -func (in *FluxHelmReleaseSpec) DeepCopy() *FluxHelmReleaseSpec { +// 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(FluxHelmReleaseSpec) + 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 *FluxHelmReleaseStatus) DeepCopyInto(out *FluxHelmReleaseStatus) { +func (in *HelmReleaseStatus) DeepCopyInto(out *HelmReleaseStatus) { *out = *in if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make([]FluxHelmReleaseCondition, len(*in)) + *out = make([]HelmReleaseCondition, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -175,28 +191,12 @@ func (in *FluxHelmReleaseStatus) DeepCopyInto(out *FluxHelmReleaseStatus) { return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FluxHelmReleaseStatus. -func (in *FluxHelmReleaseStatus) DeepCopy() *FluxHelmReleaseStatus { +// 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(FluxHelmReleaseStatus) - 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) + out := new(HelmReleaseStatus) in.DeepCopyInto(out) return out } 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 index 72f176630..7f38573de 100644 --- 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 @@ -25,8 +25,8 @@ type FakeFluxV1beta1 struct { *testing.Fake } -func (c *FakeFluxV1beta1) FluxHelmReleases(namespace string) v1beta1.FluxHelmReleaseInterface { - return &FakeFluxHelmReleases{c, namespace} +func (c *FakeFluxV1beta1) HelmReleases(namespace string) v1beta1.HelmReleaseInterface { + return &FakeHelmReleases{c, namespace} } // RESTClient returns a RESTClient that is used to communicate diff --git a/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/fake/fake_fluxhelmrelease.go b/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/fake/fake_fluxhelmrelease.go deleted file mode 100644 index a53654740..000000000 --- a/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/fake/fake_fluxhelmrelease.go +++ /dev/null @@ -1,125 +0,0 @@ -/* -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. -*/ -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" -) - -// FakeFluxHelmReleases implements FluxHelmReleaseInterface -type FakeFluxHelmReleases struct { - Fake *FakeFluxV1beta1 - ns string -} - -var fluxhelmreleasesResource = schema.GroupVersionResource{Group: "flux.weave.works", Version: "v1beta1", Resource: "fluxhelmreleases"} - -var fluxhelmreleasesKind = schema.GroupVersionKind{Group: "flux.weave.works", Version: "v1beta1", 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 *v1beta1.FluxHelmRelease, err error) { - obj, err := c.Fake. - Invokes(testing.NewGetAction(fluxhelmreleasesResource, c.ns, name), &v1beta1.FluxHelmRelease{}) - - if obj == nil { - return nil, err - } - return obj.(*v1beta1.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 *v1beta1.FluxHelmReleaseList, err error) { - obj, err := c.Fake. - Invokes(testing.NewListAction(fluxhelmreleasesResource, fluxhelmreleasesKind, c.ns, opts), &v1beta1.FluxHelmReleaseList{}) - - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &v1beta1.FluxHelmReleaseList{ListMeta: obj.(*v1beta1.FluxHelmReleaseList).ListMeta} - for _, item := range obj.(*v1beta1.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 *v1beta1.FluxHelmRelease) (result *v1beta1.FluxHelmRelease, err error) { - obj, err := c.Fake. - Invokes(testing.NewCreateAction(fluxhelmreleasesResource, c.ns, fluxHelmRelease), &v1beta1.FluxHelmRelease{}) - - if obj == nil { - return nil, err - } - return obj.(*v1beta1.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 *v1beta1.FluxHelmRelease) (result *v1beta1.FluxHelmRelease, err error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateAction(fluxhelmreleasesResource, c.ns, fluxHelmRelease), &v1beta1.FluxHelmRelease{}) - - if obj == nil { - return nil, err - } - return obj.(*v1beta1.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), &v1beta1.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, &v1beta1.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 *v1beta1.FluxHelmRelease, err error) { - obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(fluxhelmreleasesResource, c.ns, name, data, subresources...), &v1beta1.FluxHelmRelease{}) - - if obj == nil { - return nil, err - } - return obj.(*v1beta1.FluxHelmRelease), err -} 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 000000000..338b18bd1 --- /dev/null +++ b/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/fake/fake_helmrelease.go @@ -0,0 +1,125 @@ +/* +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. +*/ +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 +} + +// 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, 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 index 71a0340bc..289f93244 100644 --- 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 @@ -24,7 +24,7 @@ import ( type FluxV1beta1Interface interface { RESTClient() rest.Interface - FluxHelmReleasesGetter + HelmReleasesGetter } // FluxV1beta1Client is used to interact with features provided by the flux.weave.works group. @@ -32,8 +32,8 @@ type FluxV1beta1Client struct { restClient rest.Interface } -func (c *FluxV1beta1Client) FluxHelmReleases(namespace string) FluxHelmReleaseInterface { - return newFluxHelmReleases(c, namespace) +func (c *FluxV1beta1Client) HelmReleases(namespace string) HelmReleaseInterface { + return newHelmReleases(c, namespace) } // NewForConfig creates a new FluxV1beta1Client for the given config. diff --git a/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/fluxhelmrelease.go b/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/fluxhelmrelease.go deleted file mode 100644 index d317d9a09..000000000 --- a/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/fluxhelmrelease.go +++ /dev/null @@ -1,154 +0,0 @@ -/* -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. -*/ -package v1beta1 - -import ( - 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" -) - -// 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(*v1beta1.FluxHelmRelease) (*v1beta1.FluxHelmRelease, error) - Update(*v1beta1.FluxHelmRelease) (*v1beta1.FluxHelmRelease, error) - Delete(name string, options *v1.DeleteOptions) error - DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error - Get(name string, options v1.GetOptions) (*v1beta1.FluxHelmRelease, error) - List(opts v1.ListOptions) (*v1beta1.FluxHelmReleaseList, error) - Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.FluxHelmRelease, err error) - FluxHelmReleaseExpansion -} - -// fluxHelmReleases implements FluxHelmReleaseInterface -type fluxHelmReleases struct { - client rest.Interface - ns string -} - -// newFluxHelmReleases returns a FluxHelmReleases -func newFluxHelmReleases(c *FluxV1beta1Client, 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 *v1beta1.FluxHelmRelease, err error) { - result = &v1beta1.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 *v1beta1.FluxHelmReleaseList, err error) { - result = &v1beta1.FluxHelmReleaseList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("fluxhelmreleases"). - VersionedParams(&opts, scheme.ParameterCodec). - Do(). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested fluxHelmReleases. -func (c *fluxHelmReleases) Watch(opts v1.ListOptions) (watch.Interface, error) { - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("fluxhelmreleases"). - VersionedParams(&opts, scheme.ParameterCodec). - 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 *v1beta1.FluxHelmRelease) (result *v1beta1.FluxHelmRelease, err error) { - result = &v1beta1.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 *v1beta1.FluxHelmRelease) (result *v1beta1.FluxHelmRelease, err error) { - result = &v1beta1.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 { - return c.client.Delete(). - Namespace(c.ns). - Resource("fluxhelmreleases"). - VersionedParams(&listOptions, scheme.ParameterCodec). - 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 *v1beta1.FluxHelmRelease, err error) { - result = &v1beta1.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/flux.weave.works/v1beta1/generated_expansion.go b/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/generated_expansion.go index a0f677e57..e9f3c6342 100644 --- 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 @@ -15,4 +15,4 @@ limitations under the License. */ package v1beta1 -type FluxHelmReleaseExpansion interface{} +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 000000000..fef6fdc51 --- /dev/null +++ b/integrations/client/clientset/versioned/typed/flux.weave.works/v1beta1/helmrelease.go @@ -0,0 +1,154 @@ +/* +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. +*/ +package v1beta1 + +import ( + 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) + 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) { + result = &v1beta1.HelmReleaseList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("helmreleases"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested helmReleases. +func (c *helmReleases) Watch(opts v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("helmreleases"). + VersionedParams(&opts, scheme.ParameterCodec). + 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 +} + +// 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 { + return c.client.Delete(). + Namespace(c.ns). + Resource("helmreleases"). + VersionedParams(&listOptions, scheme.ParameterCodec). + 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/informers/externalversions/flux.weave.works/v1beta1/fluxhelmrelease.go b/integrations/client/informers/externalversions/flux.weave.works/v1beta1/helmrelease.go similarity index 56% rename from integrations/client/informers/externalversions/flux.weave.works/v1beta1/fluxhelmrelease.go rename to integrations/client/informers/externalversions/flux.weave.works/v1beta1/helmrelease.go index 0b8ffccfe..e7b1f10d1 100644 --- a/integrations/client/informers/externalversions/flux.weave.works/v1beta1/fluxhelmrelease.go +++ b/integrations/client/informers/externalversions/flux.weave.works/v1beta1/helmrelease.go @@ -27,59 +27,59 @@ import ( time "time" ) -// FluxHelmReleaseInformer provides access to a shared informer and lister for -// FluxHelmReleases. -type FluxHelmReleaseInformer interface { +// HelmReleaseInformer provides access to a shared informer and lister for +// HelmReleases. +type HelmReleaseInformer interface { Informer() cache.SharedIndexInformer - Lister() v1beta1.FluxHelmReleaseLister + Lister() v1beta1.HelmReleaseLister } -type fluxHelmReleaseInformer struct { +type helmReleaseInformer struct { factory internalinterfaces.SharedInformerFactory tweakListOptions internalinterfaces.TweakListOptionsFunc namespace string } -// NewFluxHelmReleaseInformer constructs a new informer for FluxHelmRelease type. +// 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 NewFluxHelmReleaseInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - return NewFilteredFluxHelmReleaseInformer(client, namespace, resyncPeriod, indexers, nil) +func NewHelmReleaseInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredHelmReleaseInformer(client, namespace, resyncPeriod, indexers, nil) } -// NewFilteredFluxHelmReleaseInformer constructs a new informer for FluxHelmRelease type. +// 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 NewFilteredFluxHelmReleaseInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { +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().FluxHelmReleases(namespace).List(options) + return client.FluxV1beta1().HelmReleases(namespace).List(options) }, WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.FluxV1beta1().FluxHelmReleases(namespace).Watch(options) + return client.FluxV1beta1().HelmReleases(namespace).Watch(options) }, }, - &flux_weave_works_v1beta1.FluxHelmRelease{}, + &flux_weave_works_v1beta1.HelmRelease{}, 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 *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 *fluxHelmReleaseInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&flux_weave_works_v1beta1.FluxHelmRelease{}, f.defaultInformer) +func (f *helmReleaseInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&flux_weave_works_v1beta1.HelmRelease{}, f.defaultInformer) } -func (f *fluxHelmReleaseInformer) Lister() v1beta1.FluxHelmReleaseLister { - return v1beta1.NewFluxHelmReleaseLister(f.Informer().GetIndexer()) +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 index 86d99d2ca..3eed64a14 100644 --- a/integrations/client/informers/externalversions/flux.weave.works/v1beta1/interface.go +++ b/integrations/client/informers/externalversions/flux.weave.works/v1beta1/interface.go @@ -21,8 +21,8 @@ import ( // Interface provides access to all the informers in this group version. type Interface interface { - // FluxHelmReleases returns a FluxHelmReleaseInformer. - FluxHelmReleases() FluxHelmReleaseInformer + // HelmReleases returns a HelmReleaseInformer. + HelmReleases() HelmReleaseInformer } type version struct { @@ -36,7 +36,7 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList 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} +// 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 index b664d1164..64ccbde01 100644 --- a/integrations/client/informers/externalversions/generic.go +++ b/integrations/client/informers/externalversions/generic.go @@ -50,8 +50,8 @@ func (f *genericInformer) Lister() cache.GenericLister { func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { switch resource { // Group=flux.weave.works, Version=v1beta1 - case v1beta1.SchemeGroupVersion.WithResource("fluxhelmreleases"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Flux().V1beta1().FluxHelmReleases().Informer()}, nil + 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"): diff --git a/integrations/client/listers/flux.weave.works/v1beta1/expansion_generated.go b/integrations/client/listers/flux.weave.works/v1beta1/expansion_generated.go index 3446f5856..b7797dc15 100644 --- a/integrations/client/listers/flux.weave.works/v1beta1/expansion_generated.go +++ b/integrations/client/listers/flux.weave.works/v1beta1/expansion_generated.go @@ -15,10 +15,10 @@ limitations under the License. */ package v1beta1 -// FluxHelmReleaseListerExpansion allows custom methods to be added to -// FluxHelmReleaseLister. -type FluxHelmReleaseListerExpansion interface{} +// HelmReleaseListerExpansion allows custom methods to be added to +// HelmReleaseLister. +type HelmReleaseListerExpansion interface{} -// FluxHelmReleaseNamespaceListerExpansion allows custom methods to be added to -// FluxHelmReleaseNamespaceLister. -type FluxHelmReleaseNamespaceListerExpansion interface{} +// HelmReleaseNamespaceListerExpansion allows custom methods to be added to +// HelmReleaseNamespaceLister. +type HelmReleaseNamespaceListerExpansion interface{} diff --git a/integrations/client/listers/flux.weave.works/v1beta1/fluxhelmrelease.go b/integrations/client/listers/flux.weave.works/v1beta1/fluxhelmrelease.go deleted file mode 100644 index 4c657639a..000000000 --- a/integrations/client/listers/flux.weave.works/v1beta1/fluxhelmrelease.go +++ /dev/null @@ -1,91 +0,0 @@ -/* -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. -*/ -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" -) - -// FluxHelmReleaseLister helps list FluxHelmReleases. -type FluxHelmReleaseLister interface { - // List lists all FluxHelmReleases in the indexer. - List(selector labels.Selector) (ret []*v1beta1.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 []*v1beta1.FluxHelmRelease, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.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 []*v1beta1.FluxHelmRelease, err error) - // Get retrieves the FluxHelmRelease from the indexer for a given namespace and name. - Get(name string) (*v1beta1.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 []*v1beta1.FluxHelmRelease, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.FluxHelmRelease)) - }) - return ret, err -} - -// Get retrieves the FluxHelmRelease from the indexer for a given namespace and name. -func (s fluxHelmReleaseNamespaceLister) Get(name string) (*v1beta1.FluxHelmRelease, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1beta1.Resource("fluxhelmrelease"), name) - } - return obj.(*v1beta1.FluxHelmRelease), nil -} 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 000000000..d4ca4e2d3 --- /dev/null +++ b/integrations/client/listers/flux.weave.works/v1beta1/helmrelease.go @@ -0,0 +1,91 @@ +/* +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. +*/ +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/helm/chartsync/chartsync.go b/integrations/helm/chartsync/chartsync.go index 7ca371318..fe6fc1499 100644 --- a/integrations/helm/chartsync/chartsync.go +++ b/integrations/helm/chartsync/chartsync.go @@ -1,25 +1,25 @@ /* This package has the algorithm for making sure the Helm releases in -the cluster match what are defined in the FluxHelmRelease resources. +the cluster match what are defined in the HelmRelease resources. There are several ways they can be mismatched. Here's how they are reconciled: - 1a. There is a FluxHelmRelease resource, but no corresponding + 1a. There is a HelmRelease resource, but no corresponding release. This can happen when the helm operator is first run, for example. The ChartChangeSync periodically checks for this by running through the resources and installing any that aren't released already. - 1b. The release corresponding to a FluxHelmRelease has been updated by + 1b. The release corresponding to a HelmRelease has been updated by some other means, perhaps while the operator wasn't running. This is also checked periodically, by doing a dry-run release and comparing the result to the release. 2. The chart has changed in git, meaning the release is out of date. The ChartChangeSync responds to new git commits by looking at - each chart that's referenced by a FluxHelmRelease, and if it's + each chart that's referenced by a HelmRelease, and if it's changed since the last seen commit, updating the release. 1a.) and 1b.) run on the same schedule, and 2.) is run when a git @@ -132,8 +132,8 @@ func New(logger log.Logger, polling Polling, clients Clients, release *release.R } // Run creates a syncing loop that will reconcile differences between -// Helm releases in the cluster, what FluxHelmRelease declare, and -// changes in the git repos mentioned by any FluxHelmRelease. +// Helm releases in the cluster, what HelmRelease declare, and +// changes in the git repos mentioned by any HelmRelease. func (chs *ChartChangeSync) Run(stopCh <-chan struct{}, errc chan error, wg *sync.WaitGroup) { chs.logger.Log("info", "Starting charts sync loop") wg.Add(1) @@ -172,7 +172,7 @@ func (chs *ChartChangeSync) Run(stopCh <-chan struct{}, errc chan error, wg *syn repo, ok := chs.mirrors.Get(repoName) if !ok { // Then why .. did you say .. it had changed? It may have been removed. Add it back and let it signal again. - chs.setCondition(&fhr, fluxv1beta1.FluxHelmReleaseChartFetched, v1.ConditionUnknown, ReasonGitNotReady, "git mirror missing; starting mirroring again") + chs.setCondition(&fhr, fluxv1beta1.HelmReleaseChartFetched, v1.ConditionUnknown, ReasonGitNotReady, "git mirror missing; starting mirroring again") chs.logger.Log("warning", "mirrored git repo disappeared after signalling change", "repo", repoName) chs.maybeMirror(fhr) continue @@ -182,7 +182,7 @@ func (chs *ChartChangeSync) Run(stopCh <-chan struct{}, errc chan error, wg *syn if status != git.RepoReady { chs.logger.Log("info", "repo not ready yet, while attempting chart sync", "repo", repoURL, "status", string(status)) // TODO(michael) log if there's a problem with the following? - chs.setCondition(&fhr, fluxv1beta1.FluxHelmReleaseChartFetched, v1.ConditionUnknown, ReasonGitNotReady, err.Error()) + chs.setCondition(&fhr, fluxv1beta1.HelmReleaseChartFetched, v1.ConditionUnknown, ReasonGitNotReady, err.Error()) continue } @@ -194,7 +194,7 @@ func (chs *ChartChangeSync) Run(stopCh <-chan struct{}, errc chan error, wg *syn refHead, err := repo.Revision(ctx, ref) cancel() if err != nil { - chs.setCondition(&fhr, fluxv1beta1.FluxHelmReleaseChartFetched, v1.ConditionFalse, ReasonGitNotReady, "problem cloning from local git mirror: "+err.Error()) + chs.setCondition(&fhr, fluxv1beta1.HelmReleaseChartFetched, v1.ConditionFalse, ReasonGitNotReady, "problem cloning from local git mirror: "+err.Error()) chs.logger.Log("warning", "could not get revision for ref while checking for changes", "repo", repoURL, "ref", ref, "err", err) continue } @@ -210,7 +210,7 @@ func (chs *ChartChangeSync) Run(stopCh <-chan struct{}, errc chan error, wg *syn commits, err := repo.CommitsBetween(ctx, cloneForChart.head, refHead, path) cancel() if err != nil { - chs.setCondition(&fhr, fluxv1beta1.FluxHelmReleaseChartFetched, v1.ConditionFalse, ReasonGitNotReady, "problem cloning from local git mirror: "+err.Error()) + chs.setCondition(&fhr, fluxv1beta1.HelmReleaseChartFetched, v1.ConditionFalse, ReasonGitNotReady, "problem cloning from local git mirror: "+err.Error()) chs.logger.Log("warning", "could not get revision for ref while checking for changes", "repo", repoURL, "ref", ref, "err", err) continue } @@ -222,7 +222,7 @@ func (chs *ChartChangeSync) Run(stopCh <-chan struct{}, errc chan error, wg *syn newClone, err := repo.Export(ctx, refHead) cancel() if err != nil { - chs.setCondition(&fhr, fluxv1beta1.FluxHelmReleaseChartFetched, v1.ConditionFalse, ReasonGitNotReady, "problem cloning from local git mirror: "+err.Error()) + chs.setCondition(&fhr, fluxv1beta1.HelmReleaseChartFetched, v1.ConditionFalse, ReasonGitNotReady, "problem cloning from local git mirror: "+err.Error()) chs.logger.Log("warning", "could not clone from mirror while checking for changes", "repo", repoURL, "ref", ref, "err", err) continue } @@ -259,9 +259,9 @@ func mirrorName(chartSource *fluxv1beta1.GitChartSource) string { return chartSource.GitURL // TODO(michael) this will not always be the case; e.g., per namespace, per auth } -// maybeMirror starts mirroring the repo needed by a FluxHelmRelease, +// maybeMirror starts mirroring the repo needed by a HelmRelease, // if necessary -func (chs *ChartChangeSync) maybeMirror(fhr fluxv1beta1.FluxHelmRelease) { +func (chs *ChartChangeSync) maybeMirror(fhr fluxv1beta1.HelmRelease) { chartSource := fhr.Spec.ChartSource.GitChartSource if chartSource != nil { if ok := chs.mirrors.Mirror(mirrorName(chartSource), git.Remote{chartSource.GitURL}, git.ReadOnly); !ok { @@ -271,16 +271,16 @@ func (chs *ChartChangeSync) maybeMirror(fhr fluxv1beta1.FluxHelmRelease) { } // ReconcileReleaseDef asks the ChartChangeSync to examine the release -// associated with a FluxHelmRelease, and install or upgrade the +// associated with a HelmRelease, and install or upgrade the // release if the chart it refers to has changed. -func (chs *ChartChangeSync) ReconcileReleaseDef(fhr fluxv1beta1.FluxHelmRelease) { +func (chs *ChartChangeSync) ReconcileReleaseDef(fhr fluxv1beta1.HelmRelease) { chs.reconcileReleaseDef(fhr) } // reconcileReleaseDef looks up the helm release associated with a -// FluxHelmRelease resource, and either installs, upgrades, or does +// HelmRelease resource, and either installs, upgrades, or does // nothing, depending on the state (or absence) of the release. -func (chs *ChartChangeSync) reconcileReleaseDef(fhr fluxv1beta1.FluxHelmRelease) { +func (chs *ChartChangeSync) reconcileReleaseDef(fhr fluxv1beta1.HelmRelease) { releaseName := release.GetReleaseName(fhr) // There's no exact way in the Helm API to test whether a release @@ -309,23 +309,23 @@ func (chs *ChartChangeSync) reconcileReleaseDef(fhr fluxv1beta1.FluxHelmRelease) repo, ok := chs.mirrors.Get(mirrorName(chartSource)) if !ok { chs.maybeMirror(fhr) - chs.setCondition(&fhr, fluxv1beta1.FluxHelmReleaseChartFetched, v1.ConditionUnknown, ReasonGitNotReady, "git repo "+chartSource.GitURL+" not mirrored yet") + chs.setCondition(&fhr, fluxv1beta1.HelmReleaseChartFetched, v1.ConditionUnknown, ReasonGitNotReady, "git repo "+chartSource.GitURL+" not mirrored yet") chs.logger.Log("info", "chart repo not cloned yet", "releaseName", releaseName, "resource", fmt.Sprintf("%s:%s/%s", fhr.Namespace, fhr.Kind, fhr.Name)) } else { status, err := repo.Status() if status != git.RepoReady { - chs.setCondition(&fhr, fluxv1beta1.FluxHelmReleaseChartFetched, v1.ConditionUnknown, ReasonGitNotReady, "git repo not mirrored yet: "+err.Error()) + chs.setCondition(&fhr, fluxv1beta1.HelmReleaseChartFetched, v1.ConditionUnknown, ReasonGitNotReady, "git repo not mirrored yet: "+err.Error()) chs.logger.Log("info", "chart repo not ready yet", "releaseName", releaseName, "resource", fmt.Sprintf("%s:%s/%s", fhr.Namespace, fhr.Kind, fhr.Name), "status", string(status), "err", err) } } return } - chs.setCondition(&fhr, fluxv1beta1.FluxHelmReleaseChartFetched, v1.ConditionTrue, ReasonCloned, "successfully cloned git repo") + chs.setCondition(&fhr, fluxv1beta1.HelmReleaseChartFetched, v1.ConditionTrue, ReasonCloned, "successfully cloned git repo") chartPath = filepath.Join(chartClone.export.Dir(), chartSource.Path) if chs.config.UpdateDeps { if err := updateDependencies(chartPath); err != nil { - chs.setCondition(&fhr, fluxv1beta1.FluxHelmReleaseReleased, v1.ConditionFalse, ReasonDependencyFailed, err.Error()) + chs.setCondition(&fhr, fluxv1beta1.HelmReleaseReleased, v1.ConditionFalse, ReasonDependencyFailed, err.Error()) chs.logger.Log("warning", "Failed to update chart dependencies", "namespace", fhr.Namespace, "name", fhr.Name, "error", err) return } @@ -335,22 +335,22 @@ func (chs *ChartChangeSync) reconcileReleaseDef(fhr fluxv1beta1.FluxHelmRelease) chartSource := fhr.Spec.ChartSource.RepoChartSource path, err := ensureChartFetched(chs.config.ChartCache, chartSource) if err != nil { - chs.setCondition(&fhr, fluxv1beta1.FluxHelmReleaseChartFetched, v1.ConditionFalse, ReasonDownloadFailed, "chart download failed: "+err.Error()) + chs.setCondition(&fhr, fluxv1beta1.HelmReleaseChartFetched, v1.ConditionFalse, ReasonDownloadFailed, "chart download failed: "+err.Error()) chs.logger.Log("info", "chart download failed", "releaseName", releaseName, "resource", fhr.ResourceID().String(), "err", err) return } - chs.setCondition(&fhr, fluxv1beta1.FluxHelmReleaseChartFetched, v1.ConditionTrue, ReasonDownloaded, "chart fetched: "+filepath.Base(path)) + chs.setCondition(&fhr, fluxv1beta1.HelmReleaseChartFetched, v1.ConditionTrue, ReasonDownloaded, "chart fetched: "+filepath.Base(path)) chartPath = path } if rel == nil { _, err := chs.release.Install(chartPath, releaseName, fhr, release.InstallAction, opts, &chs.kubeClient) if err != nil { - chs.setCondition(&fhr, fluxv1beta1.FluxHelmReleaseReleased, v1.ConditionFalse, ReasonInstallFailed, err.Error()) + chs.setCondition(&fhr, fluxv1beta1.HelmReleaseReleased, v1.ConditionFalse, ReasonInstallFailed, err.Error()) chs.logger.Log("warning", "Failed to install chart", "namespace", fhr.Namespace, "name", fhr.Name, "error", err) return } - chs.setCondition(&fhr, fluxv1beta1.FluxHelmReleaseReleased, v1.ConditionTrue, ReasonSuccess, "helm install succeeded") + chs.setCondition(&fhr, fluxv1beta1.HelmReleaseReleased, v1.ConditionTrue, ReasonSuccess, "helm install succeeded") return } @@ -362,11 +362,11 @@ func (chs *ChartChangeSync) reconcileReleaseDef(fhr fluxv1beta1.FluxHelmRelease) if changed { _, err := chs.release.Install(chartPath, releaseName, fhr, release.UpgradeAction, opts, &chs.kubeClient) if err != nil { - chs.setCondition(&fhr, fluxv1beta1.FluxHelmReleaseReleased, v1.ConditionFalse, ReasonUpgradeFailed, err.Error()) + chs.setCondition(&fhr, fluxv1beta1.HelmReleaseReleased, v1.ConditionFalse, ReasonUpgradeFailed, err.Error()) chs.logger.Log("warning", "Failed to upgrade chart", "namespace", fhr.Namespace, "name", fhr.Name, "error", err) return } - chs.setCondition(&fhr, fluxv1beta1.FluxHelmReleaseReleased, v1.ConditionTrue, ReasonSuccess, "helm upgrade succeeded") + chs.setCondition(&fhr, fluxv1beta1.HelmReleaseReleased, v1.ConditionTrue, ReasonSuccess, "helm upgrade succeeded") } } @@ -377,7 +377,7 @@ func (chs *ChartChangeSync) reconcileReleaseDef(fhr fluxv1beta1.FluxHelmRelease) func (chs *ChartChangeSync) reapplyReleaseDefs() error { resources, err := chs.getCustomResources() if err != nil { - return fmt.Errorf("failed to get FluxHelmRelease resources from the API server: %s", err.Error()) + return fmt.Errorf("failed to get HelmRelease resources from the API server: %s", err.Error()) } for _, fhr := range resources { @@ -387,9 +387,9 @@ func (chs *ChartChangeSync) reapplyReleaseDefs() error { } // DeleteRelease deletes the helm release associated with a -// FluxHelmRelease. This exists mainly so that the operator code can +// HelmRelease. This exists mainly so that the operator code can // call it when it is handling a resource deletion. -func (chs *ChartChangeSync) DeleteRelease(fhr fluxv1beta1.FluxHelmRelease) { +func (chs *ChartChangeSync) DeleteRelease(fhr fluxv1beta1.HelmRelease) { // FIXME(michael): these may need to stop mirroring a repo. name := release.GetReleaseName(fhr) err := chs.release.Delete(name) @@ -416,15 +416,15 @@ func (chs *ChartChangeSync) getNamespaces() ([]string, error) { } // getCustomResources assembles all custom resources in all namespaces -func (chs *ChartChangeSync) getCustomResources() ([]fluxv1beta1.FluxHelmRelease, error) { +func (chs *ChartChangeSync) getCustomResources() ([]fluxv1beta1.HelmRelease, error) { namespaces, err := chs.getNamespaces() if err != nil { return nil, err } - var fhrs []fluxv1beta1.FluxHelmRelease + var fhrs []fluxv1beta1.HelmRelease for _, ns := range namespaces { - list, err := chs.ifClient.FluxV1beta1().FluxHelmReleases(ns).List(metav1.ListOptions{}) + list, err := chs.ifClient.FluxV1beta1().HelmReleases(ns).List(metav1.ListOptions{}) if err != nil { return nil, err } @@ -440,15 +440,15 @@ func (chs *ChartChangeSync) getCustomResources() ([]fluxv1beta1.FluxHelmRelease, // information. New information is something that adds or changes the // status, reason or message (i.e., anything but the transition time) // for one of the types of condition. -func (chs *ChartChangeSync) setCondition(fhr *fluxv1beta1.FluxHelmRelease, typ fluxv1beta1.FluxHelmReleaseConditionType, st v1.ConditionStatus, reason, message string) error { +func (chs *ChartChangeSync) setCondition(fhr *fluxv1beta1.HelmRelease, typ fluxv1beta1.HelmReleaseConditionType, st v1.ConditionStatus, reason, message string) error { for _, c := range fhr.Status.Conditions { if c.Type == typ && c.Status == st && c.Message == message && c.Reason == reason { return nil } } - fhrClient := chs.ifClient.FluxV1beta1().FluxHelmReleases(fhr.Namespace) - cond := fluxv1beta1.FluxHelmReleaseCondition{ + fhrClient := chs.ifClient.FluxV1beta1().HelmReleases(fhr.Namespace) + cond := fluxv1beta1.HelmReleaseCondition{ Type: typ, Status: st, LastTransitionTime: metav1.Now(), @@ -503,7 +503,7 @@ func sortChartFields(c *hapi_chart.Chart) *hapi_chart.Chart { // shouldUpgrade returns true if the current running values or chart // don't match what the repo says we ought to be running, based on // doing a dry run install from the chart in the git repo. -func (chs *ChartChangeSync) shouldUpgrade(chartsRepo string, currRel *hapi_release.Release, fhr fluxv1beta1.FluxHelmRelease) (bool, error) { +func (chs *ChartChangeSync) shouldUpgrade(chartsRepo string, currRel *hapi_release.Release, fhr fluxv1beta1.HelmRelease) (bool, error) { if currRel == nil { return false, fmt.Errorf("No Chart release provided for %v", fhr.GetName()) } diff --git a/integrations/helm/operator/operator.go b/integrations/helm/operator/operator.go index 8df5a7f58..466fdc2bd 100644 --- a/integrations/helm/operator/operator.go +++ b/integrations/helm/operator/operator.go @@ -34,26 +34,26 @@ const ( const ( // ChartSynced is used as part of the Event 'reason' when the Chart related to the - // a FluxHelmRelease gets released/updated + // a HelmRelease gets released/updated ChartSynced = "ChartSynced" // ErrChartSync is used as part of the Event 'reason' when the related Chart related to the - // a FluxHelmRelease fails to be released/updated + // a HelmRelease fails to be released/updated ErrChartSync = "ErrChartSync" // MessageChartSynced - the message used for Events when a resource // fails to sync due to failing to release the Chart - MessageChartSynced = "Chart managed by FluxHelmRelease processed successfully" - // MessageErrChartSync - the message used for an Event fired when a FluxHelmRelease + MessageChartSynced = "Chart managed by HelmRelease processed successfully" + // MessageErrChartSync - the message used for an Event fired when a HelmRelease // is synced successfully - MessageErrChartSync = "Chart %s managed by FluxHelmRelease failed to be processed" + MessageErrChartSync = "Chart %s managed by HelmRelease failed to be processed" ) -// Controller is the operator implementation for FluxHelmRelease resources +// Controller is the operator implementation for HelmRelease resources type Controller struct { logger log.Logger logDiffs bool - fhrLister iflister.FluxHelmReleaseLister + fhrLister iflister.HelmReleaseLister fhrSynced cache.InformerSynced sync *chartsync.ChartChangeSync @@ -75,7 +75,7 @@ func New( logger log.Logger, logReleaseDiffs bool, kubeclientset kubernetes.Interface, - fhrInformer fhrv1.FluxHelmReleaseInformer, + fhrInformer fhrv1.HelmReleaseInformer, sync *chartsync.ChartChangeSync) *Controller { // Add helm-operator types to the default Kubernetes Scheme so Events can be @@ -98,7 +98,7 @@ func New( controller.logger.Log("info", "Setting up event handlers") - // ----- EVENT HANDLERS for FluxHelmRelease resources change --------- + // ----- EVENT HANDLERS for HelmRelease resources change --------- fhrInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ AddFunc: func(new interface{}) { controller.logger.Log("info", "CREATING release") @@ -202,7 +202,7 @@ func (c *Controller) processNextWorkItem() bool { return nil } // Run the syncHandler, passing it the namespace/name string of the - // FluxHelmRelease resource to sync the corresponding Chart release. + // HelmRelease resource to sync the corresponding Chart release. // If the sync failed, then we return while the item will get requeued if err := c.syncHandler(key); err != nil { return fmt.Errorf("error syncing '%s': %s", key, err.Error()) @@ -237,11 +237,11 @@ func (c *Controller) syncHandler(key string) error { } // Custom Resource fhr contains all information we need to know about the Chart release - fhr, err := c.fhrLister.FluxHelmReleases(namespace).Get(name) + fhr, err := c.fhrLister.HelmReleases(namespace).Get(name) if err != nil { if k8serrors.IsNotFound(err) { - c.logger.Log("info", fmt.Sprintf("FluxHelmRelease '%s' referred to in work queue no longer exists", key)) - runtime.HandleError(fmt.Errorf("FluxHelmRelease '%s' referred to in work queue no longer exists", key)) + c.logger.Log("info", fmt.Sprintf("HelmRelease '%s' referred to in work queue no longer exists", key)) + runtime.HandleError(fmt.Errorf("HelmRelease '%s' referred to in work queue no longer exists", key)) return nil } c.logger.Log("error", err.Error()) @@ -253,12 +253,12 @@ func (c *Controller) syncHandler(key string) error { return nil } -func checkCustomResourceType(logger log.Logger, obj interface{}) (flux_v1beta1.FluxHelmRelease, bool) { - var fhr *flux_v1beta1.FluxHelmRelease +func checkCustomResourceType(logger log.Logger, obj interface{}) (flux_v1beta1.HelmRelease, bool) { + var fhr *flux_v1beta1.HelmRelease var ok bool - if fhr, ok = obj.(*flux_v1beta1.FluxHelmRelease); !ok { - logger.Log("error", fmt.Sprintf("FluxHelmRelease Event Watch received an invalid object: %#v", obj)) - return flux_v1beta1.FluxHelmRelease{}, false + if fhr, ok = obj.(*flux_v1beta1.HelmRelease); !ok { + logger.Log("error", fmt.Sprintf("HelmRelease Event Watch received an invalid object: %#v", obj)) + return flux_v1beta1.HelmRelease{}, false } return *fhr, true } @@ -274,9 +274,9 @@ func getCacheKey(obj interface{}) (string, error) { return key, nil } -// enqueueJob takes a FluxHelmRelease resource and converts it into a namespace/name +// enqueueJob takes a HelmRelease resource and converts it into a namespace/name // string which is then put onto the work queue. This method should not be -// passed resources of any type other than FluxHelmRelease. +// passed resources of any type other than HelmRelease. func (c *Controller) enqueueJob(obj interface{}) { var key string var err error @@ -308,7 +308,7 @@ func (c *Controller) enqueueUpateJob(old, new interface{}) { } } -func (c *Controller) deleteRelease(fhr flux_v1beta1.FluxHelmRelease) { +func (c *Controller) deleteRelease(fhr flux_v1beta1.HelmRelease) { c.logger.Log("info", "DELETING release") c.logger.Log("info", "Custom Resource driven release deletion") c.sync.DeleteRelease(fhr) diff --git a/integrations/helm/release/release.go b/integrations/helm/release/release.go index 8dbe79cb1..2983ae084 100644 --- a/integrations/helm/release/release.go +++ b/integrations/helm/release/release.go @@ -38,7 +38,7 @@ type Release struct { type Releaser interface { GetCurrent() (map[string][]DeployInfo, error) GetDeployedRelease(name string) (*hapi_release.Release, error) - Install(dir string, releaseName string, fhr flux_v1beta1.FluxHelmRelease, action Action, opts InstallOptions) (*hapi_release.Release, error) + Install(dir string, releaseName string, fhr flux_v1beta1.HelmRelease, action Action, opts InstallOptions) (*hapi_release.Release, error) } type DeployInfo struct { @@ -61,7 +61,7 @@ func New(logger log.Logger, helmClient *k8shelm.Client) *Release { // GetReleaseName either retrieves the release name from the Custom Resource or constructs a new one // in the form : $Namespace-$CustomResourceName -func GetReleaseName(fhr flux_v1beta1.FluxHelmRelease) string { +func GetReleaseName(fhr flux_v1beta1.HelmRelease) string { namespace := fhr.Namespace if namespace == "" { namespace = "default" @@ -120,14 +120,14 @@ func (r *Release) canDelete(name string) (bool, error) { } // Install performs a Chart release given the directory containing the -// charts, and the FluxHelmRelease specifying the release. Depending +// charts, and the HelmRelease specifying the release. Depending // on the release type, this is either a new release, or an upgrade of // an existing one. // // TODO(michael): cloneDir is only relevant if installing from git; // either split this procedure into two varieties, or make it more // general and calculate the path to the chart in the caller. -func (r *Release) Install(chartPath, releaseName string, fhr flux_v1beta1.FluxHelmRelease, action Action, opts InstallOptions, kubeClient *kubernetes.Clientset) (*hapi_release.Release, error) { +func (r *Release) Install(chartPath, releaseName string, fhr flux_v1beta1.HelmRelease, action Action, opts InstallOptions, kubeClient *kubernetes.Clientset) (*hapi_release.Release, error) { if chartPath == "" { return nil, fmt.Errorf("empty path to chart supplied for resource %q", fhr.ResourceID().String()) } @@ -278,7 +278,7 @@ func (r *Release) GetCurrent() (map[string][]DeployInfo, error) { // annotateResources annotates each of the resources created (or updated) // by the release so that we can spot them. -func (r *Release) annotateResources(release *hapi_release.Release, fhr flux_v1beta1.FluxHelmRelease) error { +func (r *Release) annotateResources(release *hapi_release.Release, fhr flux_v1beta1.HelmRelease) error { args := []string{"annotate", "--overwrite"} args = append(args, "--namespace", release.Namespace) args = append(args, "-f", "-") @@ -296,10 +296,10 @@ func (r *Release) annotateResources(release *hapi_release.Release, fhr flux_v1be return err } -// fhrResourceID constructs a flux.ResourceID for a FluxHelmRelease +// fhrResourceID constructs a flux.ResourceID for a HelmRelease // resource. -func fhrResourceID(fhr flux_v1beta1.FluxHelmRelease) flux.ResourceID { - return flux.MakeResourceID(fhr.Namespace, "FluxHelmRelease", fhr.Name) +func fhrResourceID(fhr flux_v1beta1.HelmRelease) flux.ResourceID { + return flux.MakeResourceID(fhr.Namespace, "HelmRelease", fhr.Name) } // Merges source and destination `chartutils.Values`, preferring values from the source Values diff --git a/integrations/helm/status/conditions.go b/integrations/helm/status/conditions.go index 6681d31e9..0d154b588 100644 --- a/integrations/helm/status/conditions.go +++ b/integrations/helm/status/conditions.go @@ -11,8 +11,8 @@ import ( // We can't rely on having UpdateStatus, or strategic merge patching // for custom resources. So we have to create an object which // represents the merge path or JSON patch to apply. -func UpdateConditionsPatch(status *v1beta1.FluxHelmReleaseStatus, updates ...v1beta1.FluxHelmReleaseCondition) (types.PatchType, interface{}) { - newConditions := make([]v1beta1.FluxHelmReleaseCondition, len(status.Conditions)) +func UpdateConditionsPatch(status *v1beta1.HelmReleaseStatus, updates ...v1beta1.HelmReleaseCondition) (types.PatchType, interface{}) { + newConditions := make([]v1beta1.HelmReleaseCondition, len(status.Conditions)) oldConditions := status.Conditions for i, c := range oldConditions { newConditions[i] = c @@ -35,8 +35,8 @@ updates: } } -// UpdateConditions applies the updates to the FluxHelmRelease given, and patches the resource in the cluster. -func UpdateConditions(client v1beta1client.FluxHelmReleaseInterface, fhr *v1beta1.FluxHelmRelease, updates ...v1beta1.FluxHelmReleaseCondition) error { +// UpdateConditions applies the updates to the HelmRelease given, and patches the resource in the cluster. +func UpdateConditions(client v1beta1client.HelmReleaseInterface, fhr *v1beta1.HelmRelease, updates ...v1beta1.HelmReleaseCondition) error { t, obj := UpdateConditionsPatch(&fhr.Status, updates...) bytes, err := json.Marshal(obj) if err != nil { diff --git a/integrations/helm/status/status.go b/integrations/helm/status/status.go index 1fb19d306..f609385da 100644 --- a/integrations/helm/status/status.go +++ b/integrations/helm/status/status.go @@ -1,14 +1,14 @@ /* -This package is for maintaining the link between `FluxHelmRelease` +This package is for maintaining the link between `HelmRelease` resources and the Helm releases to which they correspond. Specifically, - 1. updating the `FluxHelmRelease` status based on the progress of + 1. updating the `HelmRelease` status based on the progress of syncing, and the state of the associated Helm release; and, 2. attributing each resource in a Helm release (under our control) to - the associated `FluxHelmRelease`. + the associated `HelmRelease`. */ package status @@ -56,14 +56,14 @@ bail: break bail case <-ticker.C: } - // Look up FluxHelmReleases + // Look up HelmReleases namespaces, err := a.kube.CoreV1().Namespaces().List(metav1.ListOptions{}) if err != nil { logErr = err break bail } for _, ns := range namespaces.Items { - fhrClient := a.fluxhelm.FluxV1beta1().FluxHelmReleases(ns.Name) + fhrClient := a.fluxhelm.FluxV1beta1().HelmReleases(ns.Name) fhrs, err := fhrClient.List(metav1.ListOptions{}) if err != nil { logErr = err @@ -92,7 +92,7 @@ bail: logger.Log("loop", "stopping", "err", logErr) } -func UpdateReleaseStatus(client v1beta1client.FluxHelmReleaseInterface, fhr v1beta1.FluxHelmRelease, releaseName, releaseStatus string) error { +func UpdateReleaseStatus(client v1beta1client.HelmReleaseInterface, fhr v1beta1.HelmRelease, releaseName, releaseStatus string) error { patchBytes, err := json.Marshal(map[string]interface{}{ "status": map[string]interface{}{ "releaseName": releaseName, diff --git a/site/helm-integration.md b/site/helm-integration.md index 5432262dd..417bde884 100644 --- a/site/helm-integration.md +++ b/site/helm-integration.md @@ -16,9 +16,9 @@ will apply it to the cluster, and once it's in the cluster, the Helm Operator will make sure the release exists by installing or upgrading it. -## The `FluxHelmRelease` custom resource +## The `HelmRelease` custom resource -Each release of a chart is declared by a `FluxHelmRelease` +Each release of a chart is declared by a `HelmRelease` resource. The schema for these resources is given in [the custom resource definition](../deploy-helm/flux-helm-release-crd.yaml). They look like this: @@ -26,7 +26,7 @@ look like this: ```yaml --- apiVersion: flux.weave.works/v1beta1 -kind: FluxHelmRelease +kind: HelmRelease metadata: name: rabbit namespace: default @@ -83,11 +83,11 @@ ssh_config; this is also demonstrated in the example deployment. ### What the Helm Operator does -When the Helm Operator sees a `FluxHelmRelease` resource in the +When the Helm Operator sees a `HelmRelease` resource in the cluster, it either installs or upgrades the named Helm release so that the chart is released as specified. -It will also notice when a `FluxHelmRelease` resource is updated, and +It will also notice when a `HelmRelease` resource is updated, and take action accordingly. ## Supplying values to the chart @@ -98,12 +98,12 @@ two ways. ### `.spec.values` This is a YAML map as you'd put in a file and supply to Helm with `-f -values.yaml`, but inlined into the FluxHelmRelease manifest. For +values.yaml`, but inlined into the HelmRelease manifest. For example, ```yaml apiVersion: flux.weave.works/v1beta1 -kind: FluxHelmRelease +kind: HelmRelease # metadata: ... spec: # chart: ... @@ -119,7 +119,7 @@ spec: ### `.spec.valueFileSecrets` This is a list of secrets (in the same namespace as the -FluxHelmRelease) from which to take values. The secrets must each +HelmRelease) from which to take values. The secrets must each contain an entry for `values.yaml`. The values are merged in the order given, with later values @@ -160,12 +160,12 @@ data: values.yaml: ``` -Then, you could refer to the secret in a `FluxHelmRelease`, and the +Then, you could refer to the secret in a `HelmRelease`, and the values would be used when the chart was installed: ```yaml apiVersion: flux.weave.works/v1beta1 -kind: FluxHelmRelease +kind: HelmRelease metadata: name: uses-secret namespace: dev @@ -196,7 +196,7 @@ included as entries in the secret. The names given in `repositories.yaml` do not have significance; it's the URLs that will be used to find credentials, since it's a repository URL that is given -in the `FluxHelmRelease`[*](#why-repo-urls). +in the `HelmRelease`[*](#why-repo-urls). ### Authentication for Git repos @@ -207,16 +207,16 @@ access. To provide an SSH key, put the key in a secret under the entry `"identity"`, and refer to that secret as the `chartPullSecret` in the -`FluxHelmRelease`. +`HelmRelease`. -## Upgrading images in a FluxHelmRelease using Flux +## Upgrading images in a HelmRelease using Flux -If the chart you're using in a FluxHelmRelease lets you specify the +If the chart you're using in a HelmRelease lets you specify the particular images to run, you will usually be able to update them with Flux, the same way you can with Deployments and so on. Flux interprets certain commonly used structures in the `values` -section of a `FluxHelmRelease` as referring to images. The following +section of a `HelmRelease` as referring to images. The following are understood (showing just the `values` section): ```yaml @@ -258,10 +258,10 @@ values: port: 4040 ``` -### Using annotations to control updates to FluxHelmRelease resources +### Using annotations to control updates to HelmRelease resources You can use the [same annotations](./using.md#using-annotations) in -the `FluxHelmRelease` as you would for a Deployment or other workload, +the `HelmRelease` as you would for a Deployment or other workload, to control updates and automation. For the purpose of specifying filters, the container name is either `chart-image` (if at the top level), or the key under which the image is given (e.g., `"subsystem"` @@ -271,10 +271,10 @@ from the example above). **Why use URLs to refer to repositories, rather than names?** [^](#cite-why-repo-urls) -A `FluxHelmRelease` must be able to stand on its own. If we used names +A `HelmRelease` must be able to stand on its own. If we used names in the spec, which were resolved to URLs elsewhere (e.g., in a `repositories.yaml` supplied to the operator), it would be possible to -change the meaning of a `FluxHelmRelease` without altering it. This is +change the meaning of a `HelmRelease` without altering it. This is undesirable because it makes it hard to specify exactly what you want, in the one place; or to read exactly what is being specified, in the one place. In other words, it's better to be explicit.