From 77aa81a064ace77f533dbb1c971a3bb388797988 Mon Sep 17 00:00:00 2001 From: Stefan Prodan Date: Tue, 19 Oct 2021 16:18:09 +0300 Subject: [PATCH] Add wait flag to create kustomization cmd Signed-off-by: Stefan Prodan --- cmd/flux/create_kustomization.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cmd/flux/create_kustomization.go b/cmd/flux/create_kustomization.go index fbcfce23..eb898e7b 100644 --- a/cmd/flux/create_kustomization.go +++ b/cmd/flux/create_kustomization.go @@ -89,6 +89,7 @@ type kustomizationFlags struct { decryptionProvider flags.DecryptionProvider decryptionSecret string targetNamespace string + wait bool } var kustomizationArgs = NewKustomizationFlags() @@ -97,6 +98,7 @@ func init() { createKsCmd.Flags().Var(&kustomizationArgs.source, "source", kustomizationArgs.source.Description()) createKsCmd.Flags().Var(&kustomizationArgs.path, "path", "path to the directory containing a kustomization.yaml file") createKsCmd.Flags().BoolVar(&kustomizationArgs.prune, "prune", false, "enable garbage collection") + createKsCmd.Flags().BoolVar(&kustomizationArgs.wait, "wait", false, "enable health checking of all the applied resources") createKsCmd.Flags().StringSliceVar(&kustomizationArgs.healthCheck, "health-check", nil, "workload to be included in the health assessment, in the format '/.'") createKsCmd.Flags().DurationVar(&kustomizationArgs.healthTimeout, "health-check-timeout", 2*time.Minute, "timeout of health checking operations") createKsCmd.Flags().StringVar(&kustomizationArgs.validation, "validation", "", "validate the manifests before applying them on the cluster, can be 'client' or 'server'") @@ -161,7 +163,7 @@ func createKsCmdRun(cmd *cobra.Command, args []string) error { }, } - if len(kustomizationArgs.healthCheck) > 0 { + if len(kustomizationArgs.healthCheck) > 0 && !kustomizationArgs.wait { healthChecks := make([]meta.NamespacedObjectKindReference, 0) for _, w := range kustomizationArgs.healthCheck { kindObj := strings.Split(w, "/") @@ -202,6 +204,13 @@ func createKsCmdRun(cmd *cobra.Command, args []string) error { } } + if kustomizationArgs.wait { + kustomization.Spec.Wait = true + kustomization.Spec.Timeout = &metav1.Duration{ + Duration: kustomizationArgs.healthTimeout, + } + } + if kustomizationArgs.saName != "" { kustomization.Spec.ServiceAccountName = kustomizationArgs.saName }