Skip to content

Commit

Permalink
fix: allow long annotations (#421)
Browse files Browse the repository at this point in the history
* fix: allow long annotations

* Update internal/test/metadata.go

Co-authored-by: Mark Vainomaa <mikroskeem@gmail.com>

---------

Co-authored-by: Mark Vainomaa <mikroskeem@gmail.com>
  • Loading branch information
scirner22 and mikroskeem authored Oct 11, 2024
1 parent 04aafbf commit 20b4d27
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/kube/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion internal/kube/labels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)},
},
}
Expand All @@ -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"])
}
3 changes: 1 addition & 2 deletions internal/test/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit 20b4d27

Please sign in to comment.