MCPcopy
hub / github.com/zarf-dev/zarf / ForResourceDefaultReady

Function ForResourceDefaultReady

src/pkg/wait/wait.go:92–109  ·  view source on GitHub ↗

ForResourceDefaultReady waits for any resource If identifier is empty, it will wait for the given kind If condition is empty, it will wait for the given identifier to be fully reconciled using healthchecks. This functions requires that a cluster is available before it is called

(ctx context.Context, kind, identifier, condition, namespace string, timeout time.Duration)

Source from the content-addressed store, hash-verified

90// If condition is empty, it will wait for the given identifier to be fully reconciled using healthchecks.
91// This functions requires that a cluster is available before it is called
92func ForResourceDefaultReady(ctx context.Context, kind, identifier, condition, namespace string, timeout time.Duration) error {
93 if kind == "" {
94 return errors.New("kind is required")
95 }
96
97 deadline := time.Now().Add(timeout)
98
99 condition = strings.ReplaceAll(condition, "'", "")
100
101 loader := clientcmd.NewDefaultClientConfigLoadingRules()
102 clientCfg := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loader, nil)
103 _, restConfig, err := cluster.ClientAndConfig()
104 if err != nil {
105 return err
106 }
107
108 return waitFor(ctx, restConfig, clientCfg, kind, namespace, identifier, condition, deadline)
109}
110
111func waitFor(ctx context.Context, restConfig *rest.Config, clientCfg clientcmd.ClientConfig, kind string, namespace string, identifier string, condition string, deadline time.Time) error {
112 l := logger.From(ctx)

Callers 1

runMethod · 0.92

Calls 3

ClientAndConfigFunction · 0.92
waitForFunction · 0.85
AddMethod · 0.80

Tested by

no test coverage detected