Skip to content

Commit

Permalink
fix: correctly handle new watch event types
Browse files Browse the repository at this point in the history
This is a fix after upgrade to COSI v0.2.0.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
  • Loading branch information
smira committed Dec 1, 2022
1 parent 881b841 commit 4cd125d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions internal/app/machined/pkg/runtime/v1alpha1/platform/metal/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ func PopulateURLParameters(ctx context.Context, downloadURL string, r state.Stat
return u.String(), nil
}

//nolint:gocyclo
func getResource[T resource.Resource](ctx context.Context, r state.State, namespace, typ, valName string, isReadyFunc func(T) bool, checkAndGetFunc func(T) string) (string, error) {
metadata := resource.NewMetadata(namespace, typ, "", resource.VersionUndefined)

Expand All @@ -122,6 +123,15 @@ func getResource[T resource.Resource](ctx context.Context, r state.State, namesp

return "", err
case event := <-events:
switch event.Type() {
case state.Created, state.Updated:
// ok, proceed
case state.Destroyed, state.Bootstrapped:
// ignore
case state.Errored:
return "", event.Error()
}

eventResource, err := event.Resource()
if err != nil {
watchErr = fmt.Errorf("%s; invalid resource in wrapped event: %w", watchErr.Error(), err)
Expand Down

0 comments on commit 4cd125d

Please sign in to comment.