From 81a3bf35b0eb944c2be196def7948728b62804d1 Mon Sep 17 00:00:00 2001 From: Kris Budde Date: Mon, 30 Oct 2023 08:59:18 +0100 Subject: [PATCH 1/2] fix(render): fix panic if metadata.name is not set --- internal/myks/render.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/myks/render.go b/internal/myks/render.go index 17b2f33e..05de2313 100644 --- a/internal/myks/render.go +++ b/internal/myks/render.go @@ -143,8 +143,11 @@ func genRenderedResourceFileName(resource map[string]interface{}) string { name := "NO_NAME" if n, ok := resource["metadata"]; ok { metadata := n.(map[string]interface{}) - name = metadata["name"].(string) + if n, ok := metadata["name"].(string); ok { + name = n + } } + // Worst case this returns "no_kind-no_name.yaml" which probably is not what we want. Maybe it's better to exit with an error? return fmt.Sprintf("%s-%s.yaml", strings.ToLower(kind), strings.ToLower(name)) } From bb9f9066d63d8ddeb40df5da555a04e98a4d1e8a Mon Sep 17 00:00:00 2001 From: German Lashevich Date: Mon, 30 Oct 2023 20:18:29 +0100 Subject: [PATCH 2/2] Update internal/myks/render.go --- internal/myks/render.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/myks/render.go b/internal/myks/render.go index 05de2313..66b6399d 100644 --- a/internal/myks/render.go +++ b/internal/myks/render.go @@ -147,7 +147,8 @@ func genRenderedResourceFileName(resource map[string]interface{}) string { name = n } } - // Worst case this returns "no_kind-no_name.yaml" which probably is not what we want. Maybe it's better to exit with an error? + // Worst case this returns "no_kind-no_name.yaml" which probably is not what we want. + // TODO: exit with an error instead return fmt.Sprintf("%s-%s.yaml", strings.ToLower(kind), strings.ToLower(name)) }