All Downloads are FREE. Search and download functionalities are using the official Maven repository.

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 final String labelKey;
    private final String labelValue;
    private final String namespace;

    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() {
        PodList list = kubernetesClient
                .pods()
                .inNamespace(namespace)
                .withLabel(labelKey, labelValue)
                .list();
        return !list.getItems().isEmpty();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy