Skip to content

Commit

Permalink
Handle errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Olshevski committed Jan 2, 2024
1 parent e565bee commit 9bb0077
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion internal/controllers/reconciliation/discoverycache.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ func (d *discoveryCache) fillUnlocked(ctx context.Context) error {
if err != nil {
return err
}
d.current = buildCurrentSchemaMap(doc)
d.current, err = buildCurrentSchemaMap(doc)
if err != nil {
return err
}
return nil
}
6 changes: 3 additions & 3 deletions internal/controllers/reconciliation/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (
"k8s.io/kube-openapi/pkg/util/proto"
)

func buildCurrentSchemaMap(doc *openapi_v2.Document) map[schema.GroupVersionKind]proto.Schema {
func buildCurrentSchemaMap(doc *openapi_v2.Document) (map[schema.GroupVersionKind]proto.Schema, error) {
models, err := proto.NewOpenAPIData(doc)
if err != nil {
panic(err) // TODO:?
return nil, err
}

allSupported := map[schema.GroupVersionKind]struct{}{}
Expand Down Expand Up @@ -60,7 +60,7 @@ func buildCurrentSchemaMap(doc *openapi_v2.Document) map[schema.GroupVersionKind
}
}

return m
return m, nil
}

func parseGroupVersionKind(s proto.Schema) []schema.GroupVersionKind {
Expand Down

0 comments on commit 9bb0077

Please sign in to comment.