Skip to content

Commit cffb62e

Browse files
authored
fix handling of labels/annotations in utils.GetPodTemplateSpec (#312)
1 parent 4ad6344 commit cffb62e

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

pkg/utils/utils.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,21 @@ func GetPodTemplateSpec(obj *unstructured.Unstructured, path string) (*v1.PodTem
6969
// Metadata
7070
dst := &v1.PodTemplateSpec{}
7171
if metadata, ok := candidatePTS["metadata"].(map[string]interface{}); ok {
72-
if labels, ok := metadata["labels"].(map[string]string); ok {
73-
dst.Labels = labels
72+
if labels, ok := metadata["labels"].(map[string]interface{}); ok {
73+
dst.Labels = make(map[string]string)
74+
for k, v := range labels {
75+
if str, ok := v.(string); ok {
76+
dst.Labels[k] = str
77+
}
78+
}
7479
}
75-
if annotations, ok := metadata["annotations"].(map[string]string); ok {
76-
dst.Annotations = annotations
80+
if annotations, ok := metadata["annotations"].(map[string]interface{}); ok {
81+
dst.Annotations = make(map[string]string)
82+
for k, v := range annotations {
83+
if str, ok := v.(string); ok {
84+
dst.Annotations[k] = str
85+
}
86+
}
7787
}
7888
}
7989

0 commit comments

Comments
 (0)