Skip to content

Commit 7176ea4

Browse files
committed
nit: private functions
1 parent 7513043 commit 7176ea4

File tree

2 files changed

+6
-24
lines changed

2 files changed

+6
-24
lines changed

pkg/controller/controllerutil/controllerutil.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ type MutateFn func() error
172172

173173
// AddFinalizer accepts a metav1 object and adds the provided finalizer if not present.
174174
func AddFinalizer(o metav1.Object, finalizer string) {
175-
newFinalizers := AddString(o.GetFinalizers(), finalizer)
175+
newFinalizers := addString(o.GetFinalizers(), finalizer)
176176
o.SetFinalizers(newFinalizers)
177177
}
178178

@@ -189,7 +189,7 @@ func AddFinalizerIfPossible(o runtime.Object, finalizer string) error {
189189

190190
// RemoveFinalizer accepts a metav1 object and removes the provided finalizer if present.
191191
func RemoveFinalizer(o metav1.Object, finalizer string) {
192-
newFinalizers := RemoveString(o.GetFinalizers(), finalizer)
192+
newFinalizers := removeString(o.GetFinalizers(), finalizer)
193193
o.SetFinalizers(newFinalizers)
194194
}
195195

@@ -204,8 +204,8 @@ func RemoveFinalizerIfPossible(o runtime.Object, finalizer string) error {
204204
return nil
205205
}
206206

207-
// AddString returns a []string with s appended if it is not already found in the provided slice.
208-
func AddString(slice []string, s string) []string {
207+
// addString returns a []string with s appended if it is not already found in the provided slice.
208+
func addString(slice []string, s string) []string {
209209
for _, item := range slice {
210210
if item == s {
211211
return slice
@@ -214,8 +214,8 @@ func AddString(slice []string, s string) []string {
214214
return append(slice, s)
215215
}
216216

217-
// RemoveString returns a newly created []string that contains all items from slice that are not equal to s.
218-
func RemoveString(slice []string, s string) []string {
217+
// removeString returns a newly created []string that contains all items from slice that are not equal to s.
218+
func removeString(slice []string, s string) []string {
219219
new := make([]string, 0)
220220
for _, item := range slice {
221221
if item == s {

pkg/controller/controllerutil/controllerutil_test.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -306,24 +306,6 @@ var _ = Describe("Controllerutil", func() {
306306
Expect(deploy.ObjectMeta.GetFinalizers()).To(Equal([]string{}))
307307
})
308308
})
309-
310-
Describe("String Helpers", func() {
311-
testString := "foobar"
312-
It("should add the string when not present", func() {
313-
testStrings := controllerutil.AddString(nil, testString)
314-
Expect(testStrings).To(Equal([]string{testString}))
315-
})
316-
317-
It("should not add the string when already present", func() {
318-
testStrings := controllerutil.AddString([]string{testString}, testString)
319-
Expect(testStrings).To(Equal([]string{testString}))
320-
})
321-
322-
It("should remove string if present", func() {
323-
testStrings := controllerutil.RemoveString([]string{testString}, testString)
324-
Expect(testStrings).To(Equal([]string{}))
325-
})
326-
})
327309
})
328310
})
329311

0 commit comments

Comments
 (0)