Merge pull request #260 from fluxcd/dependson-ns

Add support for namespace/name format in depends-on
pull/262/head
Stefan Prodan 4 years ago committed by GitHub
commit 85d03a9946
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -98,7 +98,7 @@ func init() {
createHelmReleaseCmd.Flags().StringVar(&hrSource, "source", "", "source that contains the chart (<kind>/<name>)")
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 '<name>' and '<namespace>/<name>'")
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,
},

@ -94,7 +94,7 @@ func init() {
createKsCmd.Flags().StringArrayVar(&ksHealthCheck, "health-check", nil, "workload to be included in the health assessment, in the format '<kind>/<name>.<namespace>'")
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 '<name>' and '<namespace>/<name>'")
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,
},

@ -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
}

@ -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 '<name>' and '<namespace>/<name>'
-h, --help help for helmrelease
--release-name string name used for the Helm release, defaults to a composition of '[<target-namespace>-]<hr-name>'
--source string source that contains the chart (<kind>/<name>)

@ -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 '<name>' and '<namespace>/<name>'
--health-check stringArray workload to be included in the health assessment, in the format '<kind>/<name>.<namespace>'
--health-check-timeout duration timeout of health checking operations (default 2m0s)
-h, --help help for kustomization

@ -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

@ -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=

@ -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

@ -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

@ -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

@ -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

Loading…
Cancel
Save