diff --git a/.circleci/config.yml b/.circleci/config.yml index b4ab0c12b..9f481610f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,6 +20,7 @@ jobs: if [ -z "${CIRCLE_TAG}" -a "${CIRCLE_BRANCH}" == "master" ]; then docker login -u "$DOCKER_REGISTRY_USER" -p "$DOCKER_REGISTRY_PASSWORD" quay.io docker push "quay.io/weaveworks/flux:$(docker/image-tag)" + docker push "quay.io/weaveworks/helm-operator:$(docker/image-tag)" fi - deploy: @@ -31,6 +32,7 @@ jobs: bin/upload-binaries docker login -u "$DOCKER_REGISTRY_USER" -p "$DOCKER_REGISTRY_PASSWORD" quay.io docker push "quay.io/weaveworks/flux:$(docker/image-tag)" + docker push "quay.io/weaveworks/helm-operator:$(docker/image-tag)" fi workflows: diff --git a/Gopkg.lock b/Gopkg.lock index 725d0094c..943750cec 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -465,6 +465,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "ed6298cf789833d38a643c55b3caa7914f29d83a68fc0139dce6ce84d17b6b12" + inputs-digest = "3629212a518505ac90fb570403f2993c2b16257cff30ecc50363cfadd1c686e4" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index 105ddd8f6..dc8f23686 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -31,7 +31,7 @@ required = ["k8s.io/code-generator/cmd/client-gen"] [[constraint]] name = "k8s.io/helm" - version = "v2.8.0" + version = "v2.8.1" [[constraint]] name = "google.golang.org/grpc" diff --git a/apis/helm.integrations.flux.weave.works/register.go b/apis/helm.integrations.flux.weave.works/register.go new file mode 100644 index 000000000..3904814b4 --- /dev/null +++ b/apis/helm.integrations.flux.weave.works/register.go @@ -0,0 +1,5 @@ +package fluxintegrations + +const ( + GroupName = "helm.integrations.flux.weave.works" +) diff --git a/apis/integrations.flux/v1/doc.go b/apis/helm.integrations.flux.weave.works/v1alpha/doc.go similarity index 56% rename from apis/integrations.flux/v1/doc.go rename to apis/helm.integrations.flux.weave.works/v1alpha/doc.go index 654f61da8..11fcfbd64 100644 --- a/apis/integrations.flux/v1/doc.go +++ b/apis/helm.integrations.flux.weave.works/v1alpha/doc.go @@ -1,5 +1,5 @@ // +k8s:deepcopy-gen=package,register // Package v1 is the v1 version of the API. -// +groupName=integrations.flux -package v1 +// +groupName=helm.integrations.flux.weave.works +package v1alpha diff --git a/apis/integrations.flux/v1/register.go b/apis/helm.integrations.flux.weave.works/v1alpha/register.go similarity index 86% rename from apis/integrations.flux/v1/register.go rename to apis/helm.integrations.flux.weave.works/v1alpha/register.go index 8e061dfaf..64a1aa58d 100644 --- a/apis/integrations.flux/v1/register.go +++ b/apis/helm.integrations.flux.weave.works/v1alpha/register.go @@ -1,15 +1,15 @@ -package v1 +package v1alpha import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" - fluxintegrations "github.com/weaveworks/flux/apis/integrations.flux" + fluxintegrations "github.com/weaveworks/flux/apis/helm.integrations.flux.weave.works" ) // SchemeGroupVersion is group version used to register these objects -var SchemeGroupVersion = schema.GroupVersion{Group: fluxintegrations.GroupName, Version: "v1"} +var SchemeGroupVersion = schema.GroupVersion{Group: fluxintegrations.GroupName, Version: "v1alpha"} // Resource takes an unqualified resource and returns a Group qualified GroupResource func Resource(resource string) schema.GroupResource { @@ -34,8 +34,8 @@ func init() { // Adds the list of known types to api.Scheme. func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, - &FluxHelmResource{}, - &FluxHelmResourceList{}, + &FluxHelmRelease{}, + &FluxHelmReleaseList{}, ) metav1.AddToGroupVersion(scheme, SchemeGroupVersion) return nil diff --git a/apis/helm.integrations.flux.weave.works/v1alpha/types.go b/apis/helm.integrations.flux.weave.works/v1alpha/types.go new file mode 100644 index 000000000..ee64b7455 --- /dev/null +++ b/apis/helm.integrations.flux.weave.works/v1alpha/types.go @@ -0,0 +1,47 @@ +package v1alpha + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + //"k8s.io/apimachinery/pkg/runtime" +) + +// +genclient +// +genclient:noStatus +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// FluxHelmRelease represents custom resource associated with a Helm Chart +type FluxHelmRelease struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata"` + + Spec FluxHelmReleaseSpec `json:"spec"` +} + +// FluxHelmReleaseSpec is the spec for a FluxHelmRelease resource +// FluxHelmReleaseSpec +type FluxHelmReleaseSpec struct { + ChartGitPath string `json:"chartGitPath"` + ReleaseName string `json:"releaseName,omitempty"` + Values []HelmChartParam `json:"values,omitempty"` +} + +// HelmChartParam represents Helm Chart customization +// it will be applied to override the values.yaml and/or the Chart itself +// Name ... parameter name; if missing this parameter will be discarded +// Value ... + +// HelmChartParam ... user customization of Chart parameterized values +type HelmChartParam struct { + Name string `json:"name"` + Value string `json:"value"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// FluxHelmReleaseList is a list of FluxHelmRelease resources +type FluxHelmReleaseList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []FluxHelmRelease `json:"items"` +} diff --git a/apis/integrations.flux/v1/zz_generated.deepcopy.go b/apis/helm.integrations.flux.weave.works/v1alpha/zz_generated.deepcopy.go similarity index 73% rename from apis/integrations.flux/v1/zz_generated.deepcopy.go rename to apis/helm.integrations.flux.weave.works/v1alpha/zz_generated.deepcopy.go index a2676214b..33b0395da 100644 --- a/apis/integrations.flux/v1/zz_generated.deepcopy.go +++ b/apis/helm.integrations.flux.weave.works/v1alpha/zz_generated.deepcopy.go @@ -1,7 +1,7 @@ // +build !ignore_autogenerated /* -Copyright 2018 The Kubernetes Authors. +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. @@ -18,14 +18,14 @@ limitations under the License. // This file was autogenerated by deepcopy-gen. Do not edit it manually! -package v1 +package v1alpha import ( runtime "k8s.io/apimachinery/pkg/runtime" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FluxHelmResource) DeepCopyInto(out *FluxHelmResource) { +func (in *FluxHelmRelease) DeepCopyInto(out *FluxHelmRelease) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) @@ -33,18 +33,18 @@ func (in *FluxHelmResource) DeepCopyInto(out *FluxHelmResource) { return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FluxHelmResource. -func (in *FluxHelmResource) DeepCopy() *FluxHelmResource { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FluxHelmRelease. +func (in *FluxHelmRelease) DeepCopy() *FluxHelmRelease { if in == nil { return nil } - out := new(FluxHelmResource) + out := new(FluxHelmRelease) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *FluxHelmResource) DeepCopyObject() runtime.Object { +func (in *FluxHelmRelease) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } else { @@ -53,13 +53,13 @@ func (in *FluxHelmResource) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FluxHelmResourceList) DeepCopyInto(out *FluxHelmResourceList) { +func (in *FluxHelmReleaseList) DeepCopyInto(out *FluxHelmReleaseList) { *out = *in out.TypeMeta = in.TypeMeta out.ListMeta = in.ListMeta if in.Items != nil { in, out := &in.Items, &out.Items - *out = make([]FluxHelmResource, len(*in)) + *out = make([]FluxHelmRelease, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -67,18 +67,18 @@ func (in *FluxHelmResourceList) DeepCopyInto(out *FluxHelmResourceList) { return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FluxHelmResourceList. -func (in *FluxHelmResourceList) DeepCopy() *FluxHelmResourceList { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FluxHelmReleaseList. +func (in *FluxHelmReleaseList) DeepCopy() *FluxHelmReleaseList { if in == nil { return nil } - out := new(FluxHelmResourceList) + out := new(FluxHelmReleaseList) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *FluxHelmResourceList) DeepCopyObject() runtime.Object { +func (in *FluxHelmReleaseList) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } else { @@ -87,22 +87,22 @@ func (in *FluxHelmResourceList) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FluxHelmResourceSpec) DeepCopyInto(out *FluxHelmResourceSpec) { +func (in *FluxHelmReleaseSpec) DeepCopyInto(out *FluxHelmReleaseSpec) { *out = *in - if in.Customizations != nil { - in, out := &in.Customizations, &out.Customizations + if in.Values != nil { + in, out := &in.Values, &out.Values *out = make([]HelmChartParam, len(*in)) copy(*out, *in) } return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FluxHelmResourceSpec. -func (in *FluxHelmResourceSpec) DeepCopy() *FluxHelmResourceSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FluxHelmReleaseSpec. +func (in *FluxHelmReleaseSpec) DeepCopy() *FluxHelmReleaseSpec { if in == nil { return nil } - out := new(FluxHelmResourceSpec) + out := new(FluxHelmReleaseSpec) in.DeepCopyInto(out) return out } diff --git a/apis/integrations.flux/register.go b/apis/integrations.flux/register.go deleted file mode 100644 index d33336d34..000000000 --- a/apis/integrations.flux/register.go +++ /dev/null @@ -1,5 +0,0 @@ -package fluxintegrations - -const ( - GroupName = "integrations.flux" -) diff --git a/apis/integrations.flux/v1/types.go b/apis/integrations.flux/v1/types.go deleted file mode 100644 index f7b4f8c8a..000000000 --- a/apis/integrations.flux/v1/types.go +++ /dev/null @@ -1,56 +0,0 @@ -package v1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - //"k8s.io/apimachinery/pkg/runtime" -) - -// +genclient -// +genclient:noStatus -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// FluxHelmResource represents custom resource associated with a Helm Chart -type FluxHelmResource struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata"` - - Spec FluxHelmResourceSpec `json:"spec"` - // Status FluxHelmResourceStatus `json:"status"` -} - -// FluxHelmResourceSpec is the spec for a FluxHelmResource resource -// FluxHelmResourceSpec -type FluxHelmResourceSpec struct { - ChartGitPath string `json:"chartgitpath"` - ReleaseName string `json:"releasename,omitempty"` - Customizations []HelmChartParam `json:"customizations,omitempty"` -} - -// HelmChartParam represents Helm Chart customization -// it will be applied to override the values.yaml and/or the Chart itself -// Name ... parameter name; if missing this parameter will be discarded -// Value ... -// Type ... type: string, integer, float; if missing, then string is the default - -// HelmChartParam ... user customization of Chart parameterized values -type HelmChartParam struct { - Name string `json:"name"` - Value string `json:"value"` -} - -/* -// FluxHelmResourceStatus is the status for a FluxHelmResource resource -type FluxHelmResourceStatus struct { - Revision string `json:"revision"` -} -*/ - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// FluxHelmResourceList is a list of FluxHelmResource resources -type FluxHelmResourceList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata"` - - Items []FluxHelmResource `json:"items"` -} diff --git a/hack/custom-boilerplate.go.txt b/bin/helm/custom-boilerplate.go.txt similarity index 100% rename from hack/custom-boilerplate.go.txt rename to bin/helm/custom-boilerplate.go.txt diff --git a/hack/update_codegen.sh b/bin/helm/update_codegen.sh similarity index 60% rename from hack/update_codegen.sh rename to bin/helm/update_codegen.sh index 33d108916..3b8534a1b 100755 --- a/hack/update_codegen.sh +++ b/bin/helm/update_codegen.sh @@ -4,10 +4,10 @@ set -o errexit set -o nounset set -o pipefail -SCRIPT_ROOT=$(dirname ${BASH_SOURCE})/.. +SCRIPT_ROOT=$(dirname ${BASH_SOURCE})/../.. CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${SCRIPT_ROOT}; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo ${GOPATH}/src/k8s.io/code-generator)} ${CODEGEN_PKG}/generate-groups.sh all github.com/weaveworks/flux/integrations/client \ - github.com/weaveworks/flux/apis integrations.flux:v1 \ - --go-header-file ${SCRIPT_ROOT}/hack/custom-boilerplate.go.txt + github.com/weaveworks/flux/apis helm.integrations.flux.weave.works:v1alpha \ + --go-header-file ${SCRIPT_ROOT}/bin/helm/custom-boilerplate.go.txt diff --git a/cmd/helm-operator/main.go b/cmd/helm-operator/main.go index 783dff0f6..2edc7602e 100644 --- a/cmd/helm-operator/main.go +++ b/cmd/helm-operator/main.go @@ -17,6 +17,7 @@ import ( clientset "github.com/weaveworks/flux/integrations/client/clientset/versioned" ifinformers "github.com/weaveworks/flux/integrations/client/informers/externalversions" fluxhelm "github.com/weaveworks/flux/integrations/helm" + "github.com/weaveworks/flux/integrations/helm/chartsync" "github.com/weaveworks/flux/integrations/helm/git" "github.com/weaveworks/flux/integrations/helm/operator" "github.com/weaveworks/flux/integrations/helm/release" @@ -42,7 +43,8 @@ var ( tillerPort *string tillerNamespace *string - crdPollInterval *time.Duration + chartsSyncInterval *time.Duration + chartsSyncTimeout *time.Duration eventHandlerWorkers *uint customKubectl *string @@ -54,11 +56,7 @@ var ( k8sSecretName *string k8sSecretVolumeMountPath *string k8sSecretDataKey *string - sshKeyBits ssh.OptionalValue - sshKeyType ssh.OptionalValue - upstreamURL *string - token *string queueWorkerCount *int name *string @@ -88,28 +86,22 @@ func init() { master = fs.String("master", "", "The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.") tillerIP = fs.String("tiller-ip", "", "Tiller IP address. Only required if out-of-cluster.") - tillerPort = fs.String("tiller-port", "", "Tiller port. Only required if out-of-cluster.") + tillerPort = fs.String("tiller-port", "", "Tiller port.") tillerNamespace = fs.String("tiller-namespace", "kube-system", "Tiller namespace. If not provided, the default is kube-system.") - crdPollInterval = fs.Duration("crd-poll-interval", 5*time.Minute, "Period at which to check for custom resources") + chartsSyncInterval = fs.Duration("charts-sync-interval", 3*time.Minute, "Interval at which to check for changed charts") + chartsSyncTimeout = fs.Duration("charts-sync-timeout", 1*time.Minute, "Timeout when checking for changed charts") eventHandlerWorkers = fs.Uint("event-handler-workers", 2, "Number of workers processing events for Flux-Helm custom resources") customKubectl = fs.String("kubernetes-kubectl", "", "Optional, explicit path to kubectl tool") - gitURL = fs.String("git-url", "", "URL of git repo with Kubernetes manifests; e.g., git@github.com:weaveworks/flux-example") - gitBranch = fs.String("git-branch", "master", "branch of git repo to use for Kubernetes manifests") - //gitConfigPath = fs.String("git-config-path", defaultGitConfigPath, "path within git repo to locate Custom Resource Kubernetes manifests (relative path)") + gitURL = fs.String("git-url", "", "URL of git repo with Helm Charts; e.g., git@github.com:weaveworks/flux-example") + gitBranch = fs.String("git-branch", "master", "branch of git repo") gitChartsPath = fs.String("git-charts-path", defaultGitChartsPath, "path within git repo to locate Helm Charts (relative path)") // k8s-secret backed ssh keyring configuration - k8sSecretName = fs.String("k8s-secret-name", "flux-git-deploy", "Name of the k8s secret used to store the private SSH key") + // generated by flux daemon k8sSecretVolumeMountPath = fs.String("k8s-secret-volume-mount-path", "/etc/fluxd/ssh", "Mount location of the k8s secret storing the private SSH key") k8sSecretDataKey = fs.String("k8s-secret-data-key", "identity", "Data key holding the private SSH key within the k8s secret") - // SSH key generation - sshKeyBits = optionalVar(fs, &ssh.KeyBitsValue{}, "ssh-keygen-bitsintegrations/", "-b argument to ssh-keygen (default unspecified)") - sshKeyType = optionalVar(fs, &ssh.KeyTypeValue{}, "ssh-keygen-type", "-t argument to ssh-keygen (default unspecified)") - - upstreamURL = fs.String("connect", "", "Connect to an upstream service e.g., Weave Cloud, at this base address") - token = fs.String("token", "", "Authentication token for upstream service") queueWorkerCount = fs.Int("queue-worker-count", 2, "Number of workers to process queue with Chart release jobs. Two by default") } @@ -140,7 +132,6 @@ func main() { }() defer func() { - // wait until stopping logger.Log("exiting...", <-errc) close(shutdown) shutdownWg.Wait() @@ -150,7 +141,7 @@ func main() { mainLogger := log.With(logger, "component", "helm-operator") // GIT REPO CONFIG ---------------------------------------------------------------------- - mainLogger.Log("info", "\t*** Setting up git repo configs") + mainLogger.Log("info", "Setting up git repo configs") gitRemoteConfigFhr, err := git.NewGitRemoteConfig(*gitURL, *gitBranch, *gitChartsPath) if err != nil { @@ -164,7 +155,7 @@ func main() { os.Exit(1) } fmt.Printf("%#v", gitRemoteConfigCh) - mainLogger.Log("info", "\t*** Finished setting up git repo configs") + mainLogger.Log("info", "Finished setting up git repo configs") // CLUSTER ACCESS ----------------------------------------------------------------------- cfg, err := clientcmd.BuildConfigFromFlags(*master, *kubeconfig) @@ -237,14 +228,33 @@ func main() { mainLogger.Log("info", "Repo cloned") // Chart releases sync due to pure Charts changes ------------------------------------ - checkoutCh := git.NewCheckout(log.With(logger, "component", "git"), gitRemoteConfigCh, gitAuth) - defer checkoutCh.Cleanup() + // the two repos are used to establish which charts may have changed in between the syncs + checkoutChCurr := git.NewCheckout(log.With(logger, "component", "git"), gitRemoteConfigCh, gitAuth) + defer checkoutChCurr.Cleanup() + + // If cloning not immediately possible, we wait until it is ----------------------------- + for { + mainLogger.Log("info", "Cloning repo ...") + ctx, cancel := context.WithTimeout(context.Background(), git.DefaultCloneTimeout) + err = checkoutChCurr.Clone(ctx, git.ChartsChangesCloneCurr) + cancel() + if err == nil { + break + } + mainLogger.Log("error", fmt.Sprintf("Failed to clone git repo [%s, %s, %s]: %v", gitRemoteConfigCh.URL, gitRemoteConfigCh.Branch, gitRemoteConfigCh.Path, err)) + time.Sleep(10 * time.Second) + } + mainLogger.Log("info", "Repo cloned") + + // Chart releases sync due to pure Charts changes ------------------------------------ + checkoutChNew := git.NewCheckout(log.With(logger, "component", "git"), gitRemoteConfigCh, gitAuth) + defer checkoutChNew.Cleanup() // If cloning not immediately possible, we wait until it is ----------------------------- for { mainLogger.Log("info", "Cloning repo ...") ctx, cancel := context.WithTimeout(context.Background(), git.DefaultCloneTimeout) - err = checkoutCh.Clone(ctx, git.ChartsChangesClone) + err = checkoutChNew.Clone(ctx, git.ChartsChangesCloneNew) cancel() if err == nil { break @@ -254,24 +264,35 @@ func main() { } mainLogger.Log("info", "Repo cloned") - // OPERATOR ----------------------------------------------------------------------------- - // CUSTOM RESOURCES CACHING SETUP ------------------------------------------------------- + //======================================================================================= + // CUSTOM RESOURCES CACHING SETUP ------------------------------------------------------- // 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) - rel := release.New(log.With(logger, "component", "release"), helmClient, checkoutFhr, checkoutCh) - opr := operator.New(log.With(logger, "component", "operator"), kubeClient, ifClient, ifInformerFactory, rel) + // Obtain reference to shared index informers for the FluxHelmRelease + fhrInformer := ifInformerFactory.Helm().V1alpha().FluxHelmReleases() + checkoutChartsSync := &release.ChartsSync{ + Curr: checkoutChCurr, + New: checkoutChNew, + } + rel := release.New(log.With(logger, "component", "release"), helmClient, checkoutFhr, checkoutChartsSync) + + // CHARTS CHANGES SYNC ----------------------------------------------------------------------------- + chartSync := chartsync.New(log.With(logger, "component", "chartsync"), *chartsSyncInterval, *chartsSyncTimeout, *kubeClient, *ifClient, fhrInformer, rel) + chartSync.Run(shutdown, errc, shutdownWg) + //--------------------------------------------------------------------------------------- + + // OPERATOR - CUSTOM RRESOURCES CHANGE SYNC ---------------------------------------------- + opr := operator.New(log.With(logger, "component", "operator"), kubeClient, fhrInformer, rel) // Starts handling k8s events related to the given resource kind go ifInformerFactory.Start(shutdown) - - shutdownWg.Add(1) if err = opr.Run(*queueWorkerCount, shutdown, shutdownWg); err != nil { msg := fmt.Sprintf("Failure to run controller: %s", err.Error()) logger.Log("error", msg) errc <- fmt.Errorf(ErrOperatorFailure, err) } - //--------------------------------------------------------------------------------------- + //======================================================================================= } // Helper functions diff --git a/deploy/helm-operator-deployment.yaml b/deploy/helm-operator-deployment.yaml index 6ae6b517d..5653a6af2 100644 --- a/deploy/helm-operator-deployment.yaml +++ b/deploy/helm-operator-deployment.yaml @@ -2,15 +2,15 @@ apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: - name: fluxhelmresources.integrations.flux + name: fluxhelmreleases.helm.integrations.flux.weave.works spec: - group: integrations.flux + group: helm.integrations.flux.weave.works names: - kind: FluxHelmResource - listKind: FluxHelmResourceList - plural: fluxhelmresources + kind: FluxHelmRelease + listKind: FluxHelmReleaseList + plural: fluxhelmreleases scope: Namespaced - version: v1 + version: v1alpha --- apiVersion: extensions/v1beta1 kind: Deployment @@ -37,18 +37,13 @@ # There are no ":latest" images for helm-operator. Find the most recent # release or image version at https://quay.io/weaveworks/flux (both have the same latest tag) # and replace the tag here. - image: quay.io/weaveworks/helm-operator:flux-helm-operator2-53d5187 + image: quay.io/weaveworks/helm-operator:alpha imagePullPolicy: IfNotPresent volumeMounts: - name: git-key mountPath: /etc/fluxd/ssh args: - # replace (at least) the following URL - - --git-url=git@github.com:weaveworks/helm-fhr-test + - --git-url=git@github.com:weaveworks/flux-helm-test - --git-branch=master - --git-charts-path=charts - # include these next two to connect to an "upstream" service - # (e.g., Weave Cloud). The token is particular to the service. - # - --connect=wss://cloud.weave.works/api/flux - # - --token=abc123abc123abc123abc123 diff --git a/integrations/artifacts/fluxhelmresource-crd.yaml b/integrations/artifacts/fluxhelmresource-crd.yaml deleted file mode 100644 index c8c16f810..000000000 --- a/integrations/artifacts/fluxhelmresource-crd.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: apiextensions.k8s.io/v1beta1 -kind: CustomResourceDefinition -metadata: - name: fluxhelmresources.integrations.flux -spec: - group: integrations.flux - names: - kind: FluxHelmResource - listKind: FluxHelmResourceList - plural: fluxhelmresources - scope: Namespaced - version: v1 diff --git a/integrations/client/clientset/versioned/clientset.go b/integrations/client/clientset/versioned/clientset.go index d1ec46f5e..a3c532781 100644 --- a/integrations/client/clientset/versioned/clientset.go +++ b/integrations/client/clientset/versioned/clientset.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Kubernetes Authors. +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. @@ -13,12 +13,11 @@ 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 versioned import ( glog "github.com/golang/glog" - integrationsv1 "github.com/weaveworks/flux/integrations/client/clientset/versioned/typed/integrations.flux/v1" + helmv1alpha "github.com/weaveworks/flux/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha" discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" @@ -26,27 +25,27 @@ import ( type Interface interface { Discovery() discovery.DiscoveryInterface - IntegrationsV1() integrationsv1.IntegrationsV1Interface + HelmV1alpha() helmv1alpha.HelmV1alphaInterface // Deprecated: please explicitly pick a version if possible. - Integrations() integrationsv1.IntegrationsV1Interface + Helm() helmv1alpha.HelmV1alphaInterface } // Clientset contains the clients for groups. Each group has exactly one // version included in a Clientset. type Clientset struct { *discovery.DiscoveryClient - integrationsV1 *integrationsv1.IntegrationsV1Client + helmV1alpha *helmv1alpha.HelmV1alphaClient } -// IntegrationsV1 retrieves the IntegrationsV1Client -func (c *Clientset) IntegrationsV1() integrationsv1.IntegrationsV1Interface { - return c.integrationsV1 +// HelmV1alpha retrieves the HelmV1alphaClient +func (c *Clientset) HelmV1alpha() helmv1alpha.HelmV1alphaInterface { + return c.helmV1alpha } -// Deprecated: Integrations retrieves the default version of IntegrationsClient. +// Deprecated: Helm retrieves the default version of HelmClient. // Please explicitly pick a version. -func (c *Clientset) Integrations() integrationsv1.IntegrationsV1Interface { - return c.integrationsV1 +func (c *Clientset) Helm() helmv1alpha.HelmV1alphaInterface { + return c.helmV1alpha } // Discovery retrieves the DiscoveryClient @@ -65,7 +64,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { } var cs Clientset var err error - cs.integrationsV1, err = integrationsv1.NewForConfig(&configShallowCopy) + cs.helmV1alpha, err = helmv1alpha.NewForConfig(&configShallowCopy) if err != nil { return nil, err } @@ -82,7 +81,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { // panics if there is an error in the config. func NewForConfigOrDie(c *rest.Config) *Clientset { var cs Clientset - cs.integrationsV1 = integrationsv1.NewForConfigOrDie(c) + cs.helmV1alpha = helmv1alpha.NewForConfigOrDie(c) cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) return &cs @@ -91,7 +90,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { // New creates a new Clientset for the given RESTClient. func New(c rest.Interface) *Clientset { var cs Clientset - cs.integrationsV1 = integrationsv1.New(c) + cs.helmV1alpha = helmv1alpha.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) return &cs diff --git a/integrations/client/clientset/versioned/doc.go b/integrations/client/clientset/versioned/doc.go index 9c6dfafa7..303d74ed2 100644 --- a/integrations/client/clientset/versioned/doc.go +++ b/integrations/client/clientset/versioned/doc.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Kubernetes Authors. +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. @@ -13,6 +13,5 @@ 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. */ - // This package has the automatically generated clientset. package versioned diff --git a/integrations/client/clientset/versioned/fake/clientset_generated.go b/integrations/client/clientset/versioned/fake/clientset_generated.go index 0667b7fc1..d9f041336 100644 --- a/integrations/client/clientset/versioned/fake/clientset_generated.go +++ b/integrations/client/clientset/versioned/fake/clientset_generated.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Kubernetes Authors. +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. @@ -13,13 +13,12 @@ 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 ( clientset "github.com/weaveworks/flux/integrations/client/clientset/versioned" - integrationsv1 "github.com/weaveworks/flux/integrations/client/clientset/versioned/typed/integrations.flux/v1" - fakeintegrationsv1 "github.com/weaveworks/flux/integrations/client/clientset/versioned/typed/integrations.flux/v1/fake" + helmv1alpha "github.com/weaveworks/flux/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha" + fakehelmv1alpha "github.com/weaveworks/flux/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha/fake" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/discovery" @@ -60,12 +59,12 @@ func (c *Clientset) Discovery() discovery.DiscoveryInterface { var _ clientset.Interface = &Clientset{} -// IntegrationsV1 retrieves the IntegrationsV1Client -func (c *Clientset) IntegrationsV1() integrationsv1.IntegrationsV1Interface { - return &fakeintegrationsv1.FakeIntegrationsV1{Fake: &c.Fake} +// HelmV1alpha retrieves the HelmV1alphaClient +func (c *Clientset) HelmV1alpha() helmv1alpha.HelmV1alphaInterface { + return &fakehelmv1alpha.FakeHelmV1alpha{Fake: &c.Fake} } -// Integrations retrieves the IntegrationsV1Client -func (c *Clientset) Integrations() integrationsv1.IntegrationsV1Interface { - return &fakeintegrationsv1.FakeIntegrationsV1{Fake: &c.Fake} +// Helm retrieves the HelmV1alphaClient +func (c *Clientset) Helm() helmv1alpha.HelmV1alphaInterface { + return &fakehelmv1alpha.FakeHelmV1alpha{Fake: &c.Fake} } diff --git a/integrations/client/clientset/versioned/fake/doc.go b/integrations/client/clientset/versioned/fake/doc.go index 8a3101e39..2af292e0c 100644 --- a/integrations/client/clientset/versioned/fake/doc.go +++ b/integrations/client/clientset/versioned/fake/doc.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Kubernetes Authors. +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. @@ -13,6 +13,5 @@ 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. */ - // This package has the automatically generated fake clientset. package fake diff --git a/integrations/client/clientset/versioned/fake/register.go b/integrations/client/clientset/versioned/fake/register.go index b168ed86b..9feb6ebbb 100644 --- a/integrations/client/clientset/versioned/fake/register.go +++ b/integrations/client/clientset/versioned/fake/register.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Kubernetes Authors. +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. @@ -13,11 +13,10 @@ 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 ( - integrationsv1 "github.com/weaveworks/flux/apis/integrations.flux/v1" + helmv1alpha "github.com/weaveworks/flux/apis/helm.integrations.flux.weave.works/v1alpha" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -48,6 +47,6 @@ func init() { // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. func AddToScheme(scheme *runtime.Scheme) { - integrationsv1.AddToScheme(scheme) + helmv1alpha.AddToScheme(scheme) } diff --git a/integrations/client/clientset/versioned/scheme/doc.go b/integrations/client/clientset/versioned/scheme/doc.go index 3d3ab5f4e..e4b5d1aba 100644 --- a/integrations/client/clientset/versioned/scheme/doc.go +++ b/integrations/client/clientset/versioned/scheme/doc.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Kubernetes Authors. +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. @@ -13,6 +13,5 @@ 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. */ - // This package contains the scheme of the automatically generated clientset. package scheme diff --git a/integrations/client/clientset/versioned/scheme/register.go b/integrations/client/clientset/versioned/scheme/register.go index 29db2f902..0ccac88b5 100644 --- a/integrations/client/clientset/versioned/scheme/register.go +++ b/integrations/client/clientset/versioned/scheme/register.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Kubernetes Authors. +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. @@ -13,11 +13,10 @@ 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 scheme import ( - integrationsv1 "github.com/weaveworks/flux/apis/integrations.flux/v1" + helmv1alpha "github.com/weaveworks/flux/apis/helm.integrations.flux.weave.works/v1alpha" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -48,6 +47,6 @@ func init() { // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. func AddToScheme(scheme *runtime.Scheme) { - integrationsv1.AddToScheme(scheme) + helmv1alpha.AddToScheme(scheme) } diff --git a/integrations/client/clientset/versioned/typed/integrations.flux/v1/doc.go b/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha/doc.go similarity index 92% rename from integrations/client/clientset/versioned/typed/integrations.flux/v1/doc.go rename to integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha/doc.go index 95b44dfa8..a5595561b 100644 --- a/integrations/client/clientset/versioned/typed/integrations.flux/v1/doc.go +++ b/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha/doc.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Kubernetes Authors. +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. @@ -13,6 +13,5 @@ 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. */ - // This package has the automatically generated typed clients. -package v1 +package v1alpha diff --git a/integrations/client/clientset/versioned/typed/integrations.flux/v1/fake/doc.go b/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha/fake/doc.go similarity index 93% rename from integrations/client/clientset/versioned/typed/integrations.flux/v1/fake/doc.go rename to integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha/fake/doc.go index 63e2c8a08..f119e9089 100644 --- a/integrations/client/clientset/versioned/typed/integrations.flux/v1/fake/doc.go +++ b/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha/fake/doc.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Kubernetes Authors. +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. @@ -13,6 +13,5 @@ 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 has the automatically generated clients. package fake diff --git a/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha/fake/fake_fluxhelmrelease.go b/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha/fake/fake_fluxhelmrelease.go new file mode 100644 index 000000000..a248716b8 --- /dev/null +++ b/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha/fake/fake_fluxhelmrelease.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 ( + v1alpha "github.com/weaveworks/flux/apis/helm.integrations.flux.weave.works/v1alpha" + 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 *FakeHelmV1alpha + ns string +} + +var fluxhelmreleasesResource = schema.GroupVersionResource{Group: "helm.integrations.flux.weave.works", Version: "v1alpha", Resource: "fluxhelmreleases"} + +var fluxhelmreleasesKind = schema.GroupVersionKind{Group: "helm.integrations.flux.weave.works", Version: "v1alpha", 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 *v1alpha.FluxHelmRelease, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(fluxhelmreleasesResource, c.ns, name), &v1alpha.FluxHelmRelease{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha.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 *v1alpha.FluxHelmReleaseList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(fluxhelmreleasesResource, fluxhelmreleasesKind, c.ns, opts), &v1alpha.FluxHelmReleaseList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha.FluxHelmReleaseList{} + for _, item := range obj.(*v1alpha.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 *v1alpha.FluxHelmRelease) (result *v1alpha.FluxHelmRelease, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(fluxhelmreleasesResource, c.ns, fluxHelmRelease), &v1alpha.FluxHelmRelease{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha.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 *v1alpha.FluxHelmRelease) (result *v1alpha.FluxHelmRelease, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(fluxhelmreleasesResource, c.ns, fluxHelmRelease), &v1alpha.FluxHelmRelease{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha.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), &v1alpha.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, &v1alpha.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 *v1alpha.FluxHelmRelease, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(fluxhelmreleasesResource, c.ns, name, data, subresources...), &v1alpha.FluxHelmRelease{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha.FluxHelmRelease), err +} diff --git a/integrations/client/clientset/versioned/typed/integrations.flux/v1/fake/fake_integrations.flux_client.go b/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha/fake/fake_helm.integrations.flux.weave.works_client.go similarity index 67% rename from integrations/client/clientset/versioned/typed/integrations.flux/v1/fake/fake_integrations.flux_client.go rename to integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha/fake/fake_helm.integrations.flux.weave.works_client.go index e6f79d79a..4140bdba0 100644 --- a/integrations/client/clientset/versioned/typed/integrations.flux/v1/fake/fake_integrations.flux_client.go +++ b/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha/fake/fake_helm.integrations.flux.weave.works_client.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Kubernetes Authors. +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. @@ -13,26 +13,25 @@ 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 ( - v1 "github.com/weaveworks/flux/integrations/client/clientset/versioned/typed/integrations.flux/v1" + v1alpha "github.com/weaveworks/flux/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha" rest "k8s.io/client-go/rest" testing "k8s.io/client-go/testing" ) -type FakeIntegrationsV1 struct { +type FakeHelmV1alpha struct { *testing.Fake } -func (c *FakeIntegrationsV1) FluxHelmResources(namespace string) v1.FluxHelmResourceInterface { - return &FakeFluxHelmResources{c, namespace} +func (c *FakeHelmV1alpha) FluxHelmReleases(namespace string) v1alpha.FluxHelmReleaseInterface { + return &FakeFluxHelmReleases{c, namespace} } // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. -func (c *FakeIntegrationsV1) RESTClient() rest.Interface { +func (c *FakeHelmV1alpha) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } diff --git a/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha/fluxhelmrelease.go b/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha/fluxhelmrelease.go new file mode 100644 index 000000000..bd7bbc492 --- /dev/null +++ b/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha/fluxhelmrelease.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 v1alpha + +import ( + v1alpha "github.com/weaveworks/flux/apis/helm.integrations.flux.weave.works/v1alpha" + 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(*v1alpha.FluxHelmRelease) (*v1alpha.FluxHelmRelease, error) + Update(*v1alpha.FluxHelmRelease) (*v1alpha.FluxHelmRelease, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha.FluxHelmRelease, error) + List(opts v1.ListOptions) (*v1alpha.FluxHelmReleaseList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha.FluxHelmRelease, err error) + FluxHelmReleaseExpansion +} + +// fluxHelmReleases implements FluxHelmReleaseInterface +type fluxHelmReleases struct { + client rest.Interface + ns string +} + +// newFluxHelmReleases returns a FluxHelmReleases +func newFluxHelmReleases(c *HelmV1alphaClient, 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 *v1alpha.FluxHelmRelease, err error) { + result = &v1alpha.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 *v1alpha.FluxHelmReleaseList, err error) { + result = &v1alpha.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 *v1alpha.FluxHelmRelease) (result *v1alpha.FluxHelmRelease, err error) { + result = &v1alpha.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 *v1alpha.FluxHelmRelease) (result *v1alpha.FluxHelmRelease, err error) { + result = &v1alpha.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 *v1alpha.FluxHelmRelease, err error) { + result = &v1alpha.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/integrations.flux/v1/generated_expansion.go b/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha/generated_expansion.go similarity index 84% rename from integrations/client/clientset/versioned/typed/integrations.flux/v1/generated_expansion.go rename to integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha/generated_expansion.go index b270cd10a..d70e937f8 100644 --- a/integrations/client/clientset/versioned/typed/integrations.flux/v1/generated_expansion.go +++ b/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha/generated_expansion.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Kubernetes Authors. +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. @@ -13,7 +13,6 @@ 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 v1alpha -package v1 - -type FluxHelmResourceExpansion interface{} +type FluxHelmReleaseExpansion interface{} diff --git a/integrations/client/clientset/versioned/typed/integrations.flux/v1/integrations.flux_client.go b/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha/helm.integrations.flux.weave.works_client.go similarity index 60% rename from integrations/client/clientset/versioned/typed/integrations.flux/v1/integrations.flux_client.go rename to integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha/helm.integrations.flux.weave.works_client.go index 3b9960579..304623a9f 100644 --- a/integrations/client/clientset/versioned/typed/integrations.flux/v1/integrations.flux_client.go +++ b/integrations/client/clientset/versioned/typed/helm.integrations.flux.weave.works/v1alpha/helm.integrations.flux.weave.works_client.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Kubernetes Authors. +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. @@ -13,32 +13,31 @@ 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 v1 +package v1alpha import ( - v1 "github.com/weaveworks/flux/apis/integrations.flux/v1" + v1alpha "github.com/weaveworks/flux/apis/helm.integrations.flux.weave.works/v1alpha" "github.com/weaveworks/flux/integrations/client/clientset/versioned/scheme" serializer "k8s.io/apimachinery/pkg/runtime/serializer" rest "k8s.io/client-go/rest" ) -type IntegrationsV1Interface interface { +type HelmV1alphaInterface interface { RESTClient() rest.Interface - FluxHelmResourcesGetter + FluxHelmReleasesGetter } -// IntegrationsV1Client is used to interact with features provided by the integrations.flux group. -type IntegrationsV1Client struct { +// HelmV1alphaClient is used to interact with features provided by the helm.integrations.flux.weave.works group. +type HelmV1alphaClient struct { restClient rest.Interface } -func (c *IntegrationsV1Client) FluxHelmResources(namespace string) FluxHelmResourceInterface { - return newFluxHelmResources(c, namespace) +func (c *HelmV1alphaClient) FluxHelmReleases(namespace string) FluxHelmReleaseInterface { + return newFluxHelmReleases(c, namespace) } -// NewForConfig creates a new IntegrationsV1Client for the given config. -func NewForConfig(c *rest.Config) (*IntegrationsV1Client, error) { +// NewForConfig creates a new HelmV1alphaClient for the given config. +func NewForConfig(c *rest.Config) (*HelmV1alphaClient, error) { config := *c if err := setConfigDefaults(&config); err != nil { return nil, err @@ -47,12 +46,12 @@ func NewForConfig(c *rest.Config) (*IntegrationsV1Client, error) { if err != nil { return nil, err } - return &IntegrationsV1Client{client}, nil + return &HelmV1alphaClient{client}, nil } -// NewForConfigOrDie creates a new IntegrationsV1Client for the given config and +// NewForConfigOrDie creates a new HelmV1alphaClient for the given config and // panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *IntegrationsV1Client { +func NewForConfigOrDie(c *rest.Config) *HelmV1alphaClient { client, err := NewForConfig(c) if err != nil { panic(err) @@ -60,13 +59,13 @@ func NewForConfigOrDie(c *rest.Config) *IntegrationsV1Client { return client } -// New creates a new IntegrationsV1Client for the given RESTClient. -func New(c rest.Interface) *IntegrationsV1Client { - return &IntegrationsV1Client{c} +// New creates a new HelmV1alphaClient for the given RESTClient. +func New(c rest.Interface) *HelmV1alphaClient { + return &HelmV1alphaClient{c} } func setConfigDefaults(config *rest.Config) error { - gv := v1.SchemeGroupVersion + gv := v1alpha.SchemeGroupVersion config.GroupVersion = &gv config.APIPath = "/apis" config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs} @@ -80,7 +79,7 @@ func setConfigDefaults(config *rest.Config) error { // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. -func (c *IntegrationsV1Client) RESTClient() rest.Interface { +func (c *HelmV1alphaClient) RESTClient() rest.Interface { if c == nil { return nil } diff --git a/integrations/client/clientset/versioned/typed/integrations.flux/v1/fake/fake_fluxhelmresource.go b/integrations/client/clientset/versioned/typed/integrations.flux/v1/fake/fake_fluxhelmresource.go deleted file mode 100644 index bc056c04a..000000000 --- a/integrations/client/clientset/versioned/typed/integrations.flux/v1/fake/fake_fluxhelmresource.go +++ /dev/null @@ -1,126 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -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 ( - integrations_flux_v1 "github.com/weaveworks/flux/apis/integrations.flux/v1" - 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" -) - -// FakeFluxHelmResources implements FluxHelmResourceInterface -type FakeFluxHelmResources struct { - Fake *FakeIntegrationsV1 - ns string -} - -var fluxhelmresourcesResource = schema.GroupVersionResource{Group: "integrations.flux", Version: "v1", Resource: "fluxhelmresources"} - -var fluxhelmresourcesKind = schema.GroupVersionKind{Group: "integrations.flux", Version: "v1", Kind: "FluxHelmResource"} - -// Get takes name of the fluxHelmResource, and returns the corresponding fluxHelmResource object, and an error if there is any. -func (c *FakeFluxHelmResources) Get(name string, options v1.GetOptions) (result *integrations_flux_v1.FluxHelmResource, err error) { - obj, err := c.Fake. - Invokes(testing.NewGetAction(fluxhelmresourcesResource, c.ns, name), &integrations_flux_v1.FluxHelmResource{}) - - if obj == nil { - return nil, err - } - return obj.(*integrations_flux_v1.FluxHelmResource), err -} - -// List takes label and field selectors, and returns the list of FluxHelmResources that match those selectors. -func (c *FakeFluxHelmResources) List(opts v1.ListOptions) (result *integrations_flux_v1.FluxHelmResourceList, err error) { - obj, err := c.Fake. - Invokes(testing.NewListAction(fluxhelmresourcesResource, fluxhelmresourcesKind, c.ns, opts), &integrations_flux_v1.FluxHelmResourceList{}) - - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &integrations_flux_v1.FluxHelmResourceList{} - for _, item := range obj.(*integrations_flux_v1.FluxHelmResourceList).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 fluxHelmResources. -func (c *FakeFluxHelmResources) Watch(opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewWatchAction(fluxhelmresourcesResource, c.ns, opts)) - -} - -// Create takes the representation of a fluxHelmResource and creates it. Returns the server's representation of the fluxHelmResource, and an error, if there is any. -func (c *FakeFluxHelmResources) Create(fluxHelmResource *integrations_flux_v1.FluxHelmResource) (result *integrations_flux_v1.FluxHelmResource, err error) { - obj, err := c.Fake. - Invokes(testing.NewCreateAction(fluxhelmresourcesResource, c.ns, fluxHelmResource), &integrations_flux_v1.FluxHelmResource{}) - - if obj == nil { - return nil, err - } - return obj.(*integrations_flux_v1.FluxHelmResource), err -} - -// Update takes the representation of a fluxHelmResource and updates it. Returns the server's representation of the fluxHelmResource, and an error, if there is any. -func (c *FakeFluxHelmResources) Update(fluxHelmResource *integrations_flux_v1.FluxHelmResource) (result *integrations_flux_v1.FluxHelmResource, err error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateAction(fluxhelmresourcesResource, c.ns, fluxHelmResource), &integrations_flux_v1.FluxHelmResource{}) - - if obj == nil { - return nil, err - } - return obj.(*integrations_flux_v1.FluxHelmResource), err -} - -// Delete takes name of the fluxHelmResource and deletes it. Returns an error if one occurs. -func (c *FakeFluxHelmResources) Delete(name string, options *v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewDeleteAction(fluxhelmresourcesResource, c.ns, name), &integrations_flux_v1.FluxHelmResource{}) - - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeFluxHelmResources) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(fluxhelmresourcesResource, c.ns, listOptions) - - _, err := c.Fake.Invokes(action, &integrations_flux_v1.FluxHelmResourceList{}) - return err -} - -// Patch applies the patch and returns the patched fluxHelmResource. -func (c *FakeFluxHelmResources) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *integrations_flux_v1.FluxHelmResource, err error) { - obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(fluxhelmresourcesResource, c.ns, name, data, subresources...), &integrations_flux_v1.FluxHelmResource{}) - - if obj == nil { - return nil, err - } - return obj.(*integrations_flux_v1.FluxHelmResource), err -} diff --git a/integrations/client/clientset/versioned/typed/integrations.flux/v1/fluxhelmresource.go b/integrations/client/clientset/versioned/typed/integrations.flux/v1/fluxhelmresource.go deleted file mode 100644 index 630039c10..000000000 --- a/integrations/client/clientset/versioned/typed/integrations.flux/v1/fluxhelmresource.go +++ /dev/null @@ -1,155 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -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 v1 - -import ( - v1 "github.com/weaveworks/flux/apis/integrations.flux/v1" - scheme "github.com/weaveworks/flux/integrations/client/clientset/versioned/scheme" - meta_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" -) - -// FluxHelmResourcesGetter has a method to return a FluxHelmResourceInterface. -// A group's client should implement this interface. -type FluxHelmResourcesGetter interface { - FluxHelmResources(namespace string) FluxHelmResourceInterface -} - -// FluxHelmResourceInterface has methods to work with FluxHelmResource resources. -type FluxHelmResourceInterface interface { - Create(*v1.FluxHelmResource) (*v1.FluxHelmResource, error) - Update(*v1.FluxHelmResource) (*v1.FluxHelmResource, error) - Delete(name string, options *meta_v1.DeleteOptions) error - DeleteCollection(options *meta_v1.DeleteOptions, listOptions meta_v1.ListOptions) error - Get(name string, options meta_v1.GetOptions) (*v1.FluxHelmResource, error) - List(opts meta_v1.ListOptions) (*v1.FluxHelmResourceList, error) - Watch(opts meta_v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.FluxHelmResource, err error) - FluxHelmResourceExpansion -} - -// fluxHelmResources implements FluxHelmResourceInterface -type fluxHelmResources struct { - client rest.Interface - ns string -} - -// newFluxHelmResources returns a FluxHelmResources -func newFluxHelmResources(c *IntegrationsV1Client, namespace string) *fluxHelmResources { - return &fluxHelmResources{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the fluxHelmResource, and returns the corresponding fluxHelmResource object, and an error if there is any. -func (c *fluxHelmResources) Get(name string, options meta_v1.GetOptions) (result *v1.FluxHelmResource, err error) { - result = &v1.FluxHelmResource{} - err = c.client.Get(). - Namespace(c.ns). - Resource("fluxhelmresources"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of FluxHelmResources that match those selectors. -func (c *fluxHelmResources) List(opts meta_v1.ListOptions) (result *v1.FluxHelmResourceList, err error) { - result = &v1.FluxHelmResourceList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("fluxhelmresources"). - VersionedParams(&opts, scheme.ParameterCodec). - Do(). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested fluxHelmResources. -func (c *fluxHelmResources) Watch(opts meta_v1.ListOptions) (watch.Interface, error) { - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("fluxhelmresources"). - VersionedParams(&opts, scheme.ParameterCodec). - Watch() -} - -// Create takes the representation of a fluxHelmResource and creates it. Returns the server's representation of the fluxHelmResource, and an error, if there is any. -func (c *fluxHelmResources) Create(fluxHelmResource *v1.FluxHelmResource) (result *v1.FluxHelmResource, err error) { - result = &v1.FluxHelmResource{} - err = c.client.Post(). - Namespace(c.ns). - Resource("fluxhelmresources"). - Body(fluxHelmResource). - Do(). - Into(result) - return -} - -// Update takes the representation of a fluxHelmResource and updates it. Returns the server's representation of the fluxHelmResource, and an error, if there is any. -func (c *fluxHelmResources) Update(fluxHelmResource *v1.FluxHelmResource) (result *v1.FluxHelmResource, err error) { - result = &v1.FluxHelmResource{} - err = c.client.Put(). - Namespace(c.ns). - Resource("fluxhelmresources"). - Name(fluxHelmResource.Name). - Body(fluxHelmResource). - Do(). - Into(result) - return -} - -// Delete takes name of the fluxHelmResource and deletes it. Returns an error if one occurs. -func (c *fluxHelmResources) Delete(name string, options *meta_v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("fluxhelmresources"). - Name(name). - Body(options). - Do(). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *fluxHelmResources) DeleteCollection(options *meta_v1.DeleteOptions, listOptions meta_v1.ListOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("fluxhelmresources"). - VersionedParams(&listOptions, scheme.ParameterCodec). - Body(options). - Do(). - Error() -} - -// Patch applies the patch and returns the patched fluxHelmResource. -func (c *fluxHelmResources) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.FluxHelmResource, err error) { - result = &v1.FluxHelmResource{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("fluxhelmresources"). - SubResource(subresources...). - Name(name). - Body(data). - Do(). - Into(result) - return -} diff --git a/integrations/client/clientset/versioned/typed/integrations/v1/doc.go b/integrations/client/clientset/versioned/typed/integrations/v1/doc.go deleted file mode 100644 index 53d7f29a8..000000000 --- a/integrations/client/clientset/versioned/typed/integrations/v1/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -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. -*/ - -// This package is generated by client-gen with custom arguments. - -// This package has the automatically generated typed clients. -package v1 diff --git a/integrations/client/clientset/versioned/typed/integrations/v1/fake/doc.go b/integrations/client/clientset/versioned/typed/integrations/v1/fake/doc.go deleted file mode 100644 index d4003d501..000000000 --- a/integrations/client/clientset/versioned/typed/integrations/v1/fake/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -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. -*/ - -// This package is generated by client-gen with custom arguments. - -// Package fake has the automatically generated clients. -package fake diff --git a/integrations/client/clientset/versioned/typed/integrations/v1/fake/fake_fluxhelmresource.go b/integrations/client/clientset/versioned/typed/integrations/v1/fake/fake_fluxhelmresource.go deleted file mode 100644 index bc056c04a..000000000 --- a/integrations/client/clientset/versioned/typed/integrations/v1/fake/fake_fluxhelmresource.go +++ /dev/null @@ -1,126 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -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 ( - integrations_flux_v1 "github.com/weaveworks/flux/apis/integrations.flux/v1" - 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" -) - -// FakeFluxHelmResources implements FluxHelmResourceInterface -type FakeFluxHelmResources struct { - Fake *FakeIntegrationsV1 - ns string -} - -var fluxhelmresourcesResource = schema.GroupVersionResource{Group: "integrations.flux", Version: "v1", Resource: "fluxhelmresources"} - -var fluxhelmresourcesKind = schema.GroupVersionKind{Group: "integrations.flux", Version: "v1", Kind: "FluxHelmResource"} - -// Get takes name of the fluxHelmResource, and returns the corresponding fluxHelmResource object, and an error if there is any. -func (c *FakeFluxHelmResources) Get(name string, options v1.GetOptions) (result *integrations_flux_v1.FluxHelmResource, err error) { - obj, err := c.Fake. - Invokes(testing.NewGetAction(fluxhelmresourcesResource, c.ns, name), &integrations_flux_v1.FluxHelmResource{}) - - if obj == nil { - return nil, err - } - return obj.(*integrations_flux_v1.FluxHelmResource), err -} - -// List takes label and field selectors, and returns the list of FluxHelmResources that match those selectors. -func (c *FakeFluxHelmResources) List(opts v1.ListOptions) (result *integrations_flux_v1.FluxHelmResourceList, err error) { - obj, err := c.Fake. - Invokes(testing.NewListAction(fluxhelmresourcesResource, fluxhelmresourcesKind, c.ns, opts), &integrations_flux_v1.FluxHelmResourceList{}) - - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &integrations_flux_v1.FluxHelmResourceList{} - for _, item := range obj.(*integrations_flux_v1.FluxHelmResourceList).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 fluxHelmResources. -func (c *FakeFluxHelmResources) Watch(opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewWatchAction(fluxhelmresourcesResource, c.ns, opts)) - -} - -// Create takes the representation of a fluxHelmResource and creates it. Returns the server's representation of the fluxHelmResource, and an error, if there is any. -func (c *FakeFluxHelmResources) Create(fluxHelmResource *integrations_flux_v1.FluxHelmResource) (result *integrations_flux_v1.FluxHelmResource, err error) { - obj, err := c.Fake. - Invokes(testing.NewCreateAction(fluxhelmresourcesResource, c.ns, fluxHelmResource), &integrations_flux_v1.FluxHelmResource{}) - - if obj == nil { - return nil, err - } - return obj.(*integrations_flux_v1.FluxHelmResource), err -} - -// Update takes the representation of a fluxHelmResource and updates it. Returns the server's representation of the fluxHelmResource, and an error, if there is any. -func (c *FakeFluxHelmResources) Update(fluxHelmResource *integrations_flux_v1.FluxHelmResource) (result *integrations_flux_v1.FluxHelmResource, err error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateAction(fluxhelmresourcesResource, c.ns, fluxHelmResource), &integrations_flux_v1.FluxHelmResource{}) - - if obj == nil { - return nil, err - } - return obj.(*integrations_flux_v1.FluxHelmResource), err -} - -// Delete takes name of the fluxHelmResource and deletes it. Returns an error if one occurs. -func (c *FakeFluxHelmResources) Delete(name string, options *v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewDeleteAction(fluxhelmresourcesResource, c.ns, name), &integrations_flux_v1.FluxHelmResource{}) - - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeFluxHelmResources) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(fluxhelmresourcesResource, c.ns, listOptions) - - _, err := c.Fake.Invokes(action, &integrations_flux_v1.FluxHelmResourceList{}) - return err -} - -// Patch applies the patch and returns the patched fluxHelmResource. -func (c *FakeFluxHelmResources) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *integrations_flux_v1.FluxHelmResource, err error) { - obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(fluxhelmresourcesResource, c.ns, name, data, subresources...), &integrations_flux_v1.FluxHelmResource{}) - - if obj == nil { - return nil, err - } - return obj.(*integrations_flux_v1.FluxHelmResource), err -} diff --git a/integrations/client/clientset/versioned/typed/integrations/v1/fake/fake_integrations_client.go b/integrations/client/clientset/versioned/typed/integrations/v1/fake/fake_integrations_client.go deleted file mode 100644 index 216a4c85a..000000000 --- a/integrations/client/clientset/versioned/typed/integrations/v1/fake/fake_integrations_client.go +++ /dev/null @@ -1,38 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -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 ( - v1 "github.com/weaveworks/flux/integrations/client/clientset/versioned/typed/integrations/v1" - rest "k8s.io/client-go/rest" - testing "k8s.io/client-go/testing" -) - -type FakeIntegrationsV1 struct { - *testing.Fake -} - -func (c *FakeIntegrationsV1) FluxHelmResources(namespace string) v1.FluxHelmResourceInterface { - return &FakeFluxHelmResources{c, namespace} -} - -// RESTClient returns a RESTClient that is used to communicate -// with API server by this client implementation. -func (c *FakeIntegrationsV1) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret -} diff --git a/integrations/client/clientset/versioned/typed/integrations/v1/fluxhelmresource.go b/integrations/client/clientset/versioned/typed/integrations/v1/fluxhelmresource.go deleted file mode 100644 index 630039c10..000000000 --- a/integrations/client/clientset/versioned/typed/integrations/v1/fluxhelmresource.go +++ /dev/null @@ -1,155 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -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 v1 - -import ( - v1 "github.com/weaveworks/flux/apis/integrations.flux/v1" - scheme "github.com/weaveworks/flux/integrations/client/clientset/versioned/scheme" - meta_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" -) - -// FluxHelmResourcesGetter has a method to return a FluxHelmResourceInterface. -// A group's client should implement this interface. -type FluxHelmResourcesGetter interface { - FluxHelmResources(namespace string) FluxHelmResourceInterface -} - -// FluxHelmResourceInterface has methods to work with FluxHelmResource resources. -type FluxHelmResourceInterface interface { - Create(*v1.FluxHelmResource) (*v1.FluxHelmResource, error) - Update(*v1.FluxHelmResource) (*v1.FluxHelmResource, error) - Delete(name string, options *meta_v1.DeleteOptions) error - DeleteCollection(options *meta_v1.DeleteOptions, listOptions meta_v1.ListOptions) error - Get(name string, options meta_v1.GetOptions) (*v1.FluxHelmResource, error) - List(opts meta_v1.ListOptions) (*v1.FluxHelmResourceList, error) - Watch(opts meta_v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.FluxHelmResource, err error) - FluxHelmResourceExpansion -} - -// fluxHelmResources implements FluxHelmResourceInterface -type fluxHelmResources struct { - client rest.Interface - ns string -} - -// newFluxHelmResources returns a FluxHelmResources -func newFluxHelmResources(c *IntegrationsV1Client, namespace string) *fluxHelmResources { - return &fluxHelmResources{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the fluxHelmResource, and returns the corresponding fluxHelmResource object, and an error if there is any. -func (c *fluxHelmResources) Get(name string, options meta_v1.GetOptions) (result *v1.FluxHelmResource, err error) { - result = &v1.FluxHelmResource{} - err = c.client.Get(). - Namespace(c.ns). - Resource("fluxhelmresources"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of FluxHelmResources that match those selectors. -func (c *fluxHelmResources) List(opts meta_v1.ListOptions) (result *v1.FluxHelmResourceList, err error) { - result = &v1.FluxHelmResourceList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("fluxhelmresources"). - VersionedParams(&opts, scheme.ParameterCodec). - Do(). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested fluxHelmResources. -func (c *fluxHelmResources) Watch(opts meta_v1.ListOptions) (watch.Interface, error) { - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("fluxhelmresources"). - VersionedParams(&opts, scheme.ParameterCodec). - Watch() -} - -// Create takes the representation of a fluxHelmResource and creates it. Returns the server's representation of the fluxHelmResource, and an error, if there is any. -func (c *fluxHelmResources) Create(fluxHelmResource *v1.FluxHelmResource) (result *v1.FluxHelmResource, err error) { - result = &v1.FluxHelmResource{} - err = c.client.Post(). - Namespace(c.ns). - Resource("fluxhelmresources"). - Body(fluxHelmResource). - Do(). - Into(result) - return -} - -// Update takes the representation of a fluxHelmResource and updates it. Returns the server's representation of the fluxHelmResource, and an error, if there is any. -func (c *fluxHelmResources) Update(fluxHelmResource *v1.FluxHelmResource) (result *v1.FluxHelmResource, err error) { - result = &v1.FluxHelmResource{} - err = c.client.Put(). - Namespace(c.ns). - Resource("fluxhelmresources"). - Name(fluxHelmResource.Name). - Body(fluxHelmResource). - Do(). - Into(result) - return -} - -// Delete takes name of the fluxHelmResource and deletes it. Returns an error if one occurs. -func (c *fluxHelmResources) Delete(name string, options *meta_v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("fluxhelmresources"). - Name(name). - Body(options). - Do(). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *fluxHelmResources) DeleteCollection(options *meta_v1.DeleteOptions, listOptions meta_v1.ListOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("fluxhelmresources"). - VersionedParams(&listOptions, scheme.ParameterCodec). - Body(options). - Do(). - Error() -} - -// Patch applies the patch and returns the patched fluxHelmResource. -func (c *fluxHelmResources) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.FluxHelmResource, err error) { - result = &v1.FluxHelmResource{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("fluxhelmresources"). - SubResource(subresources...). - Name(name). - Body(data). - Do(). - Into(result) - return -} diff --git a/integrations/client/clientset/versioned/typed/integrations/v1/generated_expansion.go b/integrations/client/clientset/versioned/typed/integrations/v1/generated_expansion.go deleted file mode 100644 index b270cd10a..000000000 --- a/integrations/client/clientset/versioned/typed/integrations/v1/generated_expansion.go +++ /dev/null @@ -1,19 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -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 v1 - -type FluxHelmResourceExpansion interface{} diff --git a/integrations/client/clientset/versioned/typed/integrations/v1/integrations_client.go b/integrations/client/clientset/versioned/typed/integrations/v1/integrations_client.go deleted file mode 100644 index 3b9960579..000000000 --- a/integrations/client/clientset/versioned/typed/integrations/v1/integrations_client.go +++ /dev/null @@ -1,88 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -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 v1 - -import ( - v1 "github.com/weaveworks/flux/apis/integrations.flux/v1" - "github.com/weaveworks/flux/integrations/client/clientset/versioned/scheme" - serializer "k8s.io/apimachinery/pkg/runtime/serializer" - rest "k8s.io/client-go/rest" -) - -type IntegrationsV1Interface interface { - RESTClient() rest.Interface - FluxHelmResourcesGetter -} - -// IntegrationsV1Client is used to interact with features provided by the integrations.flux group. -type IntegrationsV1Client struct { - restClient rest.Interface -} - -func (c *IntegrationsV1Client) FluxHelmResources(namespace string) FluxHelmResourceInterface { - return newFluxHelmResources(c, namespace) -} - -// NewForConfig creates a new IntegrationsV1Client for the given config. -func NewForConfig(c *rest.Config) (*IntegrationsV1Client, error) { - config := *c - if err := setConfigDefaults(&config); err != nil { - return nil, err - } - client, err := rest.RESTClientFor(&config) - if err != nil { - return nil, err - } - return &IntegrationsV1Client{client}, nil -} - -// NewForConfigOrDie creates a new IntegrationsV1Client for the given config and -// panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *IntegrationsV1Client { - client, err := NewForConfig(c) - if err != nil { - panic(err) - } - return client -} - -// New creates a new IntegrationsV1Client for the given RESTClient. -func New(c rest.Interface) *IntegrationsV1Client { - return &IntegrationsV1Client{c} -} - -func setConfigDefaults(config *rest.Config) error { - gv := v1.SchemeGroupVersion - config.GroupVersion = &gv - config.APIPath = "/apis" - config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs} - - if config.UserAgent == "" { - config.UserAgent = rest.DefaultKubernetesUserAgent() - } - - return nil -} - -// RESTClient returns a RESTClient that is used to communicate -// with API server by this client implementation. -func (c *IntegrationsV1Client) RESTClient() rest.Interface { - if c == nil { - return nil - } - return c.restClient -} diff --git a/integrations/client/informers/externalversions/factory.go b/integrations/client/informers/externalversions/factory.go index 5bebf4919..b36b16034 100644 --- a/integrations/client/informers/externalversions/factory.go +++ b/integrations/client/informers/externalversions/factory.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Kubernetes Authors. +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. @@ -20,7 +20,7 @@ package externalversions import ( versioned "github.com/weaveworks/flux/integrations/client/clientset/versioned" - integrations_flux "github.com/weaveworks/flux/integrations/client/informers/externalversions/integrations.flux" + helm_integrations_flux_weave_works "github.com/weaveworks/flux/integrations/client/informers/externalversions/helm.integrations.flux.weave.works" internalinterfaces "github.com/weaveworks/flux/integrations/client/informers/externalversions/internalinterfaces" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" @@ -122,9 +122,9 @@ type SharedInformerFactory interface { ForResource(resource schema.GroupVersionResource) (GenericInformer, error) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool - Integrations() integrations_flux.Interface + Helm() helm_integrations_flux_weave_works.Interface } -func (f *sharedInformerFactory) Integrations() integrations_flux.Interface { - return integrations_flux.New(f, f.namespace, f.tweakListOptions) +func (f *sharedInformerFactory) Helm() helm_integrations_flux_weave_works.Interface { + return helm_integrations_flux_weave_works.New(f, f.namespace, f.tweakListOptions) } diff --git a/integrations/client/informers/externalversions/generic.go b/integrations/client/informers/externalversions/generic.go index 4733213e2..76406efd3 100644 --- a/integrations/client/informers/externalversions/generic.go +++ b/integrations/client/informers/externalversions/generic.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Kubernetes Authors. +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. @@ -20,7 +20,7 @@ package externalversions import ( "fmt" - v1 "github.com/weaveworks/flux/apis/integrations.flux/v1" + v1alpha "github.com/weaveworks/flux/apis/helm.integrations.flux.weave.works/v1alpha" schema "k8s.io/apimachinery/pkg/runtime/schema" cache "k8s.io/client-go/tools/cache" ) @@ -51,9 +51,9 @@ func (f *genericInformer) Lister() cache.GenericLister { // TODO extend this to unknown resources with a client pool func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { switch resource { - // Group=integrations.flux, Version=v1 - case v1.SchemeGroupVersion.WithResource("fluxhelmresources"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Integrations().V1().FluxHelmResources().Informer()}, nil + // Group=helm.integrations.flux.weave.works, Version=v1alpha + case v1alpha.SchemeGroupVersion.WithResource("fluxhelmreleases"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Helm().V1alpha().FluxHelmReleases().Informer()}, nil } diff --git a/integrations/client/informers/externalversions/integrations.flux/interface.go b/integrations/client/informers/externalversions/helm.integrations.flux.weave.works/interface.go similarity index 74% rename from integrations/client/informers/externalversions/integrations.flux/interface.go rename to integrations/client/informers/externalversions/helm.integrations.flux.weave.works/interface.go index 43758503d..3f07635c7 100644 --- a/integrations/client/informers/externalversions/integrations.flux/interface.go +++ b/integrations/client/informers/externalversions/helm.integrations.flux.weave.works/interface.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Kubernetes Authors. +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. @@ -16,17 +16,17 @@ limitations under the License. // This file was automatically generated by informer-gen -package integrations +package helm import ( - v1 "github.com/weaveworks/flux/integrations/client/informers/externalversions/integrations.flux/v1" + v1alpha "github.com/weaveworks/flux/integrations/client/informers/externalversions/helm.integrations.flux.weave.works/v1alpha" internalinterfaces "github.com/weaveworks/flux/integrations/client/informers/externalversions/internalinterfaces" ) // Interface provides access to each of this group's versions. type Interface interface { - // V1 provides access to shared informers for resources in V1. - V1() v1.Interface + // V1alpha provides access to shared informers for resources in V1alpha. + V1alpha() v1alpha.Interface } type group struct { @@ -40,7 +40,7 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} } -// V1 returns a new v1.Interface. -func (g *group) V1() v1.Interface { - return v1.New(g.factory, g.namespace, g.tweakListOptions) +// V1alpha returns a new v1alpha.Interface. +func (g *group) V1alpha() v1alpha.Interface { + return v1alpha.New(g.factory, g.namespace, g.tweakListOptions) } diff --git a/integrations/client/informers/externalversions/helm.integrations.flux.weave.works/v1alpha/fluxhelmrelease.go b/integrations/client/informers/externalversions/helm.integrations.flux.weave.works/v1alpha/fluxhelmrelease.go new file mode 100644 index 000000000..764c3f1e8 --- /dev/null +++ b/integrations/client/informers/externalversions/helm.integrations.flux.weave.works/v1alpha/fluxhelmrelease.go @@ -0,0 +1,88 @@ +/* +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. +*/ + +// This file was automatically generated by informer-gen + +package v1alpha + +import ( + helm_integrations_flux_weave_works_v1alpha "github.com/weaveworks/flux/apis/helm.integrations.flux.weave.works/v1alpha" + versioned "github.com/weaveworks/flux/integrations/client/clientset/versioned" + internalinterfaces "github.com/weaveworks/flux/integrations/client/informers/externalversions/internalinterfaces" + v1alpha "github.com/weaveworks/flux/integrations/client/listers/helm.integrations.flux.weave.works/v1alpha" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + time "time" +) + +// FluxHelmReleaseInformer provides access to a shared informer and lister for +// FluxHelmReleases. +type FluxHelmReleaseInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha.FluxHelmReleaseLister +} + +type fluxHelmReleaseInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewFluxHelmReleaseInformer constructs a new informer for FluxHelmRelease type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFluxHelmReleaseInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredFluxHelmReleaseInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredFluxHelmReleaseInformer constructs a new informer for FluxHelmRelease type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredFluxHelmReleaseInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.HelmV1alpha().FluxHelmReleases(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.HelmV1alpha().FluxHelmReleases(namespace).Watch(options) + }, + }, + &helm_integrations_flux_weave_works_v1alpha.FluxHelmRelease{}, + resyncPeriod, + indexers, + ) +} + +func (f *fluxHelmReleaseInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredFluxHelmReleaseInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *fluxHelmReleaseInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&helm_integrations_flux_weave_works_v1alpha.FluxHelmRelease{}, f.defaultInformer) +} + +func (f *fluxHelmReleaseInformer) Lister() v1alpha.FluxHelmReleaseLister { + return v1alpha.NewFluxHelmReleaseLister(f.Informer().GetIndexer()) +} diff --git a/integrations/client/informers/externalversions/integrations.flux/v1/interface.go b/integrations/client/informers/externalversions/helm.integrations.flux.weave.works/v1alpha/interface.go similarity index 76% rename from integrations/client/informers/externalversions/integrations.flux/v1/interface.go rename to integrations/client/informers/externalversions/helm.integrations.flux.weave.works/v1alpha/interface.go index de5a7a199..031fb7ac4 100644 --- a/integrations/client/informers/externalversions/integrations.flux/v1/interface.go +++ b/integrations/client/informers/externalversions/helm.integrations.flux.weave.works/v1alpha/interface.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Kubernetes Authors. +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. @@ -16,7 +16,7 @@ limitations under the License. // This file was automatically generated by informer-gen -package v1 +package v1alpha import ( internalinterfaces "github.com/weaveworks/flux/integrations/client/informers/externalversions/internalinterfaces" @@ -24,8 +24,8 @@ import ( // Interface provides access to all the informers in this group version. type Interface interface { - // FluxHelmResources returns a FluxHelmResourceInformer. - FluxHelmResources() FluxHelmResourceInformer + // FluxHelmReleases returns a FluxHelmReleaseInformer. + FluxHelmReleases() FluxHelmReleaseInformer } type version struct { @@ -39,7 +39,7 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} } -// FluxHelmResources returns a FluxHelmResourceInformer. -func (v *version) FluxHelmResources() FluxHelmResourceInformer { - return &fluxHelmResourceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +// FluxHelmReleases returns a FluxHelmReleaseInformer. +func (v *version) FluxHelmReleases() FluxHelmReleaseInformer { + return &fluxHelmReleaseInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } diff --git a/integrations/client/informers/externalversions/integrations.flux/v1/fluxhelmresource.go b/integrations/client/informers/externalversions/integrations.flux/v1/fluxhelmresource.go deleted file mode 100644 index 92995be1c..000000000 --- a/integrations/client/informers/externalversions/integrations.flux/v1/fluxhelmresource.go +++ /dev/null @@ -1,88 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -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. -*/ - -// This file was automatically generated by informer-gen - -package v1 - -import ( - integrations_flux_v1 "github.com/weaveworks/flux/apis/integrations.flux/v1" - versioned "github.com/weaveworks/flux/integrations/client/clientset/versioned" - internalinterfaces "github.com/weaveworks/flux/integrations/client/informers/externalversions/internalinterfaces" - v1 "github.com/weaveworks/flux/integrations/client/listers/integrations.flux/v1" - meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - watch "k8s.io/apimachinery/pkg/watch" - cache "k8s.io/client-go/tools/cache" - time "time" -) - -// FluxHelmResourceInformer provides access to a shared informer and lister for -// FluxHelmResources. -type FluxHelmResourceInformer interface { - Informer() cache.SharedIndexInformer - Lister() v1.FluxHelmResourceLister -} - -type fluxHelmResourceInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc - namespace string -} - -// NewFluxHelmResourceInformer constructs a new informer for FluxHelmResource 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 NewFluxHelmResourceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - return NewFilteredFluxHelmResourceInformer(client, namespace, resyncPeriod, indexers, nil) -} - -// NewFilteredFluxHelmResourceInformer constructs a new informer for FluxHelmResource 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 NewFilteredFluxHelmResourceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { - return cache.NewSharedIndexInformer( - &cache.ListWatch{ - ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.IntegrationsV1().FluxHelmResources(namespace).List(options) - }, - WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.IntegrationsV1().FluxHelmResources(namespace).Watch(options) - }, - }, - &integrations_flux_v1.FluxHelmResource{}, - resyncPeriod, - indexers, - ) -} - -func (f *fluxHelmResourceInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewFilteredFluxHelmResourceInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) -} - -func (f *fluxHelmResourceInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&integrations_flux_v1.FluxHelmResource{}, f.defaultInformer) -} - -func (f *fluxHelmResourceInformer) Lister() v1.FluxHelmResourceLister { - return v1.NewFluxHelmResourceLister(f.Informer().GetIndexer()) -} diff --git a/integrations/client/informers/externalversions/integrations/interface.go b/integrations/client/informers/externalversions/integrations/interface.go deleted file mode 100644 index 83286ab9b..000000000 --- a/integrations/client/informers/externalversions/integrations/interface.go +++ /dev/null @@ -1,44 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -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. -*/ - -// This file was automatically generated by informer-gen - -package integrations - -import ( - v1 "github.com/weaveworks/flux/integrations/client/informers/externalversions/integrations/v1" - internalinterfaces "github.com/weaveworks/flux/integrations/client/informers/externalversions/internalinterfaces" -) - -// Interface provides access to each of this group's versions. -type Interface interface { - // V1 provides access to shared informers for resources in V1. - V1() v1.Interface -} - -type group struct { - internalinterfaces.SharedInformerFactory -} - -// New returns a new Interface. -func New(f internalinterfaces.SharedInformerFactory) Interface { - return &group{f} -} - -// V1 returns a new v1.Interface. -func (g *group) V1() v1.Interface { - return v1.New(g.SharedInformerFactory) -} diff --git a/integrations/client/informers/externalversions/integrations/v1/fluxhelmresource.go b/integrations/client/informers/externalversions/integrations/v1/fluxhelmresource.go deleted file mode 100644 index 9a773a672..000000000 --- a/integrations/client/informers/externalversions/integrations/v1/fluxhelmresource.go +++ /dev/null @@ -1,73 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -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. -*/ - -// This file was automatically generated by informer-gen - -package v1 - -import ( - integrations_flux_v1 "github.com/weaveworks/flux/apis/integrations.flux/v1" - versioned "github.com/weaveworks/flux/integrations/client/clientset/versioned" - internalinterfaces "github.com/weaveworks/flux/integrations/client/informers/externalversions/internalinterfaces" - v1 "github.com/weaveworks/flux/integrations/client/listers/integrations/v1" - meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - watch "k8s.io/apimachinery/pkg/watch" - cache "k8s.io/client-go/tools/cache" - time "time" -) - -// FluxHelmResourceInformer provides access to a shared informer and lister for -// FluxHelmResources. -type FluxHelmResourceInformer interface { - Informer() cache.SharedIndexInformer - Lister() v1.FluxHelmResourceLister -} - -type fluxHelmResourceInformer struct { - factory internalinterfaces.SharedInformerFactory -} - -// NewFluxHelmResourceInformer constructs a new informer for FluxHelmResource 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 NewFluxHelmResourceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - return cache.NewSharedIndexInformer( - &cache.ListWatch{ - ListFunc: func(options meta_v1.ListOptions) (runtime.Object, error) { - return client.IntegrationsV1().FluxHelmResources(namespace).List(options) - }, - WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) { - return client.IntegrationsV1().FluxHelmResources(namespace).Watch(options) - }, - }, - &integrations_flux_v1.FluxHelmResource{}, - resyncPeriod, - indexers, - ) -} - -func defaultFluxHelmResourceInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewFluxHelmResourceInformer(client, meta_v1.NamespaceAll, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}) -} - -func (f *fluxHelmResourceInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&integrations_flux_v1.FluxHelmResource{}, defaultFluxHelmResourceInformer) -} - -func (f *fluxHelmResourceInformer) Lister() v1.FluxHelmResourceLister { - return v1.NewFluxHelmResourceLister(f.Informer().GetIndexer()) -} diff --git a/integrations/client/informers/externalversions/integrations/v1/interface.go b/integrations/client/informers/externalversions/integrations/v1/interface.go deleted file mode 100644 index 9e9143d0f..000000000 --- a/integrations/client/informers/externalversions/integrations/v1/interface.go +++ /dev/null @@ -1,43 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -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. -*/ - -// This file was automatically generated by informer-gen - -package v1 - -import ( - internalinterfaces "github.com/weaveworks/flux/integrations/client/informers/externalversions/internalinterfaces" -) - -// Interface provides access to all the informers in this group version. -type Interface interface { - // FluxHelmResources returns a FluxHelmResourceInformer. - FluxHelmResources() FluxHelmResourceInformer -} - -type version struct { - internalinterfaces.SharedInformerFactory -} - -// New returns a new Interface. -func New(f internalinterfaces.SharedInformerFactory) Interface { - return &version{f} -} - -// FluxHelmResources returns a FluxHelmResourceInformer. -func (v *version) FluxHelmResources() FluxHelmResourceInformer { - return &fluxHelmResourceInformer{factory: v.SharedInformerFactory} -} diff --git a/integrations/client/informers/externalversions/internalinterfaces/factory_interfaces.go b/integrations/client/informers/externalversions/internalinterfaces/factory_interfaces.go index 83cc528d4..6d862922f 100644 --- a/integrations/client/informers/externalversions/internalinterfaces/factory_interfaces.go +++ b/integrations/client/informers/externalversions/internalinterfaces/factory_interfaces.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Kubernetes Authors. +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. diff --git a/integrations/client/listers/integrations.flux/v1/expansion_generated.go b/integrations/client/listers/helm.integrations.flux.weave.works/v1alpha/expansion_generated.go similarity index 61% rename from integrations/client/listers/integrations.flux/v1/expansion_generated.go rename to integrations/client/listers/helm.integrations.flux.weave.works/v1alpha/expansion_generated.go index 13f34ae9a..f9e06af0a 100644 --- a/integrations/client/listers/integrations.flux/v1/expansion_generated.go +++ b/integrations/client/listers/helm.integrations.flux.weave.works/v1alpha/expansion_generated.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Kubernetes Authors. +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. @@ -16,12 +16,12 @@ limitations under the License. // This file was automatically generated by lister-gen -package v1 +package v1alpha -// FluxHelmResourceListerExpansion allows custom methods to be added to -// FluxHelmResourceLister. -type FluxHelmResourceListerExpansion interface{} +// FluxHelmReleaseListerExpansion allows custom methods to be added to +// FluxHelmReleaseLister. +type FluxHelmReleaseListerExpansion interface{} -// FluxHelmResourceNamespaceListerExpansion allows custom methods to be added to -// FluxHelmResourceNamespaceLister. -type FluxHelmResourceNamespaceListerExpansion interface{} +// FluxHelmReleaseNamespaceListerExpansion allows custom methods to be added to +// FluxHelmReleaseNamespaceLister. +type FluxHelmReleaseNamespaceListerExpansion interface{} diff --git a/integrations/client/listers/helm.integrations.flux.weave.works/v1alpha/fluxhelmrelease.go b/integrations/client/listers/helm.integrations.flux.weave.works/v1alpha/fluxhelmrelease.go new file mode 100644 index 000000000..fd0de4d65 --- /dev/null +++ b/integrations/client/listers/helm.integrations.flux.weave.works/v1alpha/fluxhelmrelease.go @@ -0,0 +1,94 @@ +/* +Copyright 2018 Weaveworks Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// This file was automatically generated by lister-gen + +package v1alpha + +import ( + v1alpha "github.com/weaveworks/flux/apis/helm.integrations.flux.weave.works/v1alpha" + "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 []*v1alpha.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 []*v1alpha.FluxHelmRelease, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha.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 []*v1alpha.FluxHelmRelease, err error) + // Get retrieves the FluxHelmRelease from the indexer for a given namespace and name. + Get(name string) (*v1alpha.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 []*v1alpha.FluxHelmRelease, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha.FluxHelmRelease)) + }) + return ret, err +} + +// Get retrieves the FluxHelmRelease from the indexer for a given namespace and name. +func (s fluxHelmReleaseNamespaceLister) Get(name string) (*v1alpha.FluxHelmRelease, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha.Resource("fluxhelmrelease"), name) + } + return obj.(*v1alpha.FluxHelmRelease), nil +} diff --git a/integrations/client/listers/integrations.flux/v1/fluxhelmresource.go b/integrations/client/listers/integrations.flux/v1/fluxhelmresource.go deleted file mode 100644 index c490f23c1..000000000 --- a/integrations/client/listers/integrations.flux/v1/fluxhelmresource.go +++ /dev/null @@ -1,94 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -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. -*/ - -// This file was automatically generated by lister-gen - -package v1 - -import ( - v1 "github.com/weaveworks/flux/apis/integrations.flux/v1" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/tools/cache" -) - -// FluxHelmResourceLister helps list FluxHelmResources. -type FluxHelmResourceLister interface { - // List lists all FluxHelmResources in the indexer. - List(selector labels.Selector) (ret []*v1.FluxHelmResource, err error) - // FluxHelmResources returns an object that can list and get FluxHelmResources. - FluxHelmResources(namespace string) FluxHelmResourceNamespaceLister - FluxHelmResourceListerExpansion -} - -// fluxHelmResourceLister implements the FluxHelmResourceLister interface. -type fluxHelmResourceLister struct { - indexer cache.Indexer -} - -// NewFluxHelmResourceLister returns a new FluxHelmResourceLister. -func NewFluxHelmResourceLister(indexer cache.Indexer) FluxHelmResourceLister { - return &fluxHelmResourceLister{indexer: indexer} -} - -// List lists all FluxHelmResources in the indexer. -func (s *fluxHelmResourceLister) List(selector labels.Selector) (ret []*v1.FluxHelmResource, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1.FluxHelmResource)) - }) - return ret, err -} - -// FluxHelmResources returns an object that can list and get FluxHelmResources. -func (s *fluxHelmResourceLister) FluxHelmResources(namespace string) FluxHelmResourceNamespaceLister { - return fluxHelmResourceNamespaceLister{indexer: s.indexer, namespace: namespace} -} - -// FluxHelmResourceNamespaceLister helps list and get FluxHelmResources. -type FluxHelmResourceNamespaceLister interface { - // List lists all FluxHelmResources in the indexer for a given namespace. - List(selector labels.Selector) (ret []*v1.FluxHelmResource, err error) - // Get retrieves the FluxHelmResource from the indexer for a given namespace and name. - Get(name string) (*v1.FluxHelmResource, error) - FluxHelmResourceNamespaceListerExpansion -} - -// fluxHelmResourceNamespaceLister implements the FluxHelmResourceNamespaceLister -// interface. -type fluxHelmResourceNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all FluxHelmResources in the indexer for a given namespace. -func (s fluxHelmResourceNamespaceLister) List(selector labels.Selector) (ret []*v1.FluxHelmResource, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1.FluxHelmResource)) - }) - return ret, err -} - -// Get retrieves the FluxHelmResource from the indexer for a given namespace and name. -func (s fluxHelmResourceNamespaceLister) Get(name string) (*v1.FluxHelmResource, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1.Resource("fluxhelmresource"), name) - } - return obj.(*v1.FluxHelmResource), nil -} diff --git a/integrations/client/listers/integrations/v1/expansion_generated.go b/integrations/client/listers/integrations/v1/expansion_generated.go deleted file mode 100644 index 13f34ae9a..000000000 --- a/integrations/client/listers/integrations/v1/expansion_generated.go +++ /dev/null @@ -1,27 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -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. -*/ - -// This file was automatically generated by lister-gen - -package v1 - -// FluxHelmResourceListerExpansion allows custom methods to be added to -// FluxHelmResourceLister. -type FluxHelmResourceListerExpansion interface{} - -// FluxHelmResourceNamespaceListerExpansion allows custom methods to be added to -// FluxHelmResourceNamespaceLister. -type FluxHelmResourceNamespaceListerExpansion interface{} diff --git a/integrations/client/listers/integrations/v1/fluxhelmresource.go b/integrations/client/listers/integrations/v1/fluxhelmresource.go deleted file mode 100644 index c490f23c1..000000000 --- a/integrations/client/listers/integrations/v1/fluxhelmresource.go +++ /dev/null @@ -1,94 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -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. -*/ - -// This file was automatically generated by lister-gen - -package v1 - -import ( - v1 "github.com/weaveworks/flux/apis/integrations.flux/v1" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/tools/cache" -) - -// FluxHelmResourceLister helps list FluxHelmResources. -type FluxHelmResourceLister interface { - // List lists all FluxHelmResources in the indexer. - List(selector labels.Selector) (ret []*v1.FluxHelmResource, err error) - // FluxHelmResources returns an object that can list and get FluxHelmResources. - FluxHelmResources(namespace string) FluxHelmResourceNamespaceLister - FluxHelmResourceListerExpansion -} - -// fluxHelmResourceLister implements the FluxHelmResourceLister interface. -type fluxHelmResourceLister struct { - indexer cache.Indexer -} - -// NewFluxHelmResourceLister returns a new FluxHelmResourceLister. -func NewFluxHelmResourceLister(indexer cache.Indexer) FluxHelmResourceLister { - return &fluxHelmResourceLister{indexer: indexer} -} - -// List lists all FluxHelmResources in the indexer. -func (s *fluxHelmResourceLister) List(selector labels.Selector) (ret []*v1.FluxHelmResource, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1.FluxHelmResource)) - }) - return ret, err -} - -// FluxHelmResources returns an object that can list and get FluxHelmResources. -func (s *fluxHelmResourceLister) FluxHelmResources(namespace string) FluxHelmResourceNamespaceLister { - return fluxHelmResourceNamespaceLister{indexer: s.indexer, namespace: namespace} -} - -// FluxHelmResourceNamespaceLister helps list and get FluxHelmResources. -type FluxHelmResourceNamespaceLister interface { - // List lists all FluxHelmResources in the indexer for a given namespace. - List(selector labels.Selector) (ret []*v1.FluxHelmResource, err error) - // Get retrieves the FluxHelmResource from the indexer for a given namespace and name. - Get(name string) (*v1.FluxHelmResource, error) - FluxHelmResourceNamespaceListerExpansion -} - -// fluxHelmResourceNamespaceLister implements the FluxHelmResourceNamespaceLister -// interface. -type fluxHelmResourceNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all FluxHelmResources in the indexer for a given namespace. -func (s fluxHelmResourceNamespaceLister) List(selector labels.Selector) (ret []*v1.FluxHelmResource, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1.FluxHelmResource)) - }) - return ret, err -} - -// Get retrieves the FluxHelmResource from the indexer for a given namespace and name. -func (s fluxHelmResourceNamespaceLister) Get(name string) (*v1.FluxHelmResource, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1.Resource("fluxhelmresource"), name) - } - return obj.(*v1.FluxHelmResource), nil -} diff --git a/integrations/helm/chartsync/chartsync.go b/integrations/helm/chartsync/chartsync.go index 8747337fb..88cd9ed5c 100644 --- a/integrations/helm/chartsync/chartsync.go +++ b/integrations/helm/chartsync/chartsync.go @@ -1,5 +1,5 @@ /* -Package sync provides the functionality for updating a Chart release +Package chartsync provides the functionality for updating a Chart release due to (git repo) changes of Charts, while no Custom Resource changes. Helm operator regularly checks the Chart repo and if new commits are found @@ -17,10 +17,6 @@ import ( "sync" "time" - git "gopkg.in/src-d/go-git.v4" - "gopkg.in/src-d/go-git.v4/plumbing" - "gopkg.in/src-d/go-git.v4/plumbing/object" - "github.com/go-kit/kit/log" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" @@ -29,10 +25,10 @@ import ( //"gopkg.in/src-d/go-git.v4/plumbing" - ifv1 "github.com/weaveworks/flux/apis/integrations.flux/v1" + ifv1 "github.com/weaveworks/flux/apis/helm.integrations.flux.weave.works/v1alpha" ifclientset "github.com/weaveworks/flux/integrations/client/clientset/versioned" - iflister "github.com/weaveworks/flux/integrations/client/listers/integrations.flux/v1" // kubernetes 1.9 - //iflister "github.com/weaveworks/flux/integrations/client/listers/integrations/v1" // kubernetes 1.8 + fhrv1 "github.com/weaveworks/flux/integrations/client/informers/externalversions/helm.integrations.flux.weave.works/v1alpha" + iflister "github.com/weaveworks/flux/integrations/client/listers/helm.integrations.flux.weave.works/v1alpha" // kubernetes 1.9 helmgit "github.com/weaveworks/flux/integrations/helm/git" chartrelease "github.com/weaveworks/flux/integrations/helm/release" ) @@ -45,38 +41,73 @@ type Polling struct { type ChartChangeSync struct { logger log.Logger Polling - release *chartrelease.Release - kubeClient kubernetes.Clientset - ifClient ifclientset.Clientset - fhrLister iflister.FluxHelmResourceLister - lastCheckedCommit plumbing.Hash - sync.RWMutex + kubeClient kubernetes.Clientset + ifClient ifclientset.Clientset + fhrLister iflister.FluxHelmReleaseLister + release *chartrelease.Release + lastCheckedRevision string + //sync.RWMutex } -// Run ... create a syncing loop -func (chs *ChartChangeSync) Run(stopCh <-chan struct{}, errc chan error) { - chs.release.Repo.ChartsSync.Lock() - defer chs.release.Repo.ChartsSync.Unlock() - defer runtime.HandleCrash() +func New( + logger log.Logger, syncInterval time.Duration, syncTimeout time.Duration, + kubeClient kubernetes.Clientset, + ifClient ifclientset.Clientset, fhrInformer fhrv1.FluxHelmReleaseInformer, + release *chartrelease.Release) *ChartChangeSync { + lastCheckedRevision := "" + gitRef, err := release.Repo.ConfigSync.GetRevision() + if err != nil { + // we shall try again later + } + lastCheckedRevision = gitRef.String() + + return &ChartChangeSync{ + logger: logger, + Polling: Polling{Interval: syncInterval, Timeout: syncTimeout}, + kubeClient: kubeClient, + ifClient: ifClient, + fhrLister: fhrInformer.Lister(), + release: release, + lastCheckedRevision: lastCheckedRevision, + } +} + +// Run ... creates a syncing loop monitoring repo chart changes +func (chs *ChartChangeSync) Run(stopCh <-chan struct{}, errc chan error, wg *sync.WaitGroup) { + chs.logger.Log("info", "Starting repo charts sync loop") + + wg.Add(1) go func() { - ticker := time.NewTicker(chs.Polling.Interval) - defer ticker.Stop() - defer chs.release.Repo.ChartsSync.Cleanup() + defer runtime.HandleCrash() + defer wg.Done() + + chartsSyncCurr := chs.release.Repo.ChartsSync.Curr + chartsSyncNew := chs.release.Repo.ChartsSync.New + defer chartsSyncCurr.Cleanup() + defer chartsSyncNew.Cleanup() var exist bool + var newRev string var err error + ticker := time.NewTicker(chs.Polling.Interval) + defer ticker.Stop() + for { select { + // ------------------------------------------------------------------------------------ case <-ticker.C: + fmt.Printf("\n\t... TICK at %s\n\n", time.Now().String()) // new commits? - if exist, err = chs.newCommits(); err != nil { + if exist, newRev, err = chs.newCommits(); err != nil { chs.logger.Log("error", fmt.Sprintf("Failure during retrieving commits: %#v", err)) + fmt.Printf("\n\t... TICK work FINISHED at %s\n\n", time.Now().String()) continue } // continue if not if !exist { + fmt.Printf("\n\t... TICK work FINISHED at %s\n\n", time.Now().String()) continue } // get namespaces @@ -84,35 +115,75 @@ func (chs *ChartChangeSync) Run(stopCh <-chan struct{}, errc chan error) { if err != nil { errc <- err } + // get chart dirs - chartDirs, err := chs.getChartDirs() + chartDirsCurr, err := getChartDirs(chs.logger, chs.release.Repo.ChartsSync.Curr) if err != nil { + chs.logger.Log("error", fmt.Sprintf("Failure to get charts under the charts path: %#v", err)) + fmt.Printf("\n\t... TICK work FINISHED at %s\n\n", time.Now().String()) continue } + chartDirsNew, err := getChartDirs(chs.logger, chs.release.Repo.ChartsSync.New) + if err != nil { + chs.logger.Log("error", fmt.Sprintf("Failure to get charts under the charts path: %#v", err)) + fmt.Printf("\n\t... TICK work FINISHED at %s\n\n", time.Now().String()) + continue + } + // get fhrs - chartFhrs := make(map[string][]ifv1.FluxHelmResource) - for chart := range chartDirs { + chartFhrs := make(map[string][]ifv1.FluxHelmRelease) + for chart := range chartDirsNew { err = chs.getCustomResources(ns, chart, chartFhrs) if err != nil { - chs.logger.Log("error", fmt.Sprintf("Failure during retrieving Custom Resources related to Chart: %s", chart)) + chs.logger.Log("error", fmt.Sprintf("Failure during retrieving Custom Resources related to Chart [%s]: %#v", chart, err)) + fmt.Printf("\n\t... TICK work FINISHED at %s\n\n", time.Now().String()) continue } } - if len(chartFhrs) < 1 { + //fmt.Printf("\n\tFound these CS chartFhrs %+v\n\n", chartFhrs) + + // compare manifests and release if required + ctx, cancel := context.WithTimeout(context.Background(), helmgit.DefaultCloneTimeout) + chartToRelease, err := chs.releaseNeeded(ctx, chartDirsCurr, chartDirsNew, chartFhrs) + cancel() + if err != nil { + chs.logger.Log("error", fmt.Sprintf("Error while establishing upgrade need of releases: %s", err.Error())) + fmt.Printf("\n\t... TICK work FINISHED at %s\n\n", time.Now().String()) continue } - // compare manifests and release if required - if err = chs.releaseCharts(chartDirs, chartFhrs); err != nil { - chs.logger.Log("error", fmt.Sprintf("%#v", err)) + // No new commits found + if len(chartToRelease) == 0 { + fmt.Printf("\n\t... TICK work FINISHED at %s\n\n", time.Now().String()) + continue + } + + if err = chs.releaseCharts(chartToRelease, chartFhrs); err != nil { + chs.logger.Log("error", fmt.Sprintf("Failure to release Chart(s): %#v", err)) + fmt.Printf("\n\t... TICK work FINISHED at %s\n\n", time.Now().String()) + continue + } + // All went well, so we shall make the repo with the last checked commit up to date + // and update the lastCheckedRevision property + chc := chs.release.Repo.ChartsSync.Curr + ctx, cancel = context.WithTimeout(context.Background(), helmgit.DefaultCloneTimeout) + err = chc.Pull(ctx) + cancel() + if err != nil { + errm := fmt.Errorf("Failure while pulling repo: %#v", err) + chs.logger.Log("error", errm.Error()) + fmt.Printf("\n\t... TICK work FINISHED at %s\n\n", time.Now().String()) + continue } + chs.logger.Log("info", "Pulled repo") + chs.lastCheckedRevision = newRev + fmt.Printf("\n\t... TICK work FINISHED at %s\n\n", time.Now().String()) + // ------------------------------------------------------------------------------------ case <-stopCh: + chs.logger.Log("stopping", "true") break } } - }() - - <-stopCh } // GetNamespaces ... gets current kubernetes cluster namespaces @@ -134,10 +205,11 @@ func GetNamespaces(logger log.Logger, kubeClient kubernetes.Clientset) ([]string } // getChartDirs ... retrieves charts under the charts directory (under the repo root) -func (chs *ChartChangeSync) getChartDirs() (map[string]string, error) { +// go-git(.v4) does not implement finding commits under a specific path. This means +// the individual chart paths cannor be currently used with "git log" +func getChartDirs(logger log.Logger, checkout *helmgit.Checkout) (map[string]string, error) { chartD := make(map[string]string) - checkout := chs.release.Repo.ChartsSync repoRoot := checkout.Dir if repoRoot == "" { return nil, helmgit.ErrNoRepoCloned @@ -147,7 +219,7 @@ func (chs *ChartChangeSync) getChartDirs() (map[string]string, error) { files, err := ioutil.ReadDir(chartsFullPath) if err != nil { errm := fmt.Errorf("Failure to access directory %s: %#v", chartsFullPath, err) - chs.logger.Log("error", errm.Error()) + logger.Log("error", errm.Error()) return nil, errm } @@ -169,21 +241,23 @@ func (chs *ChartChangeSync) getChartDirs() (map[string]string, error) { // newCommits ... determines if charts need to be released // go-git.v4 does not provide a possibility to find commit for a particular path. // So we find if there are any commits at all sice last time -func (chs *ChartChangeSync) newCommits() (bool, error) { - chs.Lock() - defer chs.Unlock() +func (chs *ChartChangeSync) newCommits() (bool, string, error) { + chs.logger.Log("info", "Getting new commits") + + checkout := chs.release.Repo.ChartsSync.New - checkout := chs.release.Repo.ChartsSync + chs.logger.Log("info", fmt.Sprintf("Repo dir = %s", checkout.Dir)) if checkout.Dir == "" { ctx, cancel := context.WithTimeout(context.Background(), helmgit.DefaultCloneTimeout) - err := checkout.Clone(ctx, helmgit.ChartsChangesClone) + err := checkout.Clone(ctx, helmgit.ChartsChangesCloneNew) cancel() if err != nil { errm := fmt.Errorf("Failure while cloning repo : %#v", err) chs.logger.Log("error", errm.Error()) - return false, errm + return false, "", errm } + chs.logger.Log("info", "Cloned repo") } ctx, cancel := context.WithTimeout(context.Background(), helmgit.DefaultPullTimeout) @@ -192,73 +266,57 @@ func (chs *ChartChangeSync) newCommits() (bool, error) { if err != nil { errm := fmt.Errorf("Failure while pulling repo: %#v", err) chs.logger.Log("error", errm.Error()) - return false, errm + return false, "", errm } + chs.logger.Log("info", "Pulled repo") + // get latest revision - ctx, cancel = context.WithTimeout(context.Background(), helmgit.DefaultPullTimeout) newRev, err := checkout.GetRevision() - cancel() if err != nil { errm := fmt.Errorf("Failure while getting repo revision: %#v", err) chs.logger.Log("error", errm.Error()) - return false, errm + return false, "", errm } + chs.logger.Log("info", fmt.Sprintf("Got revision %s", newRev.String())) - // if lastCheckedCommit field is missing then all charts need to be assessed - oldRev := chs.lastCheckedCommit - if oldRev.String() == "" { - chs.lastCheckedCommit = newRev + oldRev := chs.lastCheckedRevision + if oldRev == "" { + chs.lastCheckedRevision = newRev.String() + chs.logger.Log("debug", fmt.Sprintf("Populated lastCheckedRevision: %s", chs.lastCheckedRevision)) - return true, nil + return false, "", nil } - // go-git.v4 does not provide a possibility to find commit for a particular path. - // So we find if there are any commits at all sice last time (since oldRev) - commitIter, err := checkout.Repo.Log(&git.LogOptions{From: oldRev}) - if err != nil { - errm := fmt.Errorf("Failure while getting commit info: %#v", err) - chs.logger.Log("error", errm.Error()) - return false, errm - } - var count int - err = commitIter.ForEach(func(c *object.Commit) error { - count = count + 1 - return nil - }) - if err != nil { - errm := fmt.Errorf("Failure while getting commit info: %#v", err) - chs.logger.Log("error", errm.Error()) - return false, errm - } + chs.logger.Log("info", fmt.Sprintf("lastCheckedRevision: %s", chs.lastCheckedRevision)) + chs.logger.Log("info", fmt.Sprintf("newRev: %s", newRev)) - if count > 0 { - return true, nil + if oldRev != newRev.String() { + return true, newRev.String(), nil } - return false, nil + return false, "", nil } // getCustomResources ... assembles custom resources referencing a particular chart -func (chs *ChartChangeSync) getCustomResources(namespaces []string, chart string, chartFhrs map[string][]ifv1.FluxHelmResource) error { - fhrs := []ifv1.FluxHelmResource{} - +func (chs *ChartChangeSync) getCustomResources(namespaces []string, chart string, chartFhrs map[string][]ifv1.FluxHelmRelease) error { chartSelector := map[string]string{ "chart": chart, } labelsSet := labels.Set(chartSelector) listOptions := metav1.ListOptions{LabelSelector: labelsSet.AsSelector().String()} + fhrs := []ifv1.FluxHelmRelease{} for _, ns := range namespaces { - list, err := chs.ifClient.IntegrationsV1().FluxHelmResources(ns).List(listOptions) + list, err := chs.ifClient.HelmV1alpha().FluxHelmReleases(ns).List(listOptions) if err != nil { - chs.logger.Log("error", fmt.Errorf("Failure while retrieving FluxHelmResources: %#v", err)) + chs.logger.Log("error", fmt.Errorf("Failure while retrieving FluxHelmReleases: %#v", err)) continue } for _, fhr := range list.Items { - fmt.Printf("\t\t>>> %v \n\n", fhr) fhrs = append(fhrs, fhr) } } + chartFhrs[chart] = fhrs return nil @@ -269,32 +327,18 @@ func (chs *ChartChangeSync) getCustomResources(namespaces []string, chart string // chartD ... provides chart name and its directory information // fhr ...... provides chart name and all Custom Resources associated with this chart // does a dry run and compares the manifests (and value file?) If differences => release) -func (chs *ChartChangeSync) releaseCharts(chartDirs map[string]string, chartFhrs map[string][]ifv1.FluxHelmResource) error { - helmCl := chs.release.HelmClient - checkout := chs.release.Repo.ChartsSync - for chart, _ := range chartDirs { +func (chs *ChartChangeSync) releaseCharts(chartToRelease map[string]string, chartFhrs map[string][]ifv1.FluxHelmRelease) error { + checkout := chs.release.Repo.ChartsSync.New + + for chart := range chartToRelease { + fmt.Printf("\t... chart %s...chartDirs = %s\n", chart, chartToRelease[chart]) + + var err error fhrs := chartFhrs[chart] for _, fhr := range fhrs { rlsName := chartrelease.GetReleaseName(fhr) - // get current release - currRlsRes, err := helmCl.ReleaseContent(rlsName) - if err != nil { - chs.logger.Log("info", fmt.Sprintf("Getting release [%s] for upgrade due to charts changes: %s. Skipping.", rlsName, err.Error())) - continue - } - // get dry-run of a new release - newRls, err := chs.release.Install(checkout, rlsName, fhr, "UPDATE", true) - if err != nil { - chs.logger.Log("info", fmt.Sprintf("Error during dry run upgrade of release of [%s]: %s. Skipping.", rlsName, err.Error())) - continue - } - // compare manifests => release if different - currMnf := currRlsRes.Release.GetManifest() - newMnf := newRls.GetManifest() - if currMnf == newMnf { - continue - } + chs.logger.Log("info", "INSTALLING") _, err = chs.release.Install(checkout, rlsName, fhr, "UPDATE", false) if err != nil { chs.logger.Log("info", fmt.Sprintf("Error during dry run upgrade of release of [%s]: %s. Skipping.", rlsName, err.Error())) @@ -304,7 +348,39 @@ func (chs *ChartChangeSync) releaseCharts(chartDirs map[string]string, chartFhrs chs.logger.Log("info", fmt.Sprintf("Release [%s] upgraded due to chart only changes", rlsName)) } } - //NEXT: return nil } + +// releaseNeeded ... finds if there were commits in the repo since the last charts sync +// returns maps keys on chart name with value corresponding to the chart path +// (go-git.v4 does not provide a possibility to find commit for a particular path.) +func (chs *ChartChangeSync) releaseNeeded(ctx context.Context, chartDirsCurr map[string]string, chartDirsNew map[string]string, chartFhr map[string][]ifv1.FluxHelmRelease) (map[string]string, error) { + chartToRelease := make(map[string]string) + var changed bool + var err error + var fhrs []ifv1.FluxHelmRelease + + for chart, dirN := range chartDirsNew { + chs.logger.Log("debug", fmt.Sprintf("Testing if release needed for Chart [%s]", chart)) + + if dirO, ok := chartDirsCurr[chart]; ok { + if fhrs, ok = chartFhr[chart]; !ok { + continue + } + if len(fhrs) < 1 { + continue + } + + if changed, err = chs.chartChanged(ctx, dirO, dirN); err != nil { + chs.logger.Log("error", fmt.Sprintf("Failure to determine chart change for [%s]: %s", chart, err.Error())) + continue + } + if !changed { + continue + } + chartToRelease[chart] = dirN + } + } + return chartToRelease, nil +} diff --git a/integrations/helm/chartsync/utils.go b/integrations/helm/chartsync/utils.go new file mode 100644 index 000000000..c4c873254 --- /dev/null +++ b/integrations/helm/chartsync/utils.go @@ -0,0 +1,85 @@ +package chartsync + +import ( + "bytes" + "context" + "fmt" + "io" + "io/ioutil" + "os/exec" + "strings" +) + +// ComparePaths ... used to establish which Chart has changed since last sync +func (chs *ChartChangeSync) chartChanged(ctx context.Context, path1, path2 string) (bool, error) { + chs.release.Repo.ChartsSync.Curr.Lock() + defer chs.release.Repo.ChartsSync.Curr.Unlock() + chs.release.Repo.ChartsSync.New.Lock() + defer chs.release.Repo.ChartsSync.New.Unlock() + + if len(path1) == 0 || path1[0] != '/' { + return false, fmt.Errorf("path [%s] must provided and must be absolute", path1) + } + if len(path2) == 0 || path2[0] != '/' { + return false, fmt.Errorf("path [%s] must provided and must be absolute", path2) + } + + out := &bytes.Buffer{} + if err := chs.execDiffCmd(ctx, out, path1, path2); err != nil { + return false, err + } + + lines := splitList(out.String()) + if len(lines) < 1 { + return false, nil + } + return true, nil +} + +func splitList(s string) []string { + outStr := strings.TrimSpace(s) + if outStr == "" { + return []string{} + } + + lines := []string{} + lines = strings.Split(outStr, "\n") + + return lines +} + +func (chs *ChartChangeSync) execDiffCmd(ctx context.Context, out io.Writer, args ...string) error { + args = append([]string{"-r"}, args...) + c := exec.CommandContext(ctx, "diff", args...) + + chs.logger.Log("info", fmt.Sprintf("Running command: diff %v", args)) + + c.Stdout = ioutil.Discard + if out != nil { + c.Stdout = out + } + errOut := &bytes.Buffer{} + c.Stderr = errOut + + err := c.Run() + if err != nil { + + // TODO/DEBUG: investigate and fix + // Getting an &exec.ExitError when there is a diff result + // This works with ls command and its output. Comparing both outputs, + // I can see diff output is more complicated. + if exitError, ok := err.(*exec.ExitError); ok { + chs.logger.Log("error", fmt.Sprintf("Failure while diffing: %#v", exitError.Error())) + return err + } + } + + if ctx.Err() == context.DeadlineExceeded { + return fmt.Errorf("running diff command: %s %v", "diff", args) + } else if ctx.Err() == context.Canceled { + return fmt.Errorf("context was unexpectedly cancelled when running command: %s %v", "diff", args) + } + + //fmt.Printf("* error while diffing = %+v\n\n", err) + return err +} diff --git a/integrations/helm/git/git.go b/integrations/helm/git/git.go index 8743cee74..96de80382 100644 --- a/integrations/helm/git/git.go +++ b/integrations/helm/git/git.go @@ -18,11 +18,12 @@ import ( ) const ( - DefaultCloneTimeout = 2 * time.Minute - DefaultPullTimeout = 2 * time.Minute - privateKeyFileMode = os.FileMode(0400) - FhrsChangesClone = "fhrs_sync_gitclone" - ChartsChangesClone = "charts_sync_gitclone" + DefaultCloneTimeout = 2 * time.Minute + DefaultPullTimeout = 2 * time.Minute + privateKeyFileMode = os.FileMode(0400) + FhrsChangesClone = "fhrs_sync_clone" + ChartsChangesCloneCurr = "charts_sync_clone_old" + ChartsChangesCloneNew = "charts_sync_clone_new" ) var ( @@ -84,21 +85,18 @@ func NewCheckout(logger log.Logger, config GitRemoteConfig, auth *gitssh.PublicK // * acting on Charts changes (syncing the cluster when there were only commits // in the Charts parts of the repo which did not trigger Custom Resource changes) func (ch *Checkout) Clone(ctx context.Context, cloneSubdir string) error { - fmt.Println("*** cloning") ch.Lock() defer ch.Unlock() if ch.Config.URL == "" { return ErrNoRepo } - //fmt.Println("\t\tstage 1") repoDir, err := ioutil.TempDir(os.TempDir(), cloneSubdir) if err != nil { return err } ch.Dir = repoDir - //fmt.Println("\t\tstage 2") repo, err := gogit.PlainClone(repoDir, false, &gogit.CloneOptions{ URL: ch.Config.URL, @@ -107,13 +105,11 @@ func (ch *Checkout) Clone(ctx context.Context, cloneSubdir string) error { if err != nil { return err } - //fmt.Println("\t\tstage 3") wt, err := repo.Worktree() if err != nil { return err } - //fmt.Println("\t\tstage 4") br := ch.Config.Branch err = wt.Checkout(&gogit.CheckoutOptions{ @@ -122,7 +118,6 @@ func (ch *Checkout) Clone(ctx context.Context, cloneSubdir string) error { if err != nil { return err } - //fmt.Println("\t\tstage 5") ch.Repo = repo ch.worktree = wt @@ -134,7 +129,6 @@ func (ch *Checkout) Clone(ctx context.Context, cloneSubdir string) error { // Cleanup ... removes the temp repo directory func (ch *Checkout) Cleanup() { - fmt.Println("*** cleanup") ch.Lock() defer ch.Unlock() @@ -180,7 +174,6 @@ func GetRepoAuth(k8sSecretVolumeMountPath, k8sSecretDataKey string) (*gitssh.Pub // Pull ... makes a git pull func (ch *Checkout) Pull(ctx context.Context) error { - fmt.Println("*** pulling") ch.Lock() defer ch.Unlock() diff --git a/integrations/helm/operator/operator.go b/integrations/helm/operator/operator.go index ead04eabd..ca13f674e 100644 --- a/integrations/helm/operator/operator.go +++ b/integrations/helm/operator/operator.go @@ -14,19 +14,16 @@ import ( "k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes/scheme" typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" - //appslisters "k8s.io/client-go/listers/apps/v1beta2" "k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/record" "k8s.io/client-go/util/workqueue" "github.com/go-kit/kit/log" - ifv1 "github.com/weaveworks/flux/apis/integrations.flux/v1" - clientset "github.com/weaveworks/flux/integrations/client/clientset/versioned" + ifv1 "github.com/weaveworks/flux/apis/helm.integrations.flux.weave.works/v1alpha" ifscheme "github.com/weaveworks/flux/integrations/client/clientset/versioned/scheme" - ifinformers "github.com/weaveworks/flux/integrations/client/informers/externalversions" - iflister "github.com/weaveworks/flux/integrations/client/listers/integrations.flux/v1" // kubernetes 1.9 - //iflister "github.com/weaveworks/flux/integrations/client/listers/integrations/v1" // kubernetes 1.8 + fhrv1 "github.com/weaveworks/flux/integrations/client/informers/externalversions/helm.integrations.flux.weave.works/v1alpha" + iflister "github.com/weaveworks/flux/integrations/client/listers/helm.integrations.flux.weave.works/v1alpha" // kubernetes 1.9 chartrelease "github.com/weaveworks/flux/integrations/helm/release" ) @@ -37,25 +34,25 @@ const ( const ( // ChartSynced is used as part of the Event 'reason' when the Chart related to the - // a FluxHelmResource gets released/updated + // a FluxHelmRelease gets released/updated ChartSynced = "ChartSynced" // ErrChartSync is used as part of the Event 'reason' when the related Chart related to the - // a FluxHelmResource fails to be released/updated + // a FluxHelmRelease 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 FluxHelmResource processed successfully" - // MessageErrChartSync - the message used for an Event fired when a FluxHelmResource + MessageChartSynced = "Chart managed by FluxHelmRelease processed successfully" + // MessageErrChartSync - the message used for an Event fired when a FluxHelmRelease // is synced successfully - MessageErrChartSync = "Chart %s managed by FluxHelmResource failed to be processed" + MessageErrChartSync = "Chart %s managed by FluxHelmRelease failed to be processed" ) -// Controller is the operator implementation for FluxHelmResource resources +// Controller is the operator implementation for FluxHelmRelease resources type Controller struct { logger log.Logger - fhrLister iflister.FluxHelmResourceLister + fhrLister iflister.FluxHelmReleaseLister fhrSynced cache.InformerSynced release *chartrelease.Release @@ -76,12 +73,13 @@ type Controller struct { func New( logger log.Logger, kubeclientset kubernetes.Interface, - fhrclientset clientset.Interface, - fhrInformerFactory ifinformers.SharedInformerFactory, + //fhrclientset clientset.Interface, + //fhrInformerFactory ifinformers.SharedInformerFactory, + fhrInformer fhrv1.FluxHelmReleaseInformer, release *chartrelease.Release) *Controller { - // Obtain reference to shared index informers for the FluxHelmResource - fhrInformer := fhrInformerFactory.Integrations().V1().FluxHelmResources() + // Obtain reference to shared index informers for the FluxHelmRelease + //fhrInformer := fhrInformerFactory.Integrations().V1().FluxHelmReleases() // Add helm-operator types to the default Kubernetes Scheme so Events can be // logged for helm-operator types. @@ -105,7 +103,7 @@ func New( controller.logger.Log("info", "Setting up event handlers") // -------------------------------------------------------------------- - // ----- EVENT HANDLERS for FluxHelmResource resources change --------- + // ----- EVENT HANDLERS for FluxHelmRelease resources change --------- fhrInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ AddFunc: func(new interface{}) { controller.logger.Log("info", "ADDING release") @@ -116,7 +114,6 @@ func New( }, UpdateFunc: func(old, new interface{}) { controller.enqueueUpateJob(old, new) - }, DeleteFunc: func(old interface{}) { fhr, ok := checkCustomResourceType(controller.logger, old) @@ -137,7 +134,6 @@ func New( func (c *Controller) Run(threadiness int, stopCh <-chan struct{}, wg *sync.WaitGroup) error { defer runtime.HandleCrash() defer c.releaseWorkqueue.ShutDown() - defer wg.Done() c.logger.Log("info", "Starting operator") // Wait for the caches to be synced before starting workers @@ -151,10 +147,14 @@ func (c *Controller) Run(threadiness int, stopCh <-chan struct{}, wg *sync.WaitG c.logger.Log("info", "Starting workers") for i := 0; i < threadiness; i++ { + wg.Add(1) go wait.Until(c.runWorker, time.Second, stopCh) } <-stopCh + for i := 0; i < threadiness; i++ { + wg.Done() + } c.logger.Log("info", "Stopping workers") return nil @@ -207,7 +207,7 @@ func (c *Controller) processNextWorkItem() bool { return nil } // Run the syncHandler, passing it the namespace/name string of the - // FluxHelmResource resource to sync the corresponding Chart release. + // FluxHelmRelease 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()) @@ -243,11 +243,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.FluxHelmResources(namespace).Get(name) + fhr, err := c.fhrLister.FluxHelmReleases(namespace).Get(name) if err != nil { if k8serrors.IsNotFound(err) { - c.logger.Log("info", fmt.Sprintf("Fluxhelmresource '%s' referred to in work queue no longer exists", key)) - runtime.HandleError(fmt.Errorf("Fluxhelmresource '%s' referred to in work queue no longer exists", key)) + 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)) return nil } c.logger.Log("error", err.Error()) @@ -270,21 +270,24 @@ func (c *Controller) syncHandler(key string) error { } // Chart installation of the appropriate type - _, err = c.release.Install(c.release.Repo.ChartsSync, releaseName, *fhr, syncType, false) + _, err = c.release.Install(c.release.Repo.ConfigSync, releaseName, *fhr, syncType, false) if err != nil { return err } + // TODO : bring the ChartsChangesCloneCurr uptodate + // needs locking because of chart syncing possibly kicking in simultaneously + c.recorder.Event(fhr, corev1.EventTypeNormal, ChartSynced, MessageChartSynced) return nil } -func checkCustomResourceType(logger log.Logger, obj interface{}) (ifv1.FluxHelmResource, bool) { - var fhr *ifv1.FluxHelmResource +func checkCustomResourceType(logger log.Logger, obj interface{}) (ifv1.FluxHelmRelease, bool) { + var fhr *ifv1.FluxHelmRelease var ok bool - if fhr, ok = obj.(*ifv1.FluxHelmResource); !ok { - logger.Log("error", fmt.Sprintf("FluxHelmResource Event Watch received an invalid object: %#v", obj)) - return ifv1.FluxHelmResource{}, false + if fhr, ok = obj.(*ifv1.FluxHelmRelease); !ok { + logger.Log("error", fmt.Sprintf("FluxHelmRelease Event Watch received an invalid object: %#v", obj)) + return ifv1.FluxHelmRelease{}, false } return *fhr, true } @@ -300,9 +303,9 @@ func getCacheKey(obj interface{}) (string, error) { return key, nil } -// enqueueJob takes a FluxHelmResource resource and converts it into a namespace/name +// enqueueJob takes a FluxHelmRelease 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 FluxHelmResource. +// passed resources of any type other than FluxHelmRelease. func (c *Controller) enqueueJob(obj interface{}) { var key string var err error @@ -333,7 +336,7 @@ func (c *Controller) enqueueUpateJob(old, new interface{}) { } } -func (c *Controller) deleteRelease(fhr ifv1.FluxHelmResource) { +func (c *Controller) deleteRelease(fhr ifv1.FluxHelmRelease) { c.logger.Log("info", "DELETING release") name := chartrelease.GetReleaseName(fhr) err := c.release.Delete(name) diff --git a/integrations/helm/release/release.go b/integrations/helm/release/release.go index dbc4fad95..2902de6ec 100644 --- a/integrations/helm/release/release.go +++ b/integrations/helm/release/release.go @@ -14,7 +14,7 @@ import ( hapi_release "k8s.io/helm/pkg/proto/hapi/release" "github.com/go-kit/kit/log" - ifv1 "github.com/weaveworks/flux/apis/integrations.flux/v1" + ifv1 "github.com/weaveworks/flux/apis/helm.integrations.flux.weave.works/v1alpha" helmgit "github.com/weaveworks/flux/integrations/helm/git" ) @@ -33,16 +33,21 @@ type Release struct { sync.RWMutex } +type ChartsSync struct { + Curr *helmgit.Checkout + New *helmgit.Checkout +} + type repo struct { ConfigSync *helmgit.Checkout - ChartsSync *helmgit.Checkout + ChartsSync *ChartsSync } // New creates a new Release instance -func New(logger log.Logger, helmClient *k8shelm.Client, configCheckout *helmgit.Checkout, chartsCheckout *helmgit.Checkout) *Release { +func New(logger log.Logger, helmClient *k8shelm.Client, configCheckout *helmgit.Checkout, chartsSync *ChartsSync) *Release { repo := repo{ ConfigSync: configCheckout, - ChartsSync: chartsCheckout, + ChartsSync: chartsSync, } r := &Release{ logger: logger, @@ -54,7 +59,7 @@ func New(logger log.Logger, helmClient *k8shelm.Client, configCheckout *helmgit. // GetReleaseName either retrieves the release name from the Custom Resource or constructs a new one // in the form : $Namespace-$CustomResourceName -func GetReleaseName(fhr ifv1.FluxHelmResource) string { +func GetReleaseName(fhr ifv1.FluxHelmRelease) string { namespace := fhr.Namespace if namespace == "" { namespace = "default" @@ -72,7 +77,10 @@ func GetReleaseName(fhr ifv1.FluxHelmResource) string { // Get ... detects if a particular Chart release exists // release name must match regex ^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])+$ func (r *Release) Exists(name string) (bool, error) { + r.Lock() rls, err := r.HelmClient.ReleaseContent(name) + r.Unlock() + if err != nil { //r.logger.Log("debug", fmt.Sprintf("Getting release (%s): %v", name, err)) return false, err @@ -98,7 +106,10 @@ func (r *Release) Exists(name string) (bool, error) { } func (r *Release) canDelete(name string) (bool, error) { + r.Lock() rls, err := r.HelmClient.ReleaseStatus(name) + r.Unlock() + if err != nil { r.logger.Log("error", fmt.Sprintf("Error finding status for release (%s): %#v", name, err)) return false, err @@ -131,10 +142,7 @@ func (r *Release) canDelete(name string) (bool, error) { // Install ... performs Chart release. Depending on the release type, this is either a new release, // or an upgrade of an existing one -func (r *Release) Install(checkout *helmgit.Checkout, releaseName string, fhr ifv1.FluxHelmResource, releaseType ReleaseType, dryRun bool) (hapi_release.Release, error) { - r.Lock() - defer r.Unlock() - +func (r *Release) Install(checkout *helmgit.Checkout, releaseName string, fhr ifv1.FluxHelmRelease, releaseType ReleaseType, dryRun bool) (hapi_release.Release, error) { r.logger.Log("info", fmt.Sprintf("releaseName= %s, releaseType=%s", releaseName, releaseType)) chartPath := fhr.Spec.ChartGitPath @@ -157,9 +165,9 @@ func (r *Release) Install(checkout *helmgit.Checkout, releaseName string, fhr if return hapi_release.Release{}, errm } - chartDir := filepath.Join(checkout.Dir, chartPath) + chartDir := filepath.Join(checkout.Dir, checkout.Config.Path, chartPath) - rawVals, err := collectValues(fhr.Spec.Customizations) + rawVals, err := collectValues(fhr.Spec.Values) if err != nil { r.logger.Log("error", fmt.Sprintf("Problem with supplied customizations for Chart release [%s]: %#v", releaseName, err)) return hapi_release.Release{}, err @@ -168,6 +176,7 @@ func (r *Release) Install(checkout *helmgit.Checkout, releaseName string, fhr if // INSTALLATION ---------------------------------------------------------------------- switch releaseType { case "CREATE": + r.Lock() res, err := r.HelmClient.InstallRelease( chartDir, namespace, @@ -181,12 +190,15 @@ func (r *Release) Install(checkout *helmgit.Checkout, releaseName string, fhr if helm.InstallWait(i.wait) */ ) + r.Unlock() + if err != nil { r.logger.Log("error", fmt.Sprintf("Chart release failed: %s: %#v", releaseName, err)) return hapi_release.Release{}, err } return *res.Release, nil case "UPDATE": + r.Lock() res, err := r.HelmClient.UpdateRelease( releaseName, chartDir, @@ -201,24 +213,23 @@ func (r *Release) Install(checkout *helmgit.Checkout, releaseName string, fhr if helm.ReuseValues(u.reuseValues), helm.UpgradeWait(u.wait)) */ - ) + r.Unlock() + if err != nil { r.logger.Log("error", fmt.Sprintf("Chart upgrade release failed: %s: %#v", releaseName, err)) return hapi_release.Release{}, err } return *res.Release, nil default: - r.logger.Log("error", fmt.Sprintf("Valid ReleaseType options: CREATE, UPDATE. Provided: %s", releaseType)) + err = fmt.Errorf("Valid ReleaseType options: CREATE, UPDATE. Provided: %s", releaseType) + r.logger.Log("error", err.Error()) return hapi_release.Release{}, err } } // Delete ... deletes Chart release func (r *Release) Delete(name string) error { - r.Lock() - defer r.Unlock() - ok, err := r.canDelete(name) if !ok { if err != nil { @@ -227,7 +238,9 @@ func (r *Release) Delete(name string) error { return nil } + r.Lock() _, err = r.HelmClient.DeleteRelease(name) + r.Unlock() if err != nil { r.logger.Log("error", fmt.Sprintf("Release deletion error: %#v", err)) return err diff --git a/site/helm/helm-integration-requirements.md b/site/helm/helm-integration-requirements.md new file mode 100644 index 000000000..0ad824029 --- /dev/null +++ b/site/helm/helm-integration-requirements.md @@ -0,0 +1,62 @@ +--- +title: Requirements for Helm Integration with Flux (alpha stage) +menu_order: 20 +--- + +# Helm + + - tiller should be running in the cluster, though helm-operator will wait until it can find one. + +# Git repo + + - One repo containing both desired release state information and Charts themselves + - Release state information in the form of Custom Resources manifests is located under a particular path ("releaseconfig" by default; can be overriden) + - Charts are colocated under another path ("charts" by default; can be overriden). Charts are subdirectories under the charts path. + - Custom Resource namespace reflects where the release should be done. Both the Helm application and its corresponding Custom Resource will live in this namespace. + - example of a test repo: https://github.com/tamarakaufler/flux-helm-test + +# Custom Resource manifest content +## Example of manifest content + +``` +--- + apiVersion: helm.integrations.flux.weave.works/v1alpha + kind: FluxHelmRelease + metadata: + name: mongodb + namespace: myNamespace + labels: + chart: mongodb + spec: + chartGitPath: mongodb + releaseName: mongo-database + values: + - name: image + value: bitnami/mongodb:3.7.1-r1 +``` + +## Required fields + + - name + - namespace + - label.chart ... the same as chartgitpath, with slash replaced with an underscore + - chartGitPath ... path (from repo root) to a Chart subdirectory + + +## Optional fields + + - releaseName: + + - if a release already exists and Flux should start managing it, then releasename must be provided + - if releasename is not provided, Flux will construct a release name based on the namespace and the Custom Resource name (ie $namespace-$CR_name) + + - values: + - name + - value + + a list of name and value couples for overriding Chart parameters. Examples of parameter names: + - image + - resources.requests.memory + + + diff --git a/site/helm/helm-integration.md b/site/helm/helm-integration.md new file mode 100644 index 000000000..e9708a02d --- /dev/null +++ b/site/helm/helm-integration.md @@ -0,0 +1,87 @@ +--- +title: Helm Integration with Flux +menu_order: 10 +--- + +# Purpose + +Helm integration provides an extension to Flux to be able to deal with Helm Chart releases.sp +As Helm has gained prominence among Kubernetes tools, Weave Deploy functionality, +facilitated by Flux, has been extended to cater for deployments described though Helm +Charts. + +# Design overview + +Chart release information is described through Kubernetes Custom Resource (CR) manifests. + +Flux-Helm Integration implementation consists of two parts: + +1. *Flux agent* monitors user git repo containing deployment configuration for applications/services, ie Custom Resource manifests. On detecting changes it applies the manifests, resulting in creation or update of Custom Resources. + +2. *Helm operator* deals with Helm Chart releases. The operator watches for changes of Custom Resources of kind FluxHelmResource. It receives Kubernetes Events and acts accordingly, installing, upgrading or deleting a Chart release. + +## More detail + + - Kubernetes Custom Resource (CR) manifests contain all the information needed to do a Chart release. There is 1-2-1 releationship between a Helm Chart and a Custom Resource. + + - Custom resource manifests can be provided several/all in one file, or in individual files. + + - Flux works, at the moment, with one git repo. For Helm integration this repo will initially contain both the desired Chart release information (CR manifests) and Chart directories for each application/service. + + - All Chart release configuration is located under one git path. All Chart directories are located under one git path. The git paths must be subdirectories under the repo root. + + - Example of Custom Resource manifest: + ``` +--- + apiVersion: helm.integrations.flux.weave.works/v1alpha + kind: FluxHelmRelease + metadata: + name: mongodb + namespace: myNamespace + labels: + chart: mongodb + spec: + chartGitPath: mongodb + releaseName: mongo-database + values: + - name: image + value: bitnami/mongodb:3.7.1-r1 + ``` + + - name of the resource must be unique across all namespaces + - namespace is where both the Custom Resource and the Chart, whose deployment state it describes, will live + - labels.chart must be provided. the label contains this Chart's path within the repo (slash replaced with underscore) + - chartgitpath ... this Chart's path within the repo + - releasename is optional. Must be provided if there is already a Chart release in the cluster that Flux should start looking after. Otherwise a new release is created for the application/service when the Custom Resource is created. Can be provided for a brand new release - if it is not, then Flux will create a release names as $namespace-$CR_name + - customizations section contains user customizations overriding the Chart values + + - Helm operator uses (Kubernetes) shared informer caching and a work queue, that is processed by a configurable number of workers. +# Setup and configuration + +helm-operator requires setup and offers customization though a multitude of flags. +(TODO: change the flags to reflect reality) + +|flag | default | purpose | +|------------------------|-------------------------------|---------| +|--kubernetes-kubectl | | Optional, explicit path to kubectl tool.| +|--kubeconfig | | Path to a kubeconfig. Only required if out-of-cluster.| +|--master | | The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.| + +|**Tiller options.**| || +|--tillerIP | | Tiller IP address. Only required if out-of-cluster.| +|--tillerPort | | Tiller port.| +|--tillerNamespace | | Tiller namespace. If not provided, the default is kube-system.| +|**Git repo & key etc.** | || +|--git-url | | URL of git repo with Helm Charts; e.g., `git@github.com:weaveworks/flux-example`| +|--git-branch | `master` | Branch of git repo to use for Kubernetes manifests| +|--git-charts-path | `charts` | Path within git repo to locate Kubernetes Charts (relative path)| +|**repo chart changes** | | (none of these need overriding, usually) | +|--git-poll-interval | `5 minutes` | period at which to poll git repo for new commits| +|--chartsSyncInterval | 3*time.Minute | Interval at which to check for changed charts.| +|--chartsSyncTimeout | 1*time.Minute | Timeout when checking for changed charts.| +|**k8s-secret backed ssh keyring configuration** | | | +|--k8s-secret-volume-mount-path | `/etc/fluxd/ssh` | Mount location of the k8s secret storing the private SSH key| +|--k8s-secret-data-key | `identity` | Data key holding the private SSH key within the k8s secret| +|--queueWorkerCount | 2 | Number of workers to process queue with Chart release jobs.| + +[Requirements](./helm-integration-requirements.md)