Skip to content

Commit ca1f091

Browse files
committed
Rename EnsureOwnerReference to SetOwnerReference for consistency
Signed-off-by: Vince Prignano <[email protected]>
1 parent d0de78d commit ca1f091

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

pkg/controller/controllerutil/controllerutil.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ func SetControllerReference(owner, controlled metav1.Object, scheme *runtime.Sch
8989
return nil
9090
}
9191

92-
// EnsureOwnerReference is a helper method to make sure the given object contains
93-
// an object reference to the object provided.
94-
// If a reference already exists, it'll be overwritten with the newly provided version.
95-
func EnsureOwnerReference(owner, object metav1.Object, scheme *runtime.Scheme) error {
92+
// SetOwnerReference is a helper method to make sure the given object contains an object reference to the object provided.
93+
// This allows you to declare that owner has a dependency on the object without specifying it as a controller.
94+
// If a reference to the same object already exists, it'll be overwritten with the newly provided version.
95+
func SetOwnerReference(owner, object metav1.Object, scheme *runtime.Scheme) error {
9696
// Validate the owner.
9797
ro, ok := owner.(runtime.Object)
9898
if !ok {

pkg/controller/controllerutil/controllerutil_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ import (
3535
)
3636

3737
var _ = Describe("Controllerutil", func() {
38-
Describe("EnsureOwnerReference", func() {
38+
Describe("SetOwnerReference", func() {
3939
It("should set ownerRef on an empty list", func() {
4040
rs := &appsv1.ReplicaSet{}
4141
dep := &extensionsv1beta1.Deployment{
4242
ObjectMeta: metav1.ObjectMeta{Name: "foo", UID: "foo-uid"},
4343
}
44-
Expect(controllerutil.EnsureOwnerReference(dep, rs, scheme.Scheme)).ToNot(HaveOccurred())
44+
Expect(controllerutil.SetOwnerReference(dep, rs, scheme.Scheme)).ToNot(HaveOccurred())
4545
Expect(rs.OwnerReferences).To(ConsistOf(metav1.OwnerReference{
4646
Name: "foo",
4747
Kind: "Deployment",
@@ -67,7 +67,7 @@ var _ = Describe("Controllerutil", func() {
6767
ObjectMeta: metav1.ObjectMeta{Name: "foo", UID: "foo-uid"},
6868
}
6969

70-
Expect(controllerutil.EnsureOwnerReference(dep, rs, scheme.Scheme)).ToNot(HaveOccurred())
70+
Expect(controllerutil.SetOwnerReference(dep, rs, scheme.Scheme)).ToNot(HaveOccurred())
7171
Expect(rs.OwnerReferences).To(ConsistOf(metav1.OwnerReference{
7272
Name: "foo",
7373
Kind: "Deployment",
@@ -93,7 +93,7 @@ var _ = Describe("Controllerutil", func() {
9393
ObjectMeta: metav1.ObjectMeta{Name: "foo", UID: "foo-uid-2"},
9494
}
9595

96-
Expect(controllerutil.EnsureOwnerReference(dep, rs, scheme.Scheme)).ToNot(HaveOccurred())
96+
Expect(controllerutil.SetOwnerReference(dep, rs, scheme.Scheme)).ToNot(HaveOccurred())
9797
Expect(rs.OwnerReferences).To(ConsistOf(metav1.OwnerReference{
9898
Name: "foo",
9999
Kind: "Deployment",

0 commit comments

Comments
 (0)