From c36e02bba92f3258650813a7716bcd01bddcef5c Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Mon, 14 Sep 2020 17:10:22 +0300 Subject: [PATCH] Update kustomize-controller to v0.0.12 --- cmd/gotk/bootstrap.go | 2 +- cmd/gotk/create_kustomization.go | 26 +++++++++++++------ go.mod | 2 +- go.sum | 4 +-- .../kustomize-controller/kustomization.yaml | 4 +-- 5 files changed, 24 insertions(+), 14 deletions(-) diff --git a/cmd/gotk/bootstrap.go b/cmd/gotk/bootstrap.go index ca26b04d..cea44e90 100644 --- a/cmd/gotk/bootstrap.go +++ b/cmd/gotk/bootstrap.go @@ -186,7 +186,7 @@ func generateSyncManifests(url, branch, name, namespace, targetPath, tmpDir stri }, Path: fmt.Sprintf("./%s", strings.TrimPrefix(targetPath, "./")), Prune: true, - SourceRef: kustomizev1.CrossNamespaceObjectReference{ + SourceRef: kustomizev1.CrossNamespaceSourceReference{ Kind: sourcev1.GitRepositoryKind, Name: name, }, diff --git a/cmd/gotk/create_kustomization.go b/cmd/gotk/create_kustomization.go index 2ef858fa..dc874917 100644 --- a/cmd/gotk/create_kustomization.go +++ b/cmd/gotk/create_kustomization.go @@ -30,6 +30,7 @@ import ( "k8s.io/apimachinery/pkg/util/wait" "sigs.k8s.io/controller-runtime/pkg/client" + helmv2 "github.com/fluxcd/helm-controller/api/v2alpha1" kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1alpha1" sourcev1 "github.com/fluxcd/source-controller/api/v1alpha1" ) @@ -139,7 +140,7 @@ func createKsCmdRun(cmd *cobra.Command, args []string) error { }, Path: ksPath, Prune: ksPrune, - SourceRef: kustomizev1.CrossNamespaceObjectReference{ + SourceRef: kustomizev1.CrossNamespaceSourceReference{ Kind: sourcev1.GitRepositoryKind, Name: ksSource, }, @@ -149,31 +150,40 @@ func createKsCmdRun(cmd *cobra.Command, args []string) error { } if len(ksHealthCheck) > 0 { - healthChecks := make([]kustomizev1.WorkloadReference, 0) + healthChecks := make([]kustomizev1.CrossNamespaceObjectReference, 0) for _, w := range ksHealthCheck { kindObj := strings.Split(w, "/") if len(kindObj) != 2 { return fmt.Errorf("invalid health check '%s' must be in the format 'kind/name.namespace' %v", w, kindObj) } kind := kindObj[0] + + //TODO: (stefan) extend this list with all the kstatus builtin kinds kinds := map[string]bool{ - "Deployment": true, - "DaemonSet": true, - "StatefulSet": true, + "Deployment": true, + "DaemonSet": true, + "StatefulSet": true, + helmv2.HelmReleaseKind: true, } if !kinds[kind] { - return fmt.Errorf("invalid health check kind '%s' can be Deployment, DaemonSet or StatefulSet", kind) + return fmt.Errorf("invalid health check kind '%s' can be HelmRelease, Deployment, DaemonSet or StatefulSet", kind) } nameNs := strings.Split(kindObj[1], ".") if len(nameNs) != 2 { return fmt.Errorf("invalid health check '%s' must be in the format 'kind/name.namespace'", w) } - healthChecks = append(healthChecks, kustomizev1.WorkloadReference{ + check := kustomizev1.CrossNamespaceObjectReference{ Kind: kind, Name: nameNs[0], Namespace: nameNs[1], - }) + } + + //TODO: (stefan) define the API version as a constant in the API package + if kind == helmv2.HelmReleaseKind { + check.APIVersion = "helm.toolkit.fluxcd.io/v2alpha1" + } + healthChecks = append(healthChecks, check) } kustomization.Spec.HealthChecks = healthChecks kustomization.Spec.Timeout = &metav1.Duration{ diff --git a/go.mod b/go.mod index 8c8b34b3..d98a48d1 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.14 require ( github.com/blang/semver v3.5.1+incompatible github.com/fluxcd/helm-controller/api v0.0.8 - github.com/fluxcd/kustomize-controller/api v0.0.11 + github.com/fluxcd/kustomize-controller/api v0.0.12 github.com/fluxcd/pkg/git v0.0.7 github.com/fluxcd/pkg/runtime v0.0.1 github.com/fluxcd/pkg/ssh v0.0.5 diff --git a/go.sum b/go.sum index 2fdcd32b..de633598 100644 --- a/go.sum +++ b/go.sum @@ -113,8 +113,8 @@ github.com/evanphx/json-patch v4.5.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLi github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fluxcd/helm-controller/api v0.0.8 h1:Pf+hZjsUpRmoQJeCe178bGWOOm2/Bvg8/s0aafRa1wQ= github.com/fluxcd/helm-controller/api v0.0.8/go.mod h1:KlzwTkpphQxulgWBwCl/uxfBU0QxK/X+w4YcJqGy/1c= -github.com/fluxcd/kustomize-controller/api v0.0.11 h1:uFL0FT0AP+NmHR8upy+Y7AhBqcWQh2Lvp1F9FXL22iQ= -github.com/fluxcd/kustomize-controller/api v0.0.11/go.mod h1:88m3p6xY3J2pjh5OsL3ANy7PkyA93KiqAJE58JMQyoc= +github.com/fluxcd/kustomize-controller/api v0.0.12 h1:4wTGH+Mf0jmvVMmUg39LHbQto6pT3aescyPr2xT/5os= +github.com/fluxcd/kustomize-controller/api v0.0.12/go.mod h1:88m3p6xY3J2pjh5OsL3ANy7PkyA93KiqAJE58JMQyoc= github.com/fluxcd/pkg/git v0.0.7 h1:tFSYPy7tcIYfOt8H5EUERXIRz7fk0id302oQZde1NtU= github.com/fluxcd/pkg/git v0.0.7/go.mod h1:5Vu92x6Q3CpxDUllmB69kAkVY5jAtPpXcY2TSZ/oCJI= github.com/fluxcd/pkg/runtime v0.0.1 h1:h8jztHVF9UMGD7XBQSfXDdw80bpT6BOkd0xe4kknPL0= diff --git a/manifests/bases/kustomize-controller/kustomization.yaml b/manifests/bases/kustomize-controller/kustomization.yaml index 834eec50..c792520e 100644 --- a/manifests/bases/kustomize-controller/kustomization.yaml +++ b/manifests/bases/kustomize-controller/kustomization.yaml @@ -1,8 +1,8 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: -- github.com/fluxcd/kustomize-controller/config//crd?ref=v0.0.11 -- github.com/fluxcd/kustomize-controller/config//manager?ref=v0.0.11 +- github.com/fluxcd/kustomize-controller/config//crd?ref=v0.0.12 +- github.com/fluxcd/kustomize-controller/config//manager?ref=v0.0.12 patchesJson6902: - target: group: apps