io.strimzi.kafka.KubernetesSecretConfigProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kafka-kubernetes-config-provider Show documentation
Show all versions of kafka-kubernetes-config-provider Show documentation
Apache Kafka configuration provider for reading data from Kubernetes Secrets and Config Maps
/*
* Copyright Strimzi authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.strimzi.kafka;
import io.fabric8.kubernetes.api.model.Secret;
import io.fabric8.kubernetes.api.model.SecretList;
import io.fabric8.kubernetes.client.dsl.MixedOperation;
import io.fabric8.kubernetes.client.dsl.Resource;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
/**
* Apache Kafka configuration provider to load configuration from Kubernetes Secrets
*/
public final class KubernetesSecretConfigProvider extends AbstractKubernetesConfigProvider> {
/**
* Calls the constructor from the super-class with the kind parameter set to Secret
*/
public KubernetesSecretConfigProvider() {
super("Secret");
}
@Override
protected MixedOperation> operator() {
return client.secrets();
}
@Override
protected Map valuesFromResource(Secret resource) {
Map encodedValues = resource.getData();
Map values = new HashMap<>(encodedValues.size());
for (Map.Entry entry : encodedValues.entrySet()) {
values.put(entry.getKey(), new String(Base64.getDecoder().decode(entry.getValue()), StandardCharsets.UTF_8));
}
return values;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy