Search in sources :

Example 1 with DoneableBuildConfig

use of io.fabric8.openshift.api.model.DoneableBuildConfig in project camel by apache.

the class KubernetesBuildConfigsProducer method doListBuildConfigsByLabels.

protected void doListBuildConfigsByLabels(Exchange exchange, String operation) throws Exception {
    BuildConfigList buildConfigsList = null;
    Map<String, String> labels = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_BUILD_CONFIGS_LABELS, Map.class);
    String namespaceName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
    if (!ObjectHelper.isEmpty(namespaceName)) {
        NonNamespaceOperation<BuildConfig, BuildConfigList, DoneableBuildConfig, BuildConfigResource<BuildConfig, DoneableBuildConfig, Void, Build>> buildConfigs;
        buildConfigs = getEndpoint().getKubernetesClient().adapt(OpenShiftClient.class).buildConfigs().inNamespace(namespaceName);
        for (Map.Entry<String, String> entry : labels.entrySet()) {
            buildConfigs.withLabel(entry.getKey(), entry.getValue());
        }
        buildConfigsList = buildConfigs.list();
    } else {
        MixedOperation<BuildConfig, BuildConfigList, DoneableBuildConfig, BuildConfigResource<BuildConfig, DoneableBuildConfig, Void, Build>> buildConfigs;
        buildConfigs = getEndpoint().getKubernetesClient().adapt(OpenShiftClient.class).buildConfigs();
        for (Map.Entry<String, String> entry : labels.entrySet()) {
            buildConfigs.withLabel(entry.getKey(), entry.getValue());
        }
        buildConfigsList = buildConfigs.list();
    }
    MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
    exchange.getOut().setBody(buildConfigsList.getItems());
}
Also used : OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) DoneableBuildConfig(io.fabric8.openshift.api.model.DoneableBuildConfig) BuildConfig(io.fabric8.openshift.api.model.BuildConfig) DoneableBuildConfig(io.fabric8.openshift.api.model.DoneableBuildConfig) BuildConfigResource(io.fabric8.openshift.client.dsl.BuildConfigResource) Map(java.util.Map) BuildConfigList(io.fabric8.openshift.api.model.BuildConfigList)

Aggregations

BuildConfig (io.fabric8.openshift.api.model.BuildConfig)1 BuildConfigList (io.fabric8.openshift.api.model.BuildConfigList)1 DoneableBuildConfig (io.fabric8.openshift.api.model.DoneableBuildConfig)1 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)1 BuildConfigResource (io.fabric8.openshift.client.dsl.BuildConfigResource)1 Map (java.util.Map)1