Search in sources :

Example 1 with DoneableNamespace

use of io.fabric8.kubernetes.api.model.DoneableNamespace in project camel by apache.

the class KubernetesNamespacesProducer method doListNamespaceByLabel.

protected void doListNamespaceByLabel(Exchange exchange, String operation) {
    Map<String, String> labels = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_LABELS, Map.class);
    if (ObjectHelper.isEmpty(labels)) {
        LOG.error("Get a specific namespace by labels require specify a labels set");
        throw new IllegalArgumentException("Get a specific namespace by labels require specify a labels set");
    }
    NonNamespaceOperation<Namespace, NamespaceList, DoneableNamespace, Resource<Namespace, DoneableNamespace>> namespaces = getEndpoint().getKubernetesClient().namespaces();
    for (Map.Entry<String, String> entry : labels.entrySet()) {
        namespaces.withLabel(entry.getKey(), entry.getValue());
    }
    NamespaceList namespace = namespaces.list();
    MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
    exchange.getOut().setBody(namespace.getItems());
}
Also used : DoneableNamespace(io.fabric8.kubernetes.api.model.DoneableNamespace) Resource(io.fabric8.kubernetes.client.dsl.Resource) Map(java.util.Map) DoneableNamespace(io.fabric8.kubernetes.api.model.DoneableNamespace) Namespace(io.fabric8.kubernetes.api.model.Namespace) NamespaceList(io.fabric8.kubernetes.api.model.NamespaceList)

Aggregations

DoneableNamespace (io.fabric8.kubernetes.api.model.DoneableNamespace)1 Namespace (io.fabric8.kubernetes.api.model.Namespace)1 NamespaceList (io.fabric8.kubernetes.api.model.NamespaceList)1 Resource (io.fabric8.kubernetes.client.dsl.Resource)1 Map (java.util.Map)1