Update pkg/cmd/flags.go

Co-authored-by: George Jenkins <gvjenkins@gmail.com>
Signed-off-by: Benoit Tigeot <benoittgt@users.noreply.github.com>
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
pull/31421/head
Benoit Tigeot 11 months ago committed by Benoit Tigeot
parent 277c140c87
commit 02312a1cf2
No known key found for this signature in database
GPG Key ID: 8E6D4FC8AEBDA62C

@ -59,7 +59,7 @@ func AddWaitFlag(cmd *cobra.Command, wait *kube.WaitStrategy) {
cmd.Flags().Var( cmd.Flags().Var(
newWaitValue(kube.HookOnlyStrategy, wait), newWaitValue(kube.HookOnlyStrategy, wait),
"wait", "wait",
"wait until resources are ready (up to --timeout). Values: 'watcher', 'hookOnly' (default), and 'legacy'", "if specified, wait until resources are ready (up to --timeout). Values: 'watcher' (default), 'hookOnly', and 'legacy'.",
) )
// Sets the strategy to use the watcher strategy if `--wait` is used without an argument // Sets the strategy to use the watcher strategy if `--wait` is used without an argument
cmd.Flags().Lookup("wait").NoOptDefVal = string(kube.StatusWatcherStrategy) cmd.Flags().Lookup("wait").NoOptDefVal = string(kube.StatusWatcherStrategy)

@ -65,7 +65,7 @@ func (w *statusWaiter) WatchUntilReady(resourceList ResourceList, timeout time.D
if timeout == 0 { if timeout == 0 {
timeout = DefaultStatusWatcherTimeout timeout = DefaultStatusWatcherTimeout
} }
ctx, cancel := context.WithTimeout(context.Background(), timeout) ctx, cancel := w.contextWithTimeout(timeout)
defer cancel() defer cancel()
slog.Debug("waiting for resources", "count", len(resourceList), "timeout", timeout) slog.Debug("waiting for resources", "count", len(resourceList), "timeout", timeout)
sw := watcher.NewDefaultStatusWatcher(w.client, w.restMapper) sw := watcher.NewDefaultStatusWatcher(w.client, w.restMapper)
@ -86,16 +86,10 @@ func (w *statusWaiter) WatchUntilReady(resourceList ResourceList, timeout time.D
} }
func (w *statusWaiter) Wait(resourceList ResourceList, timeout time.Duration) error { func (w *statusWaiter) Wait(resourceList ResourceList, timeout time.Duration) error {
<<<<<<< HEAD
ctx, cancel := w.contextWithTimeout(timeout)
||||||| parent of 86f98f870 (Prevent surprising failure with SDK when timeout is not set)
ctx, cancel := context.WithTimeout(context.TODO(), timeout)
=======
if timeout == 0 { if timeout == 0 {
timeout = DefaultStatusWatcherTimeout timeout = DefaultStatusWatcherTimeout
} }
ctx, cancel := context.WithTimeout(context.TODO(), timeout) ctx, cancel := w.contextWithTimeout(timeout)
>>>>>>> 86f98f870 (Prevent surprising failure with SDK when timeout is not set)
defer cancel() defer cancel()
slog.Debug("waiting for resources", "count", len(resourceList), "timeout", timeout) slog.Debug("waiting for resources", "count", len(resourceList), "timeout", timeout)
sw := watcher.NewDefaultStatusWatcher(w.client, w.restMapper) sw := watcher.NewDefaultStatusWatcher(w.client, w.restMapper)
@ -103,16 +97,10 @@ func (w *statusWaiter) Wait(resourceList ResourceList, timeout time.Duration) er
} }
func (w *statusWaiter) WaitWithJobs(resourceList ResourceList, timeout time.Duration) error { func (w *statusWaiter) WaitWithJobs(resourceList ResourceList, timeout time.Duration) error {
<<<<<<< HEAD
ctx, cancel := w.contextWithTimeout(timeout)
||||||| parent of 86f98f870 (Prevent surprising failure with SDK when timeout is not set)
ctx, cancel := context.WithTimeout(context.TODO(), timeout)
=======
if timeout == 0 { if timeout == 0 {
timeout = DefaultStatusWatcherTimeout timeout = DefaultStatusWatcherTimeout
} }
ctx, cancel := context.WithTimeout(context.TODO(), timeout) ctx, cancel := w.contextWithTimeout(timeout)
>>>>>>> 86f98f870 (Prevent surprising failure with SDK when timeout is not set)
defer cancel() defer cancel()
slog.Debug("waiting for resources", "count", len(resourceList), "timeout", timeout) slog.Debug("waiting for resources", "count", len(resourceList), "timeout", timeout)
sw := watcher.NewDefaultStatusWatcher(w.client, w.restMapper) sw := watcher.NewDefaultStatusWatcher(w.client, w.restMapper)
@ -123,16 +111,10 @@ func (w *statusWaiter) WaitWithJobs(resourceList ResourceList, timeout time.Dura
} }
func (w *statusWaiter) WaitForDelete(resourceList ResourceList, timeout time.Duration) error { func (w *statusWaiter) WaitForDelete(resourceList ResourceList, timeout time.Duration) error {
<<<<<<< HEAD
ctx, cancel := w.contextWithTimeout(timeout)
||||||| parent of 86f98f870 (Prevent surprising failure with SDK when timeout is not set)
ctx, cancel := context.WithTimeout(context.TODO(), timeout)
=======
if timeout == 0 { if timeout == 0 {
timeout = DefaultStatusWatcherTimeout timeout = DefaultStatusWatcherTimeout
} }
ctx, cancel := context.WithTimeout(context.TODO(), timeout) ctx, cancel := w.contextWithTimeout(timeout)
>>>>>>> 86f98f870 (Prevent surprising failure with SDK when timeout is not set)
defer cancel() defer cancel()
slog.Debug("waiting for resources to be deleted", "count", len(resourceList), "timeout", timeout) slog.Debug("waiting for resources to be deleted", "count", len(resourceList), "timeout", timeout)
sw := watcher.NewDefaultStatusWatcher(w.client, w.restMapper) sw := watcher.NewDefaultStatusWatcher(w.client, w.restMapper)

Loading…
Cancel
Save