Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile against Kubernetes 1.26 #582

Merged
merged 2 commits into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/v1/coherence_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1708,7 +1708,7 @@ func (in *PortSpecWithSSL) AddSSLVolumes(sts *appsv1.StatefulSet, c *corev1.Cont
VolumeSource: corev1.VolumeSource{
Secret: &corev1.SecretVolumeSource{
SecretName: *in.SSL.Secrets,
DefaultMode: pointer.Int32Ptr(int32(0777)),
DefaultMode: pointer.Int32(int32(0777)),
},
},
})
Expand Down
34 changes: 17 additions & 17 deletions api/v1/coherence_webhook_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2022, Oracle and/or its affiliates.
* Copyright (c) 2020, 2023, Oracle and/or its affiliates.
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*
Expand Down Expand Up @@ -403,7 +403,7 @@ func TestValidateCreateReplicasWhenReplicasIsPositive(t *testing.T) {

current := &coh.Coherence{
Spec: coh.CoherenceResourceSpec{
Replicas: pointer.Int32Ptr(19),
Replicas: pointer.Int32(19),
},
}

Expand All @@ -416,7 +416,7 @@ func TestValidateCreateReplicasWhenReplicasIsZero(t *testing.T) {

current := &coh.Coherence{
Spec: coh.CoherenceResourceSpec{
Replicas: pointer.Int32Ptr(19),
Replicas: pointer.Int32(19),
},
}

Expand All @@ -430,7 +430,7 @@ func TestValidateCreateReplicasWhenReplicasIsInvalid(t *testing.T) {
current := &coh.Coherence{
ObjectMeta: metav1.ObjectMeta{Name: "foo"},
Spec: coh.CoherenceResourceSpec{
Replicas: pointer.Int32Ptr(-1),
Replicas: pointer.Int32(-1),
},
}

Expand Down Expand Up @@ -458,7 +458,7 @@ func TestValidateUpdateReplicasWhenReplicasIsPositive(t *testing.T) {

current := &coh.Coherence{
Spec: coh.CoherenceResourceSpec{
Replicas: pointer.Int32Ptr(19),
Replicas: pointer.Int32(19),
},
}

Expand All @@ -475,7 +475,7 @@ func TestValidateUpdateReplicasWhenReplicasIsZero(t *testing.T) {

current := &coh.Coherence{
Spec: coh.CoherenceResourceSpec{
Replicas: pointer.Int32Ptr(19),
Replicas: pointer.Int32(19),
},
}

Expand All @@ -493,7 +493,7 @@ func TestValidateUpdateReplicasWhenReplicasIsInvalid(t *testing.T) {
current := &coh.Coherence{
ObjectMeta: metav1.ObjectMeta{Name: "foo"},
Spec: coh.CoherenceResourceSpec{
Replicas: pointer.Int32Ptr(-1),
Replicas: pointer.Int32(-1),
},
}

Expand Down Expand Up @@ -599,12 +599,12 @@ func TestValidateNodePortsOnCreateWithValidPorts(t *testing.T) {
{
Name: "p1",
Port: 1234,
NodePort: pointer.Int32Ptr(30000),
NodePort: pointer.Int32(30000),
},
{
Name: "p2",
Port: 1235,
NodePort: pointer.Int32Ptr(32767),
NodePort: pointer.Int32(32767),
},
},
},
Expand All @@ -624,17 +624,17 @@ func TestValidateNodePortsOnCreateWithInvalidPort(t *testing.T) {
{
Name: "p1",
Port: 1234,
NodePort: pointer.Int32Ptr(30000),
NodePort: pointer.Int32(30000),
},
{
Name: "p2",
Port: 1235,
NodePort: pointer.Int32Ptr(32767),
NodePort: pointer.Int32(32767),
},
{
Name: "p3",
Port: 1235,
NodePort: pointer.Int32Ptr(1234),
NodePort: pointer.Int32(1234),
},
},
},
Expand All @@ -654,12 +654,12 @@ func TestValidateNodePortsOnUpdateWithValidPorts(t *testing.T) {
{
Name: "p1",
Port: 1234,
NodePort: pointer.Int32Ptr(30000),
NodePort: pointer.Int32(30000),
},
{
Name: "p2",
Port: 1235,
NodePort: pointer.Int32Ptr(32767),
NodePort: pointer.Int32(32767),
},
},
},
Expand All @@ -684,17 +684,17 @@ func TestValidateNodePortsOnUpdateWithInvalidPort(t *testing.T) {
{
Name: "p1",
Port: 1234,
NodePort: pointer.Int32Ptr(30000),
NodePort: pointer.Int32(30000),
},
{
Name: "p2",
Port: 1235,
NodePort: pointer.Int32Ptr(32767),
NodePort: pointer.Int32(32767),
},
{
Name: "p3",
Port: 1235,
NodePort: pointer.Int32Ptr(1234),
NodePort: pointer.Int32(1234),
},
},
},
Expand Down
18 changes: 9 additions & 9 deletions api/v1/create_statefulset_additional_ports_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates.
* Copyright (c) 2020, 2023, Oracle and/or its affiliates.
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
Expand Down Expand Up @@ -152,7 +152,7 @@ func TestCreateStatefulSetWithMetricsPortWhenMetricsPortValueSpecified(t *testin
spec := coh.CoherenceResourceSpec{
Coherence: &coh.CoherenceSpec{
Metrics: &coh.PortSpecWithSSL{
Port: pointer.Int32Ptr(1234),
Port: pointer.Int32(1234),
},
},
Ports: []coh.NamedPortSpec{np},
Expand Down Expand Up @@ -185,7 +185,7 @@ func TestCreateStatefulSetWithMetricsPortAndServicePortWhenNoPortValueSpecified(
np := coh.NamedPortSpec{
Name: coh.PortNameMetrics,
Service: &coh.ServiceSpec{
Port: pointer.Int32Ptr(1234),
Port: pointer.Int32(1234),
},
}

Expand Down Expand Up @@ -220,14 +220,14 @@ func TestCreateStatefulSetWithMetricsPortAndServicePortWhenMetricsPortValueSpeci
np := coh.NamedPortSpec{
Name: coh.PortNameMetrics,
Service: &coh.ServiceSpec{
Port: pointer.Int32Ptr(1234),
Port: pointer.Int32(1234),
},
}

spec := coh.CoherenceResourceSpec{
Coherence: &coh.CoherenceSpec{
Metrics: &coh.PortSpecWithSSL{
Port: pointer.Int32Ptr(9876),
Port: pointer.Int32(9876),
},
},
Ports: []coh.NamedPortSpec{np},
Expand Down Expand Up @@ -296,7 +296,7 @@ func TestCreateStatefulSetWithManagementPortWhenManagementPortValueSpecified(t *
spec := coh.CoherenceResourceSpec{
Coherence: &coh.CoherenceSpec{
Management: &coh.PortSpecWithSSL{
Port: pointer.Int32Ptr(1234),
Port: pointer.Int32(1234),
},
},
Ports: []coh.NamedPortSpec{np},
Expand Down Expand Up @@ -329,7 +329,7 @@ func TestCreateStatefulSetWithManagementPortAndServicePortWhenNoPortValueSpecifi
np := coh.NamedPortSpec{
Name: coh.PortNameManagement,
Service: &coh.ServiceSpec{
Port: pointer.Int32Ptr(1234),
Port: pointer.Int32(1234),
},
}

Expand Down Expand Up @@ -364,14 +364,14 @@ func TestCreateStatefulSetWithManagementPortAndServicePortWhenManagementPortValu
np := coh.NamedPortSpec{
Name: coh.PortNameManagement,
Service: &coh.ServiceSpec{
Port: pointer.Int32Ptr(1234),
Port: pointer.Int32(1234),
},
}

spec := coh.CoherenceResourceSpec{
Coherence: &coh.CoherenceSpec{
Management: &coh.PortSpecWithSSL{
Port: pointer.Int32Ptr(9876),
Port: pointer.Int32(9876),
},
},
Ports: []coh.NamedPortSpec{np},
Expand Down
8 changes: 4 additions & 4 deletions api/v1/create_statefulset_coherencespec_persistence_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2022, Oracle and/or its affiliates.
* Copyright (c) 2020, 2023, Oracle and/or its affiliates.
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
Expand Down Expand Up @@ -35,7 +35,7 @@ func TestCreateStatefulSetWithPersistenceModeOnDemand(t *testing.T) {
spec := coh.CoherenceResourceSpec{
Coherence: &coh.CoherenceSpec{
Persistence: &coh.PersistenceSpec{
Mode: pointer.StringPtr("on-demand"),
Mode: pointer.String("on-demand"),
},
},
}
Expand All @@ -55,7 +55,7 @@ func TestCreateStatefulSetWithPersistenceModeActive(t *testing.T) {
spec := coh.CoherenceResourceSpec{
Coherence: &coh.CoherenceSpec{
Persistence: &coh.PersistenceSpec{
Mode: pointer.StringPtr("active"),
Mode: pointer.String("active"),
},
},
}
Expand All @@ -74,7 +74,7 @@ func TestCreateStatefulSetWithPersistenceModeActiveAsync(t *testing.T) {
spec := coh.CoherenceResourceSpec{
Coherence: &coh.CoherenceSpec{
Persistence: &coh.PersistenceSpec{
Mode: pointer.StringPtr("active-async"),
Mode: pointer.String("active-async"),
},
},
}
Expand Down
14 changes: 7 additions & 7 deletions api/v1/create_statefulset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestCreateStatefulSetWithName(t *testing.T) {
func TestCreateStatefulSetWithReplicas(t *testing.T) {
// create a spec with a name
spec := coh.CoherenceResourceSpec{
Replicas: pointer.Int32Ptr(50),
Replicas: pointer.Int32(50),
}

// Create the test deployment
Expand Down Expand Up @@ -347,7 +347,7 @@ func TestCreateStatefulSetWithTolerations(t *testing.T) {

func TestCreateStatefulSetWithSecurityContext(t *testing.T) {
ctx := corev1.PodSecurityContext{
RunAsUser: pointer.Int64Ptr(1000),
RunAsUser: pointer.Int64(1000),
RunAsNonRoot: boolPtr(true),
}

Expand All @@ -370,7 +370,7 @@ func TestCreateStatefulSetWithContainerSecurityContext(t *testing.T) {
Capabilities: &corev1.Capabilities{
Add: []corev1.Capability{"foo"},
},
RunAsUser: pointer.Int64Ptr(1000),
RunAsUser: pointer.Int64(1000),
RunAsNonRoot: boolPtr(true),
}

Expand Down Expand Up @@ -483,29 +483,29 @@ func TestCreateStatefulSetWithActiveDeadlineSeconds(t *testing.T) {

func TestCreateStatefulSetWithEnableServiceLinksFalse(t *testing.T) {
spec := coh.CoherenceResourceSpec{
EnableServiceLinks: pointer.BoolPtr(false),
EnableServiceLinks: pointer.Bool(false),
}

// Create the test deployment
deployment := createTestDeployment(spec)
// Create expected StatefulSet
stsExpected := createMinimalExpectedStatefulSet(deployment)
stsExpected.Spec.Template.Spec.EnableServiceLinks = pointer.BoolPtr(false)
stsExpected.Spec.Template.Spec.EnableServiceLinks = pointer.Bool(false)

// assert that the StatefulSet is as expected
assertStatefulSetCreation(t, deployment, stsExpected)
}

func TestCreateStatefulSetWithEnableServiceLinksTrue(t *testing.T) {
spec := coh.CoherenceResourceSpec{
EnableServiceLinks: pointer.BoolPtr(true),
EnableServiceLinks: pointer.Bool(true),
}

// Create the test deployment
deployment := createTestDeployment(spec)
// Create expected StatefulSet
stsExpected := createMinimalExpectedStatefulSet(deployment)
stsExpected.Spec.Template.Spec.EnableServiceLinks = pointer.BoolPtr(true)
stsExpected.Spec.Template.Spec.EnableServiceLinks = pointer.Bool(true)

// assert that the StatefulSet is as expected
assertStatefulSetCreation(t, deployment, stsExpected)
Expand Down
4 changes: 2 additions & 2 deletions api/v1/create_wka_services_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2021, Oracle and/or its affiliates.
* Copyright (c) 2020, 2023, Oracle and/or its affiliates.
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
Expand Down Expand Up @@ -180,7 +180,7 @@ func TestCreateWKAServiceForDeploymentWithClusterName(t *testing.T) {
Name: "test",
},
Spec: coh.CoherenceResourceSpec{
Cluster: pointer.StringPtr("test-cluster"),
Cluster: pointer.String("test-cluster"),
},
}

Expand Down
12 changes: 6 additions & 6 deletions controllers/statefulset/probe.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2021, Oracle and/or its affiliates.
* Copyright (c) 2020, 2023, Oracle and/or its affiliates.
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
Expand Down Expand Up @@ -167,7 +167,7 @@ func (in *CoherenceProbe) ExecuteProbe(ctx context.Context, deployment *coh.Cohe
log.Info("Using pod " + pod.Name + " to execute probe")
}

ha, err := in.RunProbe(pod, probe)
ha, err := in.RunProbe(ctx, pod, probe)
if err == nil {
log.Info(fmt.Sprintf("Executed probe using pod %s result=%t", pod.Name, ha))
return ha
Expand Down Expand Up @@ -195,10 +195,10 @@ func (in *CoherenceProbe) IsPodReady(pod corev1.Pod) (bool, string) {
return false, string(pod.Status.Phase)
}

func (in *CoherenceProbe) RunProbe(pod corev1.Pod, handler *coh.Probe) (bool, error) {
func (in *CoherenceProbe) RunProbe(ctx context.Context, pod corev1.Pod, handler *coh.Probe) (bool, error) {
switch {
case handler.Exec != nil:
return in.ProbeUsingExec(pod, handler)
return in.ProbeUsingExec(ctx, pod, handler)
case handler.HTTPGet != nil:
return in.ProbeUsingHTTP(pod, handler)
case handler.TCPSocket != nil:
Expand All @@ -208,7 +208,7 @@ func (in *CoherenceProbe) RunProbe(pod corev1.Pod, handler *coh.Probe) (bool, er
}
}

func (in *CoherenceProbe) ProbeUsingExec(pod corev1.Pod, handler *coh.Probe) (bool, error) {
func (in *CoherenceProbe) ProbeUsingExec(ctx context.Context, pod corev1.Pod, handler *coh.Probe) (bool, error) {
req := &mgmt.ExecRequest{
Pod: pod.Name,
Container: coh.ContainerNameCoherence,
Expand All @@ -218,7 +218,7 @@ func (in *CoherenceProbe) ProbeUsingExec(pod corev1.Pod, handler *coh.Probe) (bo
Timeout: handler.GetTimeout(),
}

exitCode, _, _, err := mgmt.PodExec(req, in.Config)
exitCode, _, _, err := mgmt.PodExec(ctx, req, in.Config)

log.Info(fmt.Sprintf("Exec Probe: '%s' result=%d error=%s", strings.Join(handler.Exec.Command, ", "), exitCode, err))

Expand Down
6 changes: 3 additions & 3 deletions controllers/statefulset/statefulset_controller.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2022, Oracle and/or its affiliates.
* Copyright (c) 2020, 2023, Oracle and/or its affiliates.
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
Expand Down Expand Up @@ -275,8 +275,8 @@ func buildActionJob(actionName string, actionJob *coh.ActionJob, deployment *coh
Kind: deployment.Kind,
Name: deployment.Name,
UID: deployment.UID,
Controller: pointer.BoolPtr(true),
BlockOwnerDeletion: pointer.BoolPtr(false),
Controller: pointer.Bool(true),
BlockOwnerDeletion: pointer.Bool(false),
},
},
},
Expand Down