Search in sources :

Example 1 with SecretList

use of io.fabric8.kubernetes.api.model.SecretList 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());
}
Also used : Secret(io.fabric8.kubernetes.api.model.Secret) DoneableSecret(io.fabric8.kubernetes.api.model.DoneableSecret) SecretList(io.fabric8.kubernetes.api.model.SecretList) Resource(io.fabric8.kubernetes.client.dsl.Resource) Map(java.util.Map) DoneableSecret(io.fabric8.kubernetes.api.model.DoneableSecret)

Example 2 with SecretList

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

the class KubernetesSecretsProducer method doList.

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

Aggregations

SecretList (io.fabric8.kubernetes.api.model.SecretList)2 DoneableSecret (io.fabric8.kubernetes.api.model.DoneableSecret)1 Secret (io.fabric8.kubernetes.api.model.Secret)1 Resource (io.fabric8.kubernetes.client.dsl.Resource)1 Map (java.util.Map)1