|
5 | 5 | "encoding/json" |
6 | 6 | "fmt" |
7 | 7 | "maps" |
| 8 | + "strings" |
8 | 9 |
|
9 | 10 | . "github.com/onsi/ginkgo/v2" |
10 | 11 | . "github.com/onsi/gomega" |
@@ -95,6 +96,28 @@ var _ = Describe("chunkedSecrets", func() { |
95 | 96 | _, err := maxReadDriver.Get(releaseKey(rel)) |
96 | 97 | Expect(err).To(MatchError(ContainSubstring("release too large"))) |
97 | 98 | }) |
| 99 | + It("should handle release labels that are invalid metadata labels", func() { |
| 100 | + invalidMetadataLabelKey := "stored-as-annotation" |
| 101 | + invalidMetadataLabelValue := strings.Repeat("a", 64) |
| 102 | + |
| 103 | + expected := genRelease("test-release", 1, release.StatusPendingInstall, map[string]string{invalidMetadataLabelKey: invalidMetadataLabelValue}, chunkSize/2) |
| 104 | + Expect(expected.Labels).To(HaveKey(invalidMetadataLabelKey)) |
| 105 | + Expect(chunkedDriver.Create(releaseKey(expected), expected)).To(Succeed()) |
| 106 | + |
| 107 | + // Make sure the release-only label is in the release metadata |
| 108 | + actual, err := chunkedDriver.Get(releaseKey(expected)) |
| 109 | + Expect(err).ToNot(HaveOccurred()) |
| 110 | + Expect(actual).To(Equal(expected)) |
| 111 | + Expect(actual.Labels).To(HaveKey(invalidMetadataLabelKey)) |
| 112 | + Expect(actual.Labels[invalidMetadataLabelKey]).To(Equal(invalidMetadataLabelValue)) |
| 113 | + |
| 114 | + // Make sure the invalid label is stored in the secret annotations, not labels |
| 115 | + items, err := secretInterface.List(context.Background(), metav1.ListOptions{}) |
| 116 | + Expect(err).ToNot(HaveOccurred()) |
| 117 | + Expect(items.Items).To(HaveLen(1)) |
| 118 | + Expect(items.Items[0].Labels).ToNot(HaveKey(invalidMetadataLabelKey)) |
| 119 | + Expect(items.Items[0].Annotations).To(HaveKey(invalidMetadataLabelKey)) |
| 120 | + }) |
98 | 121 | }) |
99 | 122 |
|
100 | 123 | var _ = Describe("Update", func() { |
|
0 commit comments