Skip to content

Commit

Permalink
replace depretaced pointer with ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
friedrichwilken committed Oct 20, 2023
1 parent e2ebf27 commit 8140f79
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 35 deletions.
6 changes: 3 additions & 3 deletions hack/e2e/common/testenvironment/test_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
k8stypes "k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/kyma-project/eventing-manager/hack/e2e/common"
Expand Down Expand Up @@ -264,7 +264,7 @@ func (te *TestEnvironment) CreateSinkDeployment(name, namespace, image string) e
return te.K8sClient.Patch(te.Context, fixtures.NewSinkDeployment(name, namespace, image),
client.Apply,
&client.PatchOptions{
Force: pointer.Bool(true),
Force: ptr.To(true),
FieldManager: fixtures.FieldManager,
})
})
Expand All @@ -275,7 +275,7 @@ func (te *TestEnvironment) CreateSinkService(name, namespace string) error {
return te.K8sClient.Patch(te.Context, fixtures.NewSinkService(name, namespace),
client.Apply,
&client.PatchOptions{
Force: pointer.Bool(true),
Force: ptr.To(true),
FieldManager: fixtures.FieldManager,
})
})
Expand Down
10 changes: 5 additions & 5 deletions pkg/eventing/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

"github.com/kyma-project/eventing-manager/test"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"

"sigs.k8s.io/controller-runtime/pkg/client"

Expand Down Expand Up @@ -163,8 +163,8 @@ func Test_migratePublisherDeploymentFromEC(t *testing.T) {
Kind: "Deployment",
Name: "eventing-controller",
UID: "a3cdcc7b-6853-4772-99cc-fc1511399d63",
Controller: pointer.Bool(true),
BlockOwnerDeletion: pointer.Bool(true),
Controller: ptr.To(true),
BlockOwnerDeletion: ptr.To(true),
}}
return oldPublisher
},
Expand All @@ -191,8 +191,8 @@ func Test_migratePublisherDeploymentFromEC(t *testing.T) {
Kind: "Deployment",
Name: "eventing-manager",
UID: "a3cdcc7b-6853-4772-99cc-fc1511399d63",
Controller: pointer.Bool(true),
BlockOwnerDeletion: pointer.Bool(true),
Controller: ptr.To(true),
BlockOwnerDeletion: ptr.To(true),
}}
return oldPublisher
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/k8s/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
k8sclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/client"
)

Expand Down Expand Up @@ -147,7 +147,7 @@ func (c *KubeClient) GetNATSResources(ctx context.Context, namespace string) (*n
// The object must define `GVK` (i.e. object.TypeMeta).
func (c *KubeClient) PatchApply(ctx context.Context, object client.Object) error {
return c.client.Patch(ctx, object, client.Apply, &client.PatchOptions{
Force: pointer.Bool(true),
Force: ptr.To(true),
FieldManager: c.fieldManager,
})
}
Expand Down
50 changes: 25 additions & 25 deletions pkg/object/equality_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"

apigatewayv1beta1 "github.com/kyma-incubator/api-gateway/api/v1beta1"
"github.com/kyma-project/eventing-manager/pkg/utils"
Expand Down Expand Up @@ -638,88 +638,88 @@ func Test_ownerReferencesDeepEqual(t *testing.T) {
{
name: "same OwnerReferences and same order",
givenOwnerReferences1: []metav1.OwnerReference{
ownerReference("v-0", "k-0", "n-0", "u-0", pointer.Bool(false), pointer.Bool(false)),
ownerReference("v-1", "k-1", "n-1", "u-1", pointer.Bool(false), pointer.Bool(false)),
ownerReference("v-2", "k-2", "n-2", "u-2", pointer.Bool(false), pointer.Bool(false)),
ownerReference("v-0", "k-0", "n-0", "u-0", ptr.To(false), ptr.To(false)),
ownerReference("v-1", "k-1", "n-1", "u-1", ptr.To(false), ptr.To(false)),
ownerReference("v-2", "k-2", "n-2", "u-2", ptr.To(false), ptr.To(false)),
},
givenOwnerReferences2: []metav1.OwnerReference{
ownerReference("v-0", "k-0", "n-0", "u-0", pointer.Bool(false), pointer.Bool(false)),
ownerReference("v-1", "k-1", "n-1", "u-1", pointer.Bool(false), pointer.Bool(false)),
ownerReference("v-2", "k-2", "n-2", "u-2", pointer.Bool(false), pointer.Bool(false)),
ownerReference("v-0", "k-0", "n-0", "u-0", ptr.To(false), ptr.To(false)),
ownerReference("v-1", "k-1", "n-1", "u-1", ptr.To(false), ptr.To(false)),
ownerReference("v-2", "k-2", "n-2", "u-2", ptr.To(false), ptr.To(false)),
},
wantEqual: true,
},
{
name: "same OwnerReferences but different order",
givenOwnerReferences1: []metav1.OwnerReference{
ownerReference("v-0", "k-0", "n-0", "u-0", pointer.Bool(false), pointer.Bool(false)),
ownerReference("v-1", "k-1", "n-1", "u-1", pointer.Bool(false), pointer.Bool(false)),
ownerReference("v-2", "k-2", "n-2", "u-2", pointer.Bool(false), pointer.Bool(false)),
ownerReference("v-0", "k-0", "n-0", "u-0", ptr.To(false), ptr.To(false)),
ownerReference("v-1", "k-1", "n-1", "u-1", ptr.To(false), ptr.To(false)),
ownerReference("v-2", "k-2", "n-2", "u-2", ptr.To(false), ptr.To(false)),
},
givenOwnerReferences2: []metav1.OwnerReference{
ownerReference("v-2", "k-2", "n-2", "u-2", pointer.Bool(false), pointer.Bool(false)),
ownerReference("v-0", "k-0", "n-0", "u-0", pointer.Bool(false), pointer.Bool(false)),
ownerReference("v-1", "k-1", "n-1", "u-1", pointer.Bool(false), pointer.Bool(false)),
ownerReference("v-2", "k-2", "n-2", "u-2", ptr.To(false), ptr.To(false)),
ownerReference("v-0", "k-0", "n-0", "u-0", ptr.To(false), ptr.To(false)),
ownerReference("v-1", "k-1", "n-1", "u-1", ptr.To(false), ptr.To(false)),
},
wantEqual: true,
},
{
name: "different OwnerReference APIVersion",
givenOwnerReferences1: []metav1.OwnerReference{
ownerReference("v-0", "k-0", "n-0", "u-0", pointer.Bool(false), pointer.Bool(false)),
ownerReference("v-0", "k-0", "n-0", "u-0", ptr.To(false), ptr.To(false)),
},
givenOwnerReferences2: []metav1.OwnerReference{
ownerReference("v-1", "k-0", "n-0", "u-0", pointer.Bool(false), pointer.Bool(false)),
ownerReference("v-1", "k-0", "n-0", "u-0", ptr.To(false), ptr.To(false)),
},
wantEqual: false,
},
{
name: "different OwnerReference Kind",
givenOwnerReferences1: []metav1.OwnerReference{
ownerReference("v-0", "k-0", "n-0", "u-0", pointer.Bool(false), pointer.Bool(false)),
ownerReference("v-0", "k-0", "n-0", "u-0", ptr.To(false), ptr.To(false)),
},
givenOwnerReferences2: []metav1.OwnerReference{
ownerReference("v-0", "k-1", "n-0", "u-0", pointer.Bool(false), pointer.Bool(false)),
ownerReference("v-0", "k-1", "n-0", "u-0", ptr.To(false), ptr.To(false)),
},
wantEqual: false,
},
{
name: "different OwnerReference Name",
givenOwnerReferences1: []metav1.OwnerReference{
ownerReference("v-0", "k-0", "n-0", "u-0", pointer.Bool(false), pointer.Bool(false)),
ownerReference("v-0", "k-0", "n-0", "u-0", ptr.To(false), ptr.To(false)),
},
givenOwnerReferences2: []metav1.OwnerReference{
ownerReference("v-0", "k-0", "n-1", "u-0", pointer.Bool(false), pointer.Bool(false)),
ownerReference("v-0", "k-0", "n-1", "u-0", ptr.To(false), ptr.To(false)),
},
wantEqual: false,
},
{
name: "different OwnerReference UID",
givenOwnerReferences1: []metav1.OwnerReference{
ownerReference("v-0", "k-0", "n-0", "u-0", pointer.Bool(false), pointer.Bool(false)),
ownerReference("v-0", "k-0", "n-0", "u-0", ptr.To(false), ptr.To(false)),
},
givenOwnerReferences2: []metav1.OwnerReference{
ownerReference("v-0", "k-0", "n-0", "u-1", pointer.Bool(false), pointer.Bool(false)),
ownerReference("v-0", "k-0", "n-0", "u-1", ptr.To(false), ptr.To(false)),
},
wantEqual: false,
},
{
name: "different OwnerReference Controller",
givenOwnerReferences1: []metav1.OwnerReference{
ownerReference("v-0", "k-0", "n-0", "u-0", pointer.Bool(false), pointer.Bool(false)),
ownerReference("v-0", "k-0", "n-0", "u-0", ptr.To(false), ptr.To(false)),
},
givenOwnerReferences2: []metav1.OwnerReference{
ownerReference("v-0", "k-0", "n-0", "u-0", pointer.Bool(true), pointer.Bool(false)),
ownerReference("v-0", "k-0", "n-0", "u-0", ptr.To(true), ptr.To(false)),
},
wantEqual: false,
},
{
name: "different OwnerReference BlockOwnerDeletion",
givenOwnerReferences1: []metav1.OwnerReference{
ownerReference("v-0", "k-0", "n-0", "u-0", pointer.Bool(false), pointer.Bool(false)),
ownerReference("v-0", "k-0", "n-0", "u-0", ptr.To(false), ptr.To(false)),
},
givenOwnerReferences2: []metav1.OwnerReference{
ownerReference("v-0", "k-0", "n-0", "u-0", pointer.Bool(false), pointer.Bool(true)),
ownerReference("v-0", "k-0", "n-0", "u-0", ptr.To(false), ptr.To(true)),
},
wantEqual: false,
},
Expand Down

0 comments on commit 8140f79

Please sign in to comment.