Add support for namespace/name format in depends-on
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user