Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: wait for delete and wait for objects option #103

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion kubernetes/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ func WatcherForConfig(cfg *rest.Config) (watcher.StatusWatcher, error) {

// WaitForReady waits for all of the resources to reach a ready state.
func WaitForReady(ctx context.Context, sw watcher.StatusWatcher, objs []object.ObjMetadata) error {
return waitForStatus(ctx, sw, objs, status.CurrentStatus)
}

// WaitForDeleted waits for all of the resources to to be deleted.
func WaitForDeleted(ctx context.Context, sw watcher.StatusWatcher, objs []object.ObjMetadata) error {
return waitForStatus(ctx, sw, objs, status.NotFoundStatus)
}

func waitForStatus(ctx context.Context, sw watcher.StatusWatcher, objs []object.ObjMetadata, desired status.Status) error {
cancelCtx, cancel := context.WithCancel(ctx)
defer cancel()

Expand All @@ -53,7 +62,6 @@ func WaitForReady(ctx context.Context, sw watcher.StatusWatcher, objs []object.O
}
rss = append(rss, rs)
}
desired := status.CurrentStatus
if aggregator.AggregateStatus(rss, desired) == desired {
cancel()
return
Expand Down
Loading