use of io.fabric8.kubernetes.api.model.DoneableSecret in project camel by apache.
the class KubernetesSecretsProducer method doListSecretsByLabels.
protected void doListSecretsByLabels(Exchange exchange, String operation) throws Exception {
SecretList secretsList = null;
Map<String, String> labels = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_SECRETS_LABELS, Map.class);
String namespaceName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
if (!ObjectHelper.isEmpty(namespaceName)) {
NonNamespaceOperation<Secret, SecretList, DoneableSecret, Resource<Secret, DoneableSecret>> secrets;
secrets = getEndpoint().getKubernetesClient().secrets().inNamespace(namespaceName);
for (Map.Entry<String, String> entry : labels.entrySet()) {
secrets.withLabel(entry.getKey(), entry.getValue());
}
secretsList = secrets.list();
} else {
MixedOperation<Secret, SecretList, DoneableSecret, Resource<Secret, DoneableSecret>> secrets;
secrets = getEndpoint().getKubernetesClient().secrets();
for (Map.Entry<String, String> entry : labels.entrySet()) {
secrets.withLabel(entry.getKey(), entry.getValue());
}
secretsList = secrets.list();
}
MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
exchange.getOut().setBody(secretsList.getItems());
}
Aggregations