@@ -25,6 +25,8 @@ import (
2525 "k8s.io/apimachinery/pkg/fields"
2626 "k8s.io/apimachinery/pkg/watch"
2727 "k8s.io/client-go/kubernetes"
28+ appsv1client "k8s.io/client-go/kubernetes/typed/apps/v1"
29+ corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
2830 "k8s.io/client-go/rest"
2931 "k8s.io/client-go/tools/clientcmd"
3032 "k8s.io/client-go/util/homedir"
@@ -204,7 +206,7 @@ func isReconciliationPaused(k *kafkaapi.Kafka) bool {
204206 }
205207}
206208
207- func deletePodSet (kube * kubernetes. Clientset , strimzi * strimzi.Clientset , clusterName string , poolName string , namespace string , timeout uint32 ) error {
209+ func deletePodSet (kube corev1client. CoreV1Interface , strimzi * strimzi.Clientset , clusterName string , poolName string , namespace string , timeout uint32 ) error {
208210 podSetName := clusterName + "-" + poolName
209211 log .Printf ("Deleting StrimziPodSet %s for KafkaNodePool %s" , podSetName , poolName )
210212
@@ -221,7 +223,7 @@ func deletePodSet(kube *kubernetes.Clientset, strimzi *strimzi.Clientset, cluste
221223 }
222224}
223225
224- func waitForPodSetPodsDeletion (kube * kubernetes. Clientset , clusterName string , poolName string , podSetName string , namespace string , timeout uint32 ) error {
226+ func waitForPodSetPodsDeletion (kube corev1client. CoreV1Interface , clusterName string , poolName string , podSetName string , namespace string , timeout uint32 ) error {
225227 // The Pod owner references to StrimziPodSets do not set `blockOwnerDeletion: true`.
226228 // As a result, foreground deletion of the StrimziPodSet does not wait for Pod
227229 // deletion and we need to check the Pod deletion separately.
@@ -236,7 +238,7 @@ func waitForPodSetPodsDeletion(kube *kubernetes.Clientset, clusterName string, p
236238 go func () {
237239 for {
238240 labelSelector := fmt .Sprintf ("strimzi.io/cluster=%s,strimzi.io/pool-name=%s" , clusterName , poolName )
239- pods , err := kube .CoreV1 (). Pods (namespace ).List (context .TODO (), metav1.ListOptions {LabelSelector : labelSelector })
241+ pods , err := kube .Pods (namespace ).List (context .TODO (), metav1.ListOptions {LabelSelector : labelSelector })
240242 if err != nil {
241243 podsDeletedError <- err
242244 break
@@ -260,13 +262,13 @@ func waitForPodSetPodsDeletion(kube *kubernetes.Clientset, clusterName string, p
260262 }
261263}
262264
263- func deleteDeployment (kube * kubernetes. Clientset , clusterName string , componentName string , namespace string , timeout uint32 ) error {
265+ func deleteDeployment (kube appsv1client. AppsV1Interface , clusterName string , componentName string , namespace string , timeout uint32 ) error {
264266 deploymentName := clusterName + "-" + componentName
265267 log .Printf ("Deleting Deployment %s in namespace %s" , deploymentName , namespace )
266268
267269 propagationPolicy := metav1 .DeletePropagationForeground
268270
269- err := kube .AppsV1 (). Deployments (namespace ).Delete (context .TODO (), deploymentName , metav1.DeleteOptions {PropagationPolicy : & propagationPolicy })
271+ err := kube .Deployments (namespace ).Delete (context .TODO (), deploymentName , metav1.DeleteOptions {PropagationPolicy : & propagationPolicy })
270272 if err != nil && ! errors .IsNotFound (err ) {
271273 return fmt .Errorf ("failed to delete Deployment %s in namespace %s: %v" , deploymentName , namespace , err )
272274 } else if errors .IsNotFound (err ) {
@@ -276,11 +278,11 @@ func deleteDeployment(kube *kubernetes.Clientset, clusterName string, componentN
276278 }
277279}
278280
279- func waitForDeploymentDeletion (kube * kubernetes. Clientset , name string , namespace string , timeout uint32 ) error {
281+ func waitForDeploymentDeletion (kube appsv1client. AppsV1Interface , name string , namespace string , timeout uint32 ) error {
280282 watchContext , watchContextCancel := context .WithTimeout (context .Background (), time .Millisecond * time .Duration (timeout ))
281283 defer watchContextCancel ()
282284
283- watcher , err := kube .AppsV1 (). Deployments (namespace ).Watch (watchContext , metav1.ListOptions {FieldSelector : fields .OneTermEqualSelector (metav1 .ObjectNameField , name ).String ()})
285+ watcher , err := kube .Deployments (namespace ).Watch (watchContext , metav1.ListOptions {FieldSelector : fields .OneTermEqualSelector (metav1 .ObjectNameField , name ).String ()})
284286 if err != nil {
285287 return err
286288 }
0 commit comments