Skip to content
Snippets Groups Projects
Unverified Commit 77aa81a0 authored by Stefan Prodan's avatar Stefan Prodan
Browse files

Add wait flag to create kustomization cmd

parent a4a1db09
No related branches found
No related tags found
No related merge requests found
...@@ -89,6 +89,7 @@ type kustomizationFlags struct { ...@@ -89,6 +89,7 @@ type kustomizationFlags struct {
decryptionProvider flags.DecryptionProvider decryptionProvider flags.DecryptionProvider
decryptionSecret string decryptionSecret string
targetNamespace string targetNamespace string
wait bool
} }
var kustomizationArgs = NewKustomizationFlags() var kustomizationArgs = NewKustomizationFlags()
...@@ -97,6 +98,7 @@ func init() { ...@@ -97,6 +98,7 @@ func init() {
createKsCmd.Flags().Var(&kustomizationArgs.source, "source", kustomizationArgs.source.Description()) 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().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.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 '<kind>/<name>.<namespace>'") createKsCmd.Flags().StringSliceVar(&kustomizationArgs.healthCheck, "health-check", nil, "workload to be included in the health assessment, in the format '<kind>/<name>.<namespace>'")
createKsCmd.Flags().DurationVar(&kustomizationArgs.healthTimeout, "health-check-timeout", 2*time.Minute, "timeout of health checking operations") 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'") 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 { ...@@ -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) healthChecks := make([]meta.NamespacedObjectKindReference, 0)
for _, w := range kustomizationArgs.healthCheck { for _, w := range kustomizationArgs.healthCheck {
kindObj := strings.Split(w, "/") kindObj := strings.Split(w, "/")
...@@ -202,6 +204,13 @@ func createKsCmdRun(cmd *cobra.Command, args []string) error { ...@@ -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 != "" { if kustomizationArgs.saName != "" {
kustomization.Spec.ServiceAccountName = kustomizationArgs.saName kustomization.Spec.ServiceAccountName = kustomizationArgs.saName
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment