com.codacy.scoobydoo.kubernetes.handlers.FindPodByLabelHandler Maven / Gradle / Ivy
package com.codacy.scoobydoo.kubernetes.handlers;
import io.fabric8.kubernetes.api.model.PodList;
import io.fabric8.kubernetes.client.KubernetesClient;
import java.util.concurrent.Callable;
public class FindPodByLabelHandler implements Callable {
private final KubernetesClient kubernetesClient;
private String namespace;
private String labelKey;
private String labelValue;
public FindPodByLabelHandler(KubernetesClient kubernetesClient, String labelKey, String labelValue, String namespace) {
this.kubernetesClient = kubernetesClient;
this.labelKey = labelKey;
this.labelValue = labelValue;
this.namespace = namespace;
}
@Override
public Boolean call() throws Exception {
PodList list = kubernetesClient
.pods()
.inNamespace(namespace)
.withLabel(labelKey, labelValue)
.list();
return !list.getItems().isEmpty();
}
}