
cd.connect.initializers.vault.VaultKey Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of connect-vault-initializer Show documentation
Show all versions of connect-vault-initializer Show documentation
System properties tagged with [K8S-VAULT] as a prefix will get that stripped and
the rest used as a key to ask on startup for values.
The newest version!
package cd.connect.initializers.vault;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* Created by Richard Vowles on 6/03/18.
*/
public class VaultKey {
// I'm with Steve Yegge on this one
public final String systemPropertyFieldName;
public final String vaultKeyName;
public final boolean treatAsMap;
public Map subPropertyFieldNames = new HashMap<>();
public String getSystemPropertyFieldName() {
return systemPropertyFieldName;
}
public String getVaultKeyName() {
return vaultKeyName;
}
public VaultKey(String systemPropertyFieldName, String vaultKeyName, boolean treatAsMap) {
this.systemPropertyFieldName = systemPropertyFieldName;
this.vaultKeyName = split(vaultKeyName);
this.treatAsMap = treatAsMap;
}
private String split(String systemPropertyFieldName) {
String[] parts = systemPropertyFieldName.split("#");
if (parts.length > 1) {
List subParts = Arrays.stream(parts[1].split(","))
.map(String::trim)
.filter(s -> s.length() > 0)
.collect(Collectors.toList());
// check to see if they are name=value or name:value pairs, if so, store them as such
subParts.forEach(subPart -> {
String[] mapped = subPart.split("[:=]");
if (mapped.length == 2) {
subPropertyFieldNames.put(mapped[0], mapped[1]);
} else {
subPropertyFieldNames.put(mapped[0], mapped[0]);
}
});
}
return parts[0];
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy