From c944f41c2007db8117a1dde57dc2a966f11ce8e0 Mon Sep 17 00:00:00 2001 From: David Grove Date: Fri, 7 Feb 2025 14:08:44 -0500 Subject: [PATCH] fix handling of labels/annotations in utils.GetPodTemplateSpec --- pkg/utils/utils.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 62ba6cc..be1892d 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -69,11 +69,21 @@ func GetPodTemplateSpec(obj *unstructured.Unstructured, path string) (*v1.PodTem // Metadata dst := &v1.PodTemplateSpec{} if metadata, ok := candidatePTS["metadata"].(map[string]interface{}); ok { - if labels, ok := metadata["labels"].(map[string]string); ok { - dst.Labels = labels + if labels, ok := metadata["labels"].(map[string]interface{}); ok { + dst.Labels = make(map[string]string) + for k, v := range labels { + if str, ok := v.(string); ok { + dst.Labels[k] = str + } + } } - if annotations, ok := metadata["annotations"].(map[string]string); ok { - dst.Annotations = annotations + if annotations, ok := metadata["annotations"].(map[string]interface{}); ok { + dst.Annotations = make(map[string]string) + for k, v := range annotations { + if str, ok := v.(string); ok { + dst.Annotations[k] = str + } + } } }