From 9bb00775e559864849e2055516cee82a43330341 Mon Sep 17 00:00:00 2001 From: Jordan Olshevski Date: Tue, 2 Jan 2024 23:00:25 +0000 Subject: [PATCH] Handle errors --- internal/controllers/reconciliation/discoverycache.go | 5 ++++- internal/controllers/reconciliation/kubectl.go | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/internal/controllers/reconciliation/discoverycache.go b/internal/controllers/reconciliation/discoverycache.go index 67672494..02c93784 100644 --- a/internal/controllers/reconciliation/discoverycache.go +++ b/internal/controllers/reconciliation/discoverycache.go @@ -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 } diff --git a/internal/controllers/reconciliation/kubectl.go b/internal/controllers/reconciliation/kubectl.go index 1ecc67e2..b82551c4 100644 --- a/internal/controllers/reconciliation/kubectl.go +++ b/internal/controllers/reconciliation/kubectl.go @@ -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{}{} @@ -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 {