Skip to content

Commit 89c7d10

Browse files
committed
update tests for 1.30 kubernetes chages
this includes * updating for controller-runtime * updating location of openshift/api manifests for tests * update Makefile for envtest version and gcs bucket flag
1 parent 9fd51e4 commit 89c7d10

File tree

5 files changed

+15
-14
lines changed

5 files changed

+15
-14
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
IMG ?= controller:latest
44

55
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
6-
ENVTEST_K8S_VERSION = 1.29
6+
ENVTEST_K8S_VERSION = 1.30.1
77

88
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
99
CONTROLLER_GEN = go run ${PROJECT_DIR}/vendor/sigs.k8s.io/controller-tools/cmd/controller-gen
@@ -34,7 +34,7 @@ verify: fmt vet lint
3434
test: generate verify manifests unit
3535

3636
unit:
37-
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path --bin-dir $(PROJECT_DIR)/bin --remote-bucket openshift-kubebuilder-tools)" ./hack/ci-test.sh
37+
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --use-deprecated-gcs=true -p path --bin-dir $(PROJECT_DIR)/bin --remote-bucket openshift-kubebuilder-tools)" ./hack/ci-test.sh
3838

3939
# Build operator binaries
4040
build: operator config-sync-controllers azure-config-credentials-injector

pkg/controllers/clusteroperator_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ func (r *CloudOperatorReconciler) SetupWithManager(mgr ctrl.Manager) error {
205205
Watches(&operatorv1.KubeControllerManager{},
206206
handler.EnqueueRequestsFromMapFunc(toClusterOperator),
207207
builder.WithPredicates(kcmPredicates())).
208-
WatchesRawSource(&source.Channel{Source: watcher.EventStream()}, handler.EnqueueRequestsFromMapFunc(toClusterOperator)).
208+
WatchesRawSource(source.Channel(watcher.EventStream(), handler.EnqueueRequestsFromMapFunc(toClusterOperator))).
209209
Watches(&corev1.ConfigMap{}, handler.EnqueueRequestsFromMapFunc(toClusterOperator)).
210210
Watches(&corev1.Secret{}, handler.EnqueueRequestsFromMapFunc(toClusterOperator))
211211

pkg/controllers/clusteroperator_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ var _ = Describe("Apply resources should", func() {
600600
Eventually(func() bool {
601601
err := cl.Delete(context.Background(), co)
602602
return err == nil || apierrors.IsNotFound(err)
603-
}).Should(BeTrue())
603+
}, timeout).Should(BeTrue())
604604
}
605605
Eventually(apierrors.IsNotFound(cl.Get(context.Background(), client.ObjectKey{Name: clusterOperatorName}, co))).Should(BeTrue())
606606

pkg/controllers/resourceapply/resourceapply.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1818
"k8s.io/client-go/tools/record"
1919
"k8s.io/klog/v2"
20+
"k8s.io/utils/ptr"
2021

2122
"sigs.k8s.io/controller-runtime/pkg/client"
2223
coreclientv1 "sigs.k8s.io/controller-runtime/pkg/client"
@@ -105,7 +106,7 @@ func applyConfigMap(ctx context.Context, client coreclientv1.Client, recorder re
105106
return false, err
106107
}
107108

108-
modified := resourcemerge.BoolPtr(false)
109+
modified := ptr.To[bool](false)
109110
existingCopy := existing.DeepCopy()
110111

111112
resourcemerge.EnsureObjectMeta(modified, &existingCopy.ObjectMeta, required.ObjectMeta)
@@ -178,7 +179,7 @@ func applyDeployment(ctx context.Context, client coreclientv1.Client, recorder r
178179
return false, err
179180
}
180181

181-
modified := resourcemerge.BoolPtr(false)
182+
modified := ptr.To[bool](false)
182183
existingCopy := existing.DeepCopy()
183184

184185
expectedGeneration := ""
@@ -267,7 +268,7 @@ func applyDaemonSet(ctx context.Context, client coreclientv1.Client, recorder re
267268
return false, err
268269
}
269270

270-
modified := resourcemerge.BoolPtr(false)
271+
modified := ptr.To[bool](false)
271272
existingCopy := existing.DeepCopy()
272273

273274
expectedGeneration := ""
@@ -347,7 +348,7 @@ func applyPodDisruptionBudget(ctx context.Context, client coreclientv1.Client, r
347348
return false, fmt.Errorf("failed to get pdb for update: %v", err)
348349
}
349350

350-
modified := resourcemerge.BoolPtr(false)
351+
modified := ptr.To[bool](false)
351352
existingCopy := existing.DeepCopy()
352353

353354
resourcemerge.EnsureObjectMeta(modified, &existingCopy.ObjectMeta, required.ObjectMeta)
@@ -387,7 +388,7 @@ func applyRole(ctx context.Context, client coreclientv1.Client, recorder record.
387388
return false, fmt.Errorf("failed to get role for update: %v", err)
388389
}
389390

390-
modified := resourcemerge.BoolPtr(false)
391+
modified := ptr.To[bool](false)
391392
existingCopy := existing.DeepCopy()
392393

393394
resourcemerge.EnsureObjectMeta(modified, &existingCopy.ObjectMeta, required.ObjectMeta)
@@ -425,7 +426,7 @@ func applyClusterRole(ctx context.Context, client coreclientv1.Client, recorder
425426
return false, fmt.Errorf("failed to get clusterrole for update: %v", err)
426427
}
427428

428-
modified := resourcemerge.BoolPtr(false)
429+
modified := ptr.To[bool](false)
429430
existingCopy := existing.DeepCopy()
430431

431432
resourcemerge.EnsureObjectMeta(modified, &existingCopy.ObjectMeta, required.ObjectMeta)
@@ -464,7 +465,7 @@ func applyRoleBinding(ctx context.Context, client coreclientv1.Client, recorder
464465
return false, fmt.Errorf("failed to get rolebinding for update: %v", err)
465466
}
466467

467-
modified := resourcemerge.BoolPtr(false)
468+
modified := ptr.To[bool](false)
468469
existingCopy := existing.DeepCopy()
469470
requiredCopy := required.DeepCopy()
470471

@@ -521,7 +522,7 @@ func applyClusterRoleBinding(ctx context.Context, client coreclientv1.Client, re
521522
return false, fmt.Errorf("failed to get clusterrolebinding for update: %v", err)
522523
}
523524

524-
modified := resourcemerge.BoolPtr(false)
525+
modified := ptr.To[bool](false)
525526
existingCopy := existing.DeepCopy()
526527
requiredCopy := required.DeepCopy()
527528

pkg/controllers/suite_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ var _ = BeforeSuite(func() {
7474
By("bootstrapping test environment")
7575
testEnv = &envtest.Environment{
7676
CRDDirectoryPaths: []string{
77-
filepath.Join("../..", "vendor", "github.com", "openshift", "api", "config", "v1"),
78-
filepath.Join("../..", "vendor", "github.com", "openshift", "api", "operator", "v1"),
77+
filepath.Join("../..", "vendor", "github.com", "openshift", "api", "config", "v1", "zz_generated.crd-manifests"),
78+
filepath.Join("../..", "vendor", "github.com", "openshift", "api", "operator", "v1", "zz_generated.crd-manifests"),
7979
},
8080
}
8181

0 commit comments

Comments
 (0)