Search in sources :

Example 1 with ServiceAccountList

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

the class KubernetesServiceAccountsProducer method doList.

protected void doList(Exchange exchange, String operation) throws Exception {
    ServiceAccountList saList = getEndpoint().getKubernetesClient().serviceAccounts().list();
    exchange.getOut().setBody(saList.getItems());
}
Also used : ServiceAccountList(io.fabric8.kubernetes.api.model.ServiceAccountList)

Example 2 with ServiceAccountList

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

the class KubernetesServiceAccountsProducer method doListServiceAccountsByLabels.

protected void doListServiceAccountsByLabels(Exchange exchange, String operation) throws Exception {
    ServiceAccountList saList = null;
    Map<String, String> labels = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_SERVICE_ACCOUNTS_LABELS, Map.class);
    String namespaceName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
    if (!ObjectHelper.isEmpty(namespaceName)) {
        NonNamespaceOperation<ServiceAccount, ServiceAccountList, DoneableServiceAccount, Resource<ServiceAccount, DoneableServiceAccount>> serviceAccounts;
        serviceAccounts = getEndpoint().getKubernetesClient().serviceAccounts().inNamespace(namespaceName);
        for (Map.Entry<String, String> entry : labels.entrySet()) {
            serviceAccounts.withLabel(entry.getKey(), entry.getValue());
        }
        saList = serviceAccounts.list();
    } else {
        MixedOperation<ServiceAccount, ServiceAccountList, DoneableServiceAccount, Resource<ServiceAccount, DoneableServiceAccount>> serviceAccounts;
        serviceAccounts = getEndpoint().getKubernetesClient().serviceAccounts();
        for (Map.Entry<String, String> entry : labels.entrySet()) {
            serviceAccounts.withLabel(entry.getKey(), entry.getValue());
        }
        saList = serviceAccounts.list();
    }
    MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
    exchange.getOut().setBody(saList.getItems());
}
Also used : DoneableServiceAccount(io.fabric8.kubernetes.api.model.DoneableServiceAccount) ServiceAccount(io.fabric8.kubernetes.api.model.ServiceAccount) DoneableServiceAccount(io.fabric8.kubernetes.api.model.DoneableServiceAccount) Resource(io.fabric8.kubernetes.client.dsl.Resource) Map(java.util.Map) ServiceAccountList(io.fabric8.kubernetes.api.model.ServiceAccountList)

Aggregations

ServiceAccountList (io.fabric8.kubernetes.api.model.ServiceAccountList)2 DoneableServiceAccount (io.fabric8.kubernetes.api.model.DoneableServiceAccount)1 ServiceAccount (io.fabric8.kubernetes.api.model.ServiceAccount)1 Resource (io.fabric8.kubernetes.client.dsl.Resource)1 Map (java.util.Map)1