diff --git a/controllers/tls/manager.go b/controllers/tls/manager.go index 315dd8a7..558af16a 100644 --- a/controllers/tls/manager.go +++ b/controllers/tls/manager.go @@ -19,7 +19,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/util/retry" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" @@ -234,8 +234,8 @@ func (r *Reconciler) updateTenantCustomResourceDefinition(ctx context.Context, n Service: &apiextensionsv1.ServiceReference{ Namespace: r.Namespace, Name: "capsule-webhook-service", - Path: pointer.String("/convert"), - Port: pointer.Int32(443), + Path: ptr.To("/convert"), + Port: ptr.To(int32(443)), }, CABundle: caBundle, }, diff --git a/e2e/disable_externalname_test.go b/e2e/disable_externalname_test.go index 918668db..a332e1cb 100644 --- a/e2e/disable_externalname_test.go +++ b/e2e/disable_externalname_test.go @@ -13,7 +13,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" capsulev1beta2 "github.com/projectcapsule/capsule/api/v1beta2" "github.com/projectcapsule/capsule/pkg/api" @@ -33,7 +33,7 @@ var _ = Describe("creating an ExternalName service when it is disabled for Tenan }, ServiceOptions: &api.ServiceOptions{ AllowedServices: &api.AllowedServices{ - ExternalName: pointer.Bool(false), + ExternalName: ptr.To(false), }, }, }, diff --git a/e2e/disable_loadbalancer_test.go b/e2e/disable_loadbalancer_test.go index 902cb781..d7468b2f 100644 --- a/e2e/disable_loadbalancer_test.go +++ b/e2e/disable_loadbalancer_test.go @@ -13,7 +13,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" capsulev1beta2 "github.com/projectcapsule/capsule/api/v1beta2" "github.com/projectcapsule/capsule/pkg/api" @@ -33,7 +33,7 @@ var _ = Describe("creating a LoadBalancer service when it is disabled for Tenant }, ServiceOptions: &api.ServiceOptions{ AllowedServices: &api.AllowedServices{ - LoadBalancer: pointer.Bool(false), + LoadBalancer: ptr.To(false), }, }, }, diff --git a/e2e/disable_node_ports_test.go b/e2e/disable_node_ports_test.go index 67d22b0e..59875333 100644 --- a/e2e/disable_node_ports_test.go +++ b/e2e/disable_node_ports_test.go @@ -13,7 +13,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" capsulev1beta2 "github.com/projectcapsule/capsule/api/v1beta2" "github.com/projectcapsule/capsule/pkg/api" @@ -33,7 +33,7 @@ var _ = Describe("creating a nodePort service when it is disabled for Tenant", f }, ServiceOptions: &api.ServiceOptions{ AllowedServices: &api.AllowedServices{ - NodePort: pointer.Bool(false), + NodePort: ptr.To(false), }, }, }, diff --git a/e2e/enable_loadbalancer_test.go b/e2e/enable_loadbalancer_test.go index 8ea54320..e3735cdb 100644 --- a/e2e/enable_loadbalancer_test.go +++ b/e2e/enable_loadbalancer_test.go @@ -13,7 +13,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" capsulev1beta2 "github.com/projectcapsule/capsule/api/v1beta2" "github.com/projectcapsule/capsule/pkg/api" @@ -33,7 +33,7 @@ var _ = Describe("creating a LoadBalancer service when it is enabled for Tenant" }, ServiceOptions: &api.ServiceOptions{ AllowedServices: &api.AllowedServices{ - LoadBalancer: pointer.Bool(true), + LoadBalancer: ptr.To(true), }, }, }, diff --git a/e2e/globaltenantresource_test.go b/e2e/globaltenantresource_test.go index cd75772a..d9936b4c 100644 --- a/e2e/globaltenantresource_test.go +++ b/e2e/globaltenantresource_test.go @@ -18,7 +18,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/selection" "k8s.io/apimachinery/pkg/types" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" capsulev1beta2 "github.com/projectcapsule/capsule/api/v1beta2" @@ -83,7 +83,7 @@ var _ = Describe("Creating a GlobalTenantResource object", func() { }, TenantResourceSpec: capsulev1beta2.TenantResourceSpec{ ResyncPeriod: metav1.Duration{Duration: time.Minute}, - PruningOnDelete: pointer.Bool(true), + PruningOnDelete: ptr.To(true), Resources: []capsulev1beta2.ResourceSpec{ { NamespacedItems: []capsulev1beta2.ObjectReference{ diff --git a/e2e/ingress_class_extensions_test.go b/e2e/ingress_class_extensions_test.go index 1e55377f..f67839e3 100644 --- a/e2e/ingress_class_extensions_test.go +++ b/e2e/ingress_class_extensions_test.go @@ -14,7 +14,7 @@ import ( extensionsv1beta1 "k8s.io/api/extensions/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" capsulev1beta2 "github.com/projectcapsule/capsule/api/v1beta2" "github.com/projectcapsule/capsule/pkg/api" @@ -131,7 +131,7 @@ var _ = Describe("when Tenant handles Ingress classes with extensions/v1beta1", Name: "denied-ingress", }, Spec: extensionsv1beta1.IngressSpec{ - IngressClassName: pointer.String("the-worst-ingress-available"), + IngressClassName: ptr.To("the-worst-ingress-available"), Backend: &extensionsv1beta1.IngressBackend{ ServiceName: "foo", ServicePort: intstr.FromInt(8080), diff --git a/e2e/ingress_class_networking_test.go b/e2e/ingress_class_networking_test.go index 6c92d54e..0dfe358d 100644 --- a/e2e/ingress_class_networking_test.go +++ b/e2e/ingress_class_networking_test.go @@ -18,7 +18,7 @@ import ( "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/selection" "k8s.io/apimachinery/pkg/types" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" capsulev1beta2 "github.com/projectcapsule/capsule/api/v1beta2" @@ -220,7 +220,7 @@ var _ = Describe("when Tenant handles Ingress classes with networking.k8s.io/v1" Name: "denied-ingress", }, Spec: networkingv1.IngressSpec{ - IngressClassName: pointer.String("the-worst-ingress-available"), + IngressClassName: ptr.To("the-worst-ingress-available"), DefaultBackend: &networkingv1.IngressBackend{ Service: &networkingv1.IngressServiceBackend{ Name: "foo", diff --git a/e2e/overquota_namespace_test.go b/e2e/overquota_namespace_test.go index f6ef3d71..16260d1b 100644 --- a/e2e/overquota_namespace_test.go +++ b/e2e/overquota_namespace_test.go @@ -11,7 +11,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" capsulev1beta2 "github.com/projectcapsule/capsule/api/v1beta2" ) @@ -29,7 +29,7 @@ var _ = Describe("creating a Namespace in over-quota of three", func() { }, }, NamespaceOptions: &capsulev1beta2.NamespaceOptions{ - Quota: pointer.Int32(3), + Quota: ptr.To(int32(3)), }, }, } diff --git a/e2e/preventing_pv_cross_tenant_mount_test.go b/e2e/preventing_pv_cross_tenant_mount_test.go index dd983abc..2e6d163a 100644 --- a/e2e/preventing_pv_cross_tenant_mount_test.go +++ b/e2e/preventing_pv_cross_tenant_mount_test.go @@ -14,7 +14,7 @@ import ( "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" capsulev1beta2 "github.com/projectcapsule/capsule/api/v1beta2" @@ -84,7 +84,7 @@ var _ = Describe("preventing PersistentVolume cross-tenant mount", func() { corev1.ResourceStorage: resource.MustParse("1Gi"), }, }, - StorageClassName: pointer.String("standard"), + StorageClassName: ptr.To("standard"), }, } @@ -167,7 +167,7 @@ var _ = Describe("preventing PersistentVolume cross-tenant mount", func() { return k8sClient.Update(context.Background(), &pv) }, defaultTimeoutInterval, defaultPollInterval).Should(Succeed()) - Expect(k8sClient.Delete(context.Background(), &pod, &client.DeleteOptions{GracePeriodSeconds: pointer.Int64(0)})).ToNot(HaveOccurred()) + Expect(k8sClient.Delete(context.Background(), &pod, &client.DeleteOptions{GracePeriodSeconds: ptr.To(int64(0))})).ToNot(HaveOccurred()) ns2 := NewNamespace("") NamespaceCreation(ns2, tnt2.Spec.Owners[0], defaultTimeoutInterval).Should(Succeed()) @@ -188,7 +188,7 @@ var _ = Describe("preventing PersistentVolume cross-tenant mount", func() { corev1.ResourceStorage: resource.MustParse("1Gi"), }, }, - StorageClassName: pointer.String("standard"), + StorageClassName: ptr.To("standard"), VolumeName: pv.Name, }, } diff --git a/e2e/resource_quota_exceeded_test.go b/e2e/resource_quota_exceeded_test.go index b1da8d2d..c97929df 100644 --- a/e2e/resource_quota_exceeded_test.go +++ b/e2e/resource_quota_exceeded_test.go @@ -18,7 +18,7 @@ import ( "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" capsulev1beta2 "github.com/projectcapsule/capsule/api/v1beta2" ) @@ -135,7 +135,7 @@ var _ = Describe("exceeding a Tenant resource quota", func() { Name: "my-pause", }, Spec: appsv1.DeploymentSpec{ - Replicas: pointer.Int32(5), + Replicas: ptr.To(int32(5)), Selector: &metav1.LabelSelector{ MatchLabels: map[string]string{ "app": "pause", diff --git a/e2e/service_metadata_test.go b/e2e/service_metadata_test.go index 15d1755b..46c70836 100644 --- a/e2e/service_metadata_test.go +++ b/e2e/service_metadata_test.go @@ -18,7 +18,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" capsulev1beta2 "github.com/projectcapsule/capsule/api/v1beta2" @@ -269,8 +269,8 @@ var _ = Describe("adding metadata to Service objects", func() { }, Ports: []discoveryv1beta1.EndpointPort{ { - Name: pointer.String("foo"), - Port: pointer.Int32(9999), + Name: ptr.To("foo"), + Port: ptr.To(int32(9999)), }, }, } @@ -288,8 +288,8 @@ var _ = Describe("adding metadata to Service objects", func() { }, Ports: []discoveryv1.EndpointPort{ { - Name: pointer.String("foo"), - Port: pointer.Int32(9999), + Name: ptr.To("foo"), + Port: ptr.To(int32(9999)), }, }, } diff --git a/e2e/storage_class_test.go b/e2e/storage_class_test.go index 1d0f887d..c98b34fe 100644 --- a/e2e/storage_class_test.go +++ b/e2e/storage_class_test.go @@ -21,7 +21,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/selection" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" capsulev1beta2 "github.com/projectcapsule/capsule/api/v1beta2" @@ -230,13 +230,14 @@ var _ = Describe("when Tenant handles Storage classes", func() { TenantNamespaceList(tntNoDefaults, defaultTimeoutInterval).Should(ContainElement(ns.GetName())) By("using exact matches", func() { for _, c := range tntNoDefaults.Spec.StorageClasses.Exact { + Eventually(func() (err error) { p := &corev1.PersistentVolumeClaim{ ObjectMeta: metav1.ObjectMeta{ Name: c, }, Spec: corev1.PersistentVolumeClaimSpec{ - StorageClassName: pointer.String(c), + StorageClassName: ptr.To(c), AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}, Resources: corev1.ResourceRequirements{ Requests: map[corev1.ResourceName]resource.Quantity{ diff --git a/e2e/suite_test.go b/e2e/suite_test.go index 142b3258..5e016ecc 100644 --- a/e2e/suite_test.go +++ b/e2e/suite_test.go @@ -13,7 +13,7 @@ import ( "k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/config" "sigs.k8s.io/controller-runtime/pkg/envtest" @@ -43,7 +43,7 @@ var _ = BeforeSuite(func() { By("bootstrapping test environment") testEnv = &envtest.Environment{ - UseExistingCluster: pointer.Bool(true), + UseExistingCluster: ptr.To(true), } var err error diff --git a/e2e/tenantresource_test.go b/e2e/tenantresource_test.go index df97353b..0b7505a3 100644 --- a/e2e/tenantresource_test.go +++ b/e2e/tenantresource_test.go @@ -19,7 +19,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/selection" "k8s.io/apimachinery/pkg/types" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" capsulev1beta2 "github.com/projectcapsule/capsule/api/v1beta2" @@ -77,7 +77,7 @@ var _ = Describe("Creating a TenantResource object", func() { }, Spec: capsulev1beta2.TenantResourceSpec{ ResyncPeriod: metav1.Duration{Duration: time.Minute}, - PruningOnDelete: pointer.Bool(true), + PruningOnDelete: ptr.To(true), Resources: []capsulev1beta2.ResourceSpec{ { NamespaceSelector: &metav1.LabelSelector{ @@ -371,7 +371,7 @@ var _ = Describe("Creating a TenantResource object", func() { Expect(k8sClient.Get(context.TODO(), types.NamespacedName{Name: tr.GetName(), Namespace: "solar-system"}, tr)).ToNot(HaveOccurred()) Expect(*tr.Spec.PruningOnDelete).Should(BeTrue()) - tr.Spec.PruningOnDelete = pointer.Bool(false) + tr.Spec.PruningOnDelete = ptr.To(false) Expect(k8sClient.Update(context.TODO(), tr)).ToNot(HaveOccurred()) diff --git a/go.mod b/go.mod index 6522d60f..35ab9052 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( k8s.io/apiextensions-apiserver v0.28.4 k8s.io/apimachinery v0.28.4 k8s.io/client-go v0.28.4 - k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 + k8s.io/utils v0.0.0-20240102154912-e7106e64919e sigs.k8s.io/cluster-api v1.6.1 sigs.k8s.io/controller-runtime v0.16.3 ) diff --git a/go.sum b/go.sum index 886be6b0..abf3c44b 100644 --- a/go.sum +++ b/go.sum @@ -257,8 +257,8 @@ k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg= k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 h1:LyMgNKD2P8Wn1iAwQU5OhxCKlKJy0sHc+PcDwFB24dQ= k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9/go.mod h1:wZK2AVp1uHCp4VamDVgBP2COHZjqD1T68Rf0CM3YjSM= -k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 h1:qY1Ad8PODbnymg2pRbkyMT/ylpTrCM8P2RJ0yroCyIk= -k8s.io/utils v0.0.0-20230406110748-d93618cff8a2/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +k8s.io/utils v0.0.0-20240102154912-e7106e64919e h1:eQ/4ljkx21sObifjzXwlPKpdGLrCfRziVtos3ofG/sQ= +k8s.io/utils v0.0.0-20240102154912-e7106e64919e/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/cluster-api v1.6.1 h1:I34p/fwgRlEhs+o9cUhKXDwNNfPS3no0yJsd2bJyQVc= sigs.k8s.io/cluster-api v1.6.1/go.mod h1:DaxwruDvSaEYq5q6FREDaGzX6UsAVUCA99Sp8vfMHyQ= sigs.k8s.io/controller-runtime v0.16.3 h1:2TuvuokmfXvDUamSx1SuAOO3eTyye+47mJCigwG62c4=