Skip to content

Commit

Permalink
Use NewClientset instead of NewSimpleClientset
Browse files Browse the repository at this point in the history
The latter is deprecated in Kubernetes 1.31.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
  • Loading branch information
skitt committed Aug 21, 2024
1 parent 2393f8c commit 0ef3b62
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion pkg/cableengine/syncer/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ type testDriver struct {
}

func newTestDriver() *testDriver {
client := fakeClientset.NewSimpleClientset()
client := fakeClientset.NewClientset()

t := &testDriver{
engine: fakeEngine.New(),
Expand Down
2 changes: 1 addition & 1 deletion pkg/endpoint/local_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ var _ = Describe("GetLocalSpec", func() {
})

JustBeforeEach(func() {
client = fake.NewSimpleClientset(node)
client = fake.NewClientset(node)
})

It("should return a valid EndpointSpec object", func() {
Expand Down
18 changes: 9 additions & 9 deletions pkg/endpoint/public_ip_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ var _ = Describe("public ip resolvers", func() {
When("a LoadBalancer with Ingress IP is specified", func() {
It("should return the IP", func() {
backendConfig[publicIPConfig] = lbPublicIP
client := fake.NewSimpleClientset(serviceWithIngress(v1.LoadBalancerIngress{Hostname: "", IP: testIP}))
client := fake.NewClientset(serviceWithIngress(v1.LoadBalancerIngress{Hostname: "", IP: testIP}))
ip, err := getPublicIP(submSpec, client, backendConfig, false)
Expect(err).ToNot(HaveOccurred())
Expect(ip).To(Equal(testIP))
Expand All @@ -90,7 +90,7 @@ var _ = Describe("public ip resolvers", func() {
When("a LoadBalancer with Ingress hostname is specified", func() {
It("should return the IP", func() {
backendConfig[publicIPConfig] = lbPublicIP
client := fake.NewSimpleClientset(serviceWithIngress(v1.LoadBalancerIngress{
client := fake.NewClientset(serviceWithIngress(v1.LoadBalancerIngress{
Hostname: dnsHost,
IP: "",
}))
Expand All @@ -106,7 +106,7 @@ var _ = Describe("public ip resolvers", func() {
loadBalancerRetryConfig.Duration = 50 * time.Millisecond
loadBalancerRetryConfig.Steps = 1
backendConfig[publicIPConfig] = lbPublicIP
client := fake.NewSimpleClientset(serviceWithIngress())
client := fake.NewClientset(serviceWithIngress())
_, err := getPublicIP(submSpec, client, backendConfig, false)
Expect(err).To(HaveOccurred())
})
Expand All @@ -115,7 +115,7 @@ var _ = Describe("public ip resolvers", func() {
When("an IPv4 entry specified", func() {
It("should return the IP", func() {
backendConfig[publicIPConfig] = ipv4PublicIP
client := fake.NewSimpleClientset()
client := fake.NewClientset()
ip, err := getPublicIP(submSpec, client, backendConfig, false)
Expect(err).ToNot(HaveOccurred())
Expect(ip).To(Equal(testIP))
Expand All @@ -125,7 +125,7 @@ var _ = Describe("public ip resolvers", func() {
When("an IPv4 entry specified in air-gapped deployment", func() {
It("should return the IP and not an empty value", func() {
backendConfig[publicIPConfig] = ipv4PublicIP
client := fake.NewSimpleClientset()
client := fake.NewClientset()
ip, err := getPublicIP(submSpec, client, backendConfig, true)
Expect(err).ToNot(HaveOccurred())
Expect(ip).To(Equal(testIP))
Expand All @@ -135,7 +135,7 @@ var _ = Describe("public ip resolvers", func() {
When("a DNS entry specified", func() {
It("should return the IP", func() {
backendConfig[publicIPConfig] = "dns:" + dnsHost
client := fake.NewSimpleClientset()
client := fake.NewClientset()
ip, err := getPublicIP(submSpec, client, backendConfig, false)
Expect(err).ToNot(HaveOccurred())
Expect(ip).To(Equal(testIPDNS))
Expand All @@ -145,7 +145,7 @@ var _ = Describe("public ip resolvers", func() {
When("an API entry specified", func() {
It("should return some IP", func() {
backendConfig[publicIPConfig] = "api:4.icanhazip.com/"
client := fake.NewSimpleClientset()
client := fake.NewClientset()
ip, err := getPublicIP(submSpec, client, backendConfig, false)
Expect(err).ToNot(HaveOccurred())
Expect(net.ParseIP(ip)).NotTo(BeNil())
Expand All @@ -155,7 +155,7 @@ var _ = Describe("public ip resolvers", func() {
When("multiple entries are specified", func() {
It("should return the first working one", func() {
backendConfig[publicIPConfig] = ipv4PublicIP + ",dns:" + dnsHost
client := fake.NewSimpleClientset()
client := fake.NewClientset()
ip, err := getPublicIP(submSpec, client, backendConfig, false)
Expect(err).ToNot(HaveOccurred())
Expect(ip).To(Equal(testIP))
Expand All @@ -165,7 +165,7 @@ var _ = Describe("public ip resolvers", func() {
When("multiple entries are specified and the first one doesn't succeed", func() {
It("should return the first working one", func() {
backendConfig[publicIPConfig] = "dns:thisdomaindoesntexistforsure.badbadbad,ipv4:" + testIP
client := fake.NewSimpleClientset()
client := fake.NewClientset()
ip, err := getPublicIP(submSpec, client, backendConfig, false)
Expect(err).ToNot(HaveOccurred())
Expect(ip).To(Equal(testIP))
Expand Down
2 changes: 1 addition & 1 deletion pkg/endpoint/public_ip_watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func newPublicIPWatcherTestDriver() *publicIPWatcherTestDriver {
t.localEPSpec = newEndpointSpec(clusterID, cableName)

t.stopCh = make(chan struct{})
t.k8sClient = fake.NewSimpleClientset(loadBalancerService(v1.LoadBalancerIngress{Hostname: "", IP: initialIP}))
t.k8sClient = fake.NewClientset(loadBalancerService(v1.LoadBalancerIngress{Hostname: "", IP: initialIP}))
t.dynClient = dynamicfake.NewSimpleDynamicClient(scheme.Scheme)
t.endpointClient = t.dynClient.Resource(submarinerv1.EndpointGVR).Namespace(testNamespace)
t.localEndpoint = endpoint.NewLocal(&t.localEPSpec, t.dynClient, testNamespace)
Expand Down
4 changes: 2 additions & 2 deletions pkg/gateway/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func newTestDriver() *testDriver {
restMapper := test.GetRESTMapperFor(&submarinerv1.Endpoint{}, &submarinerv1.Cluster{}, &submarinerv1.Gateway{}, &corev1.Node{})

t.dynClient = dynamicfake.NewSimpleDynamicClient(scheme.Scheme)
t.kubeClient = k8sfake.NewSimpleClientset()
t.kubeClient = k8sfake.NewClientset()

t.cableEngine = enginefake.New()

Expand All @@ -282,7 +282,7 @@ func newTestDriver() *testDriver {
RestMapper: restMapper,
Client: t.dynClient,
},
SubmarinerClient: submfake.NewSimpleClientset(),
SubmarinerClient: submfake.NewClientset(),
KubeClient: t.kubeClient,
LeaderElectionClient: t.kubeClient,
NewCableEngine: func(_ *types.SubmarinerCluster, lep *submendpoint.Local) cableengine.Engine {
Expand Down
4 changes: 2 additions & 2 deletions pkg/globalnet/controllers/gateway_monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ var _ = Describe("Uninstall", func() {
})

Specify("DeleteGlobalnetObjects should delete all Globalnet resources and internal Services", func() {
submClient := fakesubmariner.NewSimpleClientset()
submClient := fakesubmariner.NewClientset()
fake.AddBasicReactors(&submClient.Fake)

clusterEgressIP, err := submClient.SubmarinerV1().ClusterGlobalEgressIPs("").Create(context.Background(),
Expand Down Expand Up @@ -387,7 +387,7 @@ func newGatewayMonitorTestDriver() *gatewayMonitorTestDriver {
t.endpoints = t.dynClient.Resource(*test.GetGroupVersionResourceFor(t.restMapper, &submarinerv1.Endpoint{})).
Namespace(namespace)

t.kubeClient = fakek8s.NewSimpleClientset()
t.kubeClient = fakek8s.NewClientset()
t.leaderElectionConfig = controllers.LeaderElectionConfig{}
t.leaderElection = testutil.NewLeaderElectionSupport(t.kubeClient, namespace, controllers.LeaderElectionLockName)

Expand Down
2 changes: 1 addition & 1 deletion pkg/routeagent_driver/handlers/calico/calico_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func newTestDriver() *testDriver {
}

BeforeEach(func() {
t.k8sClient = fakek8s.NewSimpleClientset()
t.k8sClient = fakek8s.NewClientset()

t.calicoClient = calicocsfake.NewSimpleClientset()
fake.AddDeleteCollectionReactor(&t.calicoClient.Fake)
Expand Down
4 changes: 2 additions & 2 deletions pkg/routeagent_driver/handlers/ovn/ovn_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ func newTestDriver() *testDriver {

BeforeEach(func() {
t.transitSwitchIP = "190.1.2.0"
t.submClient = fakesubm.NewSimpleClientset()
t.k8sClient = fakek8s.NewSimpleClientset()
t.submClient = fakesubm.NewClientset()
t.k8sClient = fakek8s.NewClientset()
t.dynClient = fakedynamic.NewSimpleDynamicClient(scheme.Scheme)

t.netLink = fakenetlink.New()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var _ = Describe("TransitSwitchIP", func() {
var k8sClient *fakek8s.Clientset

JustBeforeEach(func() {
k8sClient = fakek8s.NewSimpleClientset()
k8sClient = fakek8s.NewClientset()
node = createNode(k8sClient, nodeIP)
})

Expand Down
2 changes: 1 addition & 1 deletion pkg/util/clusterfiles/cluster_files_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var _ = BeforeSuite(func() {
var _ = Describe("Cluster Files Get", func() {
var client kubernetes.Interface
BeforeEach(func() {
client = fake.NewSimpleClientset(
client = fake.NewClientset(
&v1.Secret{
ObjectMeta: v1meta.ObjectMeta{Namespace: "ns1", Name: "my-secret"},
Data: map[string][]byte{
Expand Down

0 comments on commit 0ef3b62

Please sign in to comment.