diff --git a/internal/kube/labels.go b/internal/kube/labels.go index 30b419b4..006d540f 100644 --- a/internal/kube/labels.go +++ b/internal/kube/labels.go @@ -59,7 +59,7 @@ func NormalizeMetadata(obj *metav1.ObjectMeta) { annots := make(map[string]string) for k, v := range obj.Annotations { - annots[ToLabelKey(k)] = trimMiddle(v, 63) + annots[ToLabelKey(k)] = v } obj.Annotations = annots diff --git a/internal/kube/labels_test.go b/internal/kube/labels_test.go index f06752b1..2b83836a 100644 --- a/internal/kube/labels_test.go +++ b/internal/kube/labels_test.go @@ -86,7 +86,7 @@ func TestNormalizeMetadata(t *testing.T) { obj := &corev1.Pod{ ObjectMeta: metav1.ObjectMeta{ Name: strings.Repeat(" name ", 500), - Annotations: map[string]string{strings.Repeat("annot-key", 500): strings.Repeat("value", 500), "cloud.google.com/neg": `{"ingress": true}`}, + Annotations: map[string]string{strings.Repeat("annot-key", 500): strings.Repeat("value", 500), "cloud.google.com/neg": `{"ingress": true}`, "long-value": strings.Repeat("value", 500)}, Labels: map[string]string{strings.Repeat("label-key", 500): strings.Repeat("value", 500)}, }, } @@ -95,4 +95,5 @@ func TestNormalizeMetadata(t *testing.T) { test.RequireValidMetadata(t, obj) require.Equal(t, `{"ingress": true}`, obj.Annotations["cloud.google.com/neg"]) + require.Equal(t, strings.Repeat("value", 500), obj.Annotations["long-value"]) } diff --git a/internal/test/metadata.go b/internal/test/metadata.go index b00750ca..6bd0157f 100644 --- a/internal/test/metadata.go +++ b/internal/test/metadata.go @@ -16,8 +16,7 @@ func RequireValidMetadata(t *testing.T, obj client.Object) { require.LessOrEqual(t, len(k), 63) require.LessOrEqual(t, len(v), 63, k) } - for k, v := range obj.GetAnnotations() { + for k := range obj.GetAnnotations() { require.LessOrEqual(t, len(k), 63) - require.LessOrEqual(t, len(v), 63, k) } }