Skip to content

Commit

Permalink
feat: add wait for ready runtime (#105)
Browse files Browse the repository at this point in the history
## Description

Adds an alternative wait function to remove the need to create object
meta slices and instead pass runtime objects.

## Related Issue

N/A
  • Loading branch information
phillebaba authored Jun 20, 2024
1 parent 0899029 commit 0872f19
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion kubernetes/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package kubernetes
import (
"context"

"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/discovery"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/rest"
Expand Down Expand Up @@ -37,7 +38,20 @@ func WatcherForConfig(cfg *rest.Config) (watcher.StatusWatcher, error) {
return sw, nil
}

// WaitForReady waits for all of the resources to reach a ready state.
// WaitForReadyRuntime waits for all of the runtime objects to reach a ready state.
func WaitForReadyRuntime(ctx context.Context, sw watcher.StatusWatcher, robjs []runtime.Object) error {
objs := []object.ObjMetadata{}
for _, robj := range robjs {
obj, err := object.RuntimeToObjMeta(robj)
if err != nil {
return err
}
objs = append(objs, obj)
}
return WaitForReady(ctx, sw, objs)
}

// WaitForReady waits for all of the objects to reach a ready state.
func WaitForReady(ctx context.Context, sw watcher.StatusWatcher, objs []object.ObjMetadata) error {
cancelCtx, cancel := context.WithCancel(ctx)
defer cancel()
Expand Down

0 comments on commit 0872f19

Please sign in to comment.