use of io.kubernetes.client.openapi.models.V1SecretKeySelector in project heron by twitter.
the class V1Controller method setSecretKeyRefs.
/**
* Adds <code>Secret Key</code> references to a <code>container</code>.
* @param container <code>container</code> to be configured.
*/
private void setSecretKeyRefs(V1Container container) {
final Config config = getConfiguration();
final Map<String, String> podSecretKeyRefs = KubernetesContext.getPodSecretKeyRefs(config);
for (Map.Entry<String, String> secret : podSecretKeyRefs.entrySet()) {
final String[] keyRefParts = secret.getValue().split(":");
if (keyRefParts.length != 2) {
LOG.log(Level.SEVERE, "SecretKeyRef must be in the form name:key. <" + secret.getValue() + ">");
throw new TopologyRuntimeManagementException("SecretKeyRef must be in the form name:key. <" + secret.getValue() + ">");
}
String name = keyRefParts[0];
String key = keyRefParts[1];
final V1EnvVar envVar = new V1EnvVar().name(secret.getKey()).valueFrom(new V1EnvVarSource().secretKeyRef(new V1SecretKeySelector().key(key).name(name)));
container.addEnvItem(envVar);
}
}
Aggregations