Skip to content

Commit a786206

Browse files
authored
fix: remove prepending and appending runes to the condition type and reason (#177)
* fix: remove the preprending and appendig to condition type and reason * feat: release v0.23.4 * format
1 parent 24025ac commit a786206

File tree

4 files changed

+8
-22
lines changed

4 files changed

+8
-22
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.23.3-dev
1+
v0.23.4

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require (
1111
github.com/google/uuid v1.6.0
1212
github.com/onsi/ginkgo/v2 v2.27.2
1313
github.com/onsi/gomega v1.38.2
14-
github.com/openmcp-project/controller-utils/api v0.23.3
14+
github.com/openmcp-project/controller-utils/api v0.23.4
1515
github.com/spf13/pflag v1.0.10
1616
github.com/stretchr/testify v1.11.1
1717
go.uber.org/zap v1.27.0

pkg/conditions/updater.go

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,8 @@ func ReplaceIllegalCharsInConditionType(s string) string {
290290
result = append(result, '_')
291291
}
292292
}
293-
return ensureStartsAndEndsWithLetter(string(result), 'T', 't')
293+
294+
return string(result)
294295
}
295296

296297
// ReplaceIllegalCharsInConditionReason replaces all characters in the given string that are not allowed in condition reasons with underscores.
@@ -320,21 +321,6 @@ func ReplaceIllegalCharsInConditionReason(s string) string {
320321
result = append(result, '_')
321322
}
322323
}
323-
return ensureStartsAndEndsWithLetter(string(result), 'R', 'r')
324-
}
325324

326-
func ensureStartsAndEndsWithLetter(s string, start, end rune) string {
327-
if s == "" {
328-
return s
329-
}
330-
runes := []rune(s)
331-
// Ensure starts with letter
332-
if (runes[0] < 'a' || runes[0] > 'z') && (runes[0] < 'A' || runes[0] > 'Z') {
333-
runes = append([]rune{start}, runes...)
334-
}
335-
// Ensure ends with letter
336-
if (runes[len(runes)-1] < 'a' || runes[len(runes)-1] > 'z') && (runes[len(runes)-1] < 'A' || runes[len(runes)-1] > 'Z') {
337-
runes = append(runes, end)
338-
}
339-
return string(runes)
325+
return string(result)
340326
}

pkg/controller/status_updater_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ var _ = Describe("Status Updater", func() {
128128
}
129129
condFunc := controller.GenerateCreateConditionFunc(rr)
130130

131-
condFunc("0CondType :,;-_.Test02@", metav1.ConditionTrue, "1Reason -.,:_Test93$", "Message")
131+
condFunc("CondType :,;-_.Test02@", metav1.ConditionTrue, "Reason -.,:_Test93$", "Message")
132132
Expect(rr.Conditions).To(HaveLen(1))
133-
Expect(rr.Conditions[0].Type).To(Equal("T0CondType____-_.Test02_t"))
134-
Expect(rr.Conditions[0].Reason).To(Equal("R1Reason___,:_Test93_r"))
133+
Expect(rr.Conditions[0].Type).To(Equal("CondType____-_.Test02_"))
134+
Expect(rr.Conditions[0].Reason).To(Equal("Reason___,:_Test93_"))
135135
})
136136

137137
It("should not update disabled fields", func() {

0 commit comments

Comments
 (0)