From 347c2b6bcc55ab2b36944b5e7941d275fa58c13a Mon Sep 17 00:00:00 2001 From: fluxcdbot Date: Tue, 22 Sep 2020 13:17:27 +0000 Subject: [PATCH 1/2] Update toolkit components --- go.mod | 8 ++++---- go.sum | 16 ++++++++-------- .../bases/helm-controller/kustomization.yaml | 4 ++-- .../kustomize-controller/kustomization.yaml | 4 ++-- .../notification-controller/kustomization.yaml | 4 ++-- .../bases/source-controller/kustomization.yaml | 4 ++-- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/go.mod b/go.mod index 55bbf26d..88663d6f 100644 --- a/go.mod +++ b/go.mod @@ -4,13 +4,13 @@ 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.12 + github.com/fluxcd/helm-controller/api v0.0.9 + github.com/fluxcd/kustomize-controller/api v0.0.13 github.com/fluxcd/pkg/git v0.0.7 - github.com/fluxcd/pkg/runtime v0.0.1 + github.com/fluxcd/pkg/runtime v0.0.3 github.com/fluxcd/pkg/ssh v0.0.5 github.com/fluxcd/pkg/untar v0.0.5 - github.com/fluxcd/source-controller/api v0.0.16 + github.com/fluxcd/source-controller/api v0.0.17 github.com/manifoldco/promptui v0.7.0 github.com/spf13/cobra v1.0.0 golang.org/x/net v0.0.0-20200602114024-627f9648deb9 // indirect diff --git a/go.sum b/go.sum index e9841e89..6065969c 100644 --- a/go.sum +++ b/go.sum @@ -111,20 +111,20 @@ github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLi github.com/evanphx/json-patch v4.5.0+incompatible h1:ouOWdg56aJriqS0huScTkVXPC5IcNrDCXZ6OoTAWu7M= github.com/evanphx/json-patch v4.5.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= 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.12 h1:4wTGH+Mf0jmvVMmUg39LHbQto6pT3aescyPr2xT/5os= -github.com/fluxcd/kustomize-controller/api v0.0.12/go.mod h1:88m3p6xY3J2pjh5OsL3ANy7PkyA93KiqAJE58JMQyoc= +github.com/fluxcd/helm-controller/api v0.0.9 h1:mE3mmUlPEwoKSOQi0LC0gvNoMpzsI6ls29DmW894yP0= +github.com/fluxcd/helm-controller/api v0.0.9/go.mod h1:m6f9E3SniPQhdBJj5f1uUTGSDimERl3fHhTouTfBAq4= +github.com/fluxcd/kustomize-controller/api v0.0.13 h1:5ktXXMzsNEoQtSdC7OF606JLV2k/+SzJrgWZ8kx05pg= +github.com/fluxcd/kustomize-controller/api v0.0.13/go.mod h1:zr/JbKgyikeFnWM2eE5h+zMxZ7Ey3JITEAuH5OjGDIo= 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= -github.com/fluxcd/pkg/runtime v0.0.1/go.mod h1:cU1t0+Ld39pZjMyrrHukw1E++OZFNHxG2qAExfDWQ34= +github.com/fluxcd/pkg/runtime v0.0.3 h1:x9rOThl1qh5srIUpW0YHEj1I84swMj5m76UqrR1QknY= +github.com/fluxcd/pkg/runtime v0.0.3/go.mod h1:ECBTeplxhgbCJYIjmtwn3ZS0A91/+6YtOS4w2G0LeK4= github.com/fluxcd/pkg/ssh v0.0.5 h1:rnbFZ7voy2JBlUfMbfyqArX2FYaLNpDhccGFC3qW83A= github.com/fluxcd/pkg/ssh v0.0.5/go.mod h1:7jXPdXZpc0ttMNz2kD9QuMi3RNn/e0DOFbj0Tij/+Hs= github.com/fluxcd/pkg/untar v0.0.5 h1:UGI3Ch1UIEIaqQvMicmImL1s9npQa64DJ/ozqHKB7gk= github.com/fluxcd/pkg/untar v0.0.5/go.mod h1:O6V9+rtl8c1mHBafgqFlJN6zkF1HS5SSYn7RpQJ/nfw= -github.com/fluxcd/source-controller/api v0.0.16 h1:Mk+X2H+5CX7vfmrVhGT/TR8EnZ8UmZ20TpPyP3e8ZBs= -github.com/fluxcd/source-controller/api v0.0.16/go.mod h1:PUe+EYQ/s+KPnz2iOCgdf+L6clM0SWkyvdXIpbfpkQE= +github.com/fluxcd/source-controller/api v0.0.17 h1:LQR6VR/CATAV+RDcK3rPgA66IW5CFbhAH4Prm0UBL5Y= +github.com/fluxcd/source-controller/api v0.0.17/go.mod h1:PUe+EYQ/s+KPnz2iOCgdf+L6clM0SWkyvdXIpbfpkQE= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= diff --git a/manifests/bases/helm-controller/kustomization.yaml b/manifests/bases/helm-controller/kustomization.yaml index af58fe99..7d9c57b4 100644 --- a/manifests/bases/helm-controller/kustomization.yaml +++ b/manifests/bases/helm-controller/kustomization.yaml @@ -1,8 +1,8 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: -- https://github.com/fluxcd/helm-controller/archive/v0.0.8.zip//helm-controller-0.0.8/config/crd -- https://github.com/fluxcd/helm-controller/archive/v0.0.8.zip//helm-controller-0.0.8/config/manager +- https://github.com/fluxcd/helm-controller/archive/v0.0.9.zip//helm-controller-0.0.9/config/crd +- https://github.com/fluxcd/helm-controller/archive/v0.0.9.zip//helm-controller-0.0.9/config/manager patchesJson6902: - target: group: apps diff --git a/manifests/bases/kustomize-controller/kustomization.yaml b/manifests/bases/kustomize-controller/kustomization.yaml index af6df1e1..2a5c8395 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: -- https://github.com/fluxcd/kustomize-controller/archive/v0.0.12.zip//kustomize-controller-0.0.12/config/crd -- https://github.com/fluxcd/kustomize-controller/archive/v0.0.12.zip//kustomize-controller-0.0.12/config/manager +- https://github.com/fluxcd/kustomize-controller/archive/v0.0.13.zip//kustomize-controller-0.0.13/config/crd +- https://github.com/fluxcd/kustomize-controller/archive/v0.0.13.zip//kustomize-controller-0.0.13/config/manager patchesJson6902: - target: group: apps diff --git a/manifests/bases/notification-controller/kustomization.yaml b/manifests/bases/notification-controller/kustomization.yaml index d3784ae1..e5d81701 100644 --- a/manifests/bases/notification-controller/kustomization.yaml +++ b/manifests/bases/notification-controller/kustomization.yaml @@ -1,5 +1,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: -- https://github.com/fluxcd/notification-controller/archive/v0.0.10.zip//notification-controller-0.0.10/config/crd -- https://github.com/fluxcd/notification-controller/archive/v0.0.10.zip//notification-controller-0.0.10/config/manager +- https://github.com/fluxcd/notification-controller/archive/v0.0.11.zip//notification-controller-0.0.11/config/crd +- https://github.com/fluxcd/notification-controller/archive/v0.0.11.zip//notification-controller-0.0.11/config/manager diff --git a/manifests/bases/source-controller/kustomization.yaml b/manifests/bases/source-controller/kustomization.yaml index 7e311455..cbec980b 100644 --- a/manifests/bases/source-controller/kustomization.yaml +++ b/manifests/bases/source-controller/kustomization.yaml @@ -1,8 +1,8 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: -- https://github.com/fluxcd/source-controller/archive/v0.0.16.zip//source-controller-0.0.16/config/crd -- https://github.com/fluxcd/source-controller/archive/v0.0.16.zip//source-controller-0.0.16/config/manager +- https://github.com/fluxcd/source-controller/archive/v0.0.17.zip//source-controller-0.0.17/config/crd +- https://github.com/fluxcd/source-controller/archive/v0.0.17.zip//source-controller-0.0.17/config/manager patchesJson6902: - target: group: apps From 1c7994a3532629547cbef33508953adc93a22e75 Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Tue, 22 Sep 2020 17:18:04 +0300 Subject: [PATCH 2/2] Add support for namespace/name format in depends-on --- cmd/gotk/create_helmrelease.go | 4 ++-- cmd/gotk/create_kustomization.go | 4 ++-- cmd/gotk/utils.go | 22 ++++++++++++++++++++++ docs/cmd/gotk_create_helmrelease.md | 2 +- docs/cmd/gotk_create_kustomization.md | 2 +- 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/cmd/gotk/create_helmrelease.go b/cmd/gotk/create_helmrelease.go index 562b6115..2b6a61f5 100644 --- a/cmd/gotk/create_helmrelease.go +++ b/cmd/gotk/create_helmrelease.go @@ -98,7 +98,7 @@ func init() { createHelmReleaseCmd.Flags().StringVar(&hrSource, "source", "", "source that contains the chart (/)") createHelmReleaseCmd.Flags().StringVar(&hrChart, "chart", "", "Helm chart name or path") createHelmReleaseCmd.Flags().StringVar(&hrChartVersion, "chart-version", "", "Helm chart version, accepts a semver range (ignored for charts from GitRepository sources)") - createHelmReleaseCmd.Flags().StringArrayVar(&hrDependsOn, "depends-on", nil, "HelmReleases that must be ready before this release can be installed") + createHelmReleaseCmd.Flags().StringArrayVar(&hrDependsOn, "depends-on", nil, "HelmReleases that must be ready before this release can be installed, supported formats '' and '/'") createHelmReleaseCmd.Flags().StringVar(&hrTargetNamespace, "target-namespace", "", "namespace to install this release, defaults to the HelmRelease namespace") createHelmReleaseCmd.Flags().StringVar(&hrValuesFile, "values", "", "local path to the values.yaml file") createCmd.AddCommand(createHelmReleaseCmd) @@ -143,7 +143,7 @@ func createHelmReleaseCmdRun(cmd *cobra.Command, args []string) error { }, Spec: helmv2.HelmReleaseSpec{ ReleaseName: hrName, - DependsOn: hrDependsOn, + DependsOn: utils.makeDependsOn(hrDependsOn), Interval: metav1.Duration{ Duration: interval, }, diff --git a/cmd/gotk/create_kustomization.go b/cmd/gotk/create_kustomization.go index 95364dbe..e5898692 100644 --- a/cmd/gotk/create_kustomization.go +++ b/cmd/gotk/create_kustomization.go @@ -94,7 +94,7 @@ func init() { createKsCmd.Flags().StringArrayVar(&ksHealthCheck, "health-check", nil, "workload to be included in the health assessment, in the format '/.'") createKsCmd.Flags().DurationVar(&ksHealthTimeout, "health-check-timeout", 2*time.Minute, "timeout of health checking operations") createKsCmd.Flags().StringVar(&ksValidation, "validation", "", "validate the manifests before applying them on the cluster, can be 'client' or 'server'") - createKsCmd.Flags().StringArrayVar(&ksDependsOn, "depends-on", nil, "Kustomization that must be ready before this Kustomization can be applied") + createKsCmd.Flags().StringArrayVar(&ksDependsOn, "depends-on", nil, "Kustomization that must be ready before this Kustomization can be applied, supported formats '' and '/'") createKsCmd.Flags().StringVar(&ksSAName, "sa-name", "", "service account name") createKsCmd.Flags().StringVar(&ksSANamespace, "sa-namespace", "", "service account namespace") createKsCmd.Flags().StringVar(&ksDecryptionProvider, "decryption-provider", "", "enables secrets decryption, provider can be 'sops'") @@ -134,7 +134,7 @@ func createKsCmdRun(cmd *cobra.Command, args []string) error { Labels: ksLabels, }, Spec: kustomizev1.KustomizationSpec{ - DependsOn: ksDependsOn, + DependsOn: utils.makeDependsOn(hrDependsOn), Interval: metav1.Duration{ Duration: interval, }, diff --git a/cmd/gotk/utils.go b/cmd/gotk/utils.go index 16d0d6bf..e1e7c752 100644 --- a/cmd/gotk/utils.go +++ b/cmd/gotk/utils.go @@ -24,6 +24,7 @@ import ( "io" "os" "os/exec" + "strings" "text/template" corev1 "k8s.io/api/core/v1" @@ -34,6 +35,7 @@ import ( helmv2 "github.com/fluxcd/helm-controller/api/v2alpha1" kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1alpha1" + "github.com/fluxcd/pkg/runtime/dependency" sourcev1 "github.com/fluxcd/source-controller/api/v1alpha1" ) @@ -177,3 +179,23 @@ func (*Utils) containsItemString(s []string, e string) bool { } return false } + +func (*Utils) makeDependsOn(deps []string) []dependency.CrossNamespaceDependencyReference { + refs := []dependency.CrossNamespaceDependencyReference{} + for _, dep := range deps { + parts := strings.Split(dep, "/") + depNamespace := "" + depName := "" + if len(parts) > 1 { + depNamespace = parts[0] + depName = parts[1] + } else { + depName = parts[0] + } + refs = append(refs, dependency.CrossNamespaceDependencyReference{ + Namespace: depNamespace, + Name: depName, + }) + } + return refs +} diff --git a/docs/cmd/gotk_create_helmrelease.md b/docs/cmd/gotk_create_helmrelease.md index e1d254f4..09e9803a 100644 --- a/docs/cmd/gotk_create_helmrelease.md +++ b/docs/cmd/gotk_create_helmrelease.md @@ -58,7 +58,7 @@ gotk create helmrelease [name] [flags] ``` --chart string Helm chart name or path --chart-version string Helm chart version, accepts a semver range (ignored for charts from GitRepository sources) - --depends-on stringArray HelmReleases that must be ready before this release can be installed + --depends-on stringArray HelmReleases that must be ready before this release can be installed, supported formats '' and '/' -h, --help help for helmrelease --release-name string name used for the Helm release, defaults to a composition of '[-]' --source string source that contains the chart (/) diff --git a/docs/cmd/gotk_create_kustomization.md b/docs/cmd/gotk_create_kustomization.md index 3f0ad7ca..436cc329 100644 --- a/docs/cmd/gotk_create_kustomization.md +++ b/docs/cmd/gotk_create_kustomization.md @@ -50,7 +50,7 @@ gotk create kustomization [name] [flags] ``` --decryption-provider string enables secrets decryption, provider can be 'sops' --decryption-secret string set the Kubernetes secret name that contains the OpenPGP private keys used for sops decryption - --depends-on stringArray Kustomization that must be ready before this Kustomization can be applied + --depends-on stringArray Kustomization that must be ready before this Kustomization can be applied, supported formats '' and '/' --health-check stringArray workload to be included in the health assessment, in the format '/.' --health-check-timeout duration timeout of health checking operations (default 2m0s) -h, --help help for kustomization