use of io.fabric8.kubernetes.api.model.DoneableServiceAccount 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());
}
Aggregations