Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ The secret source for JCasC is configured via environment variables as way to ge
- The environment variable `CASC_VAULT_APPROLE_SECRET` must be present, it token is not used and U/P not used. (Vault AppRole Secret ID.)
- The environment variable `CASC_VAULT_KUBERNETES_ROLE` must be present, if you want to use Kubernetes Service Account. (Vault Kubernetes Role.)
- The environment variable `CASC_VAULT_TOKEN` must be present, if U/P is not used. (Vault token.)
- The environment variable `CASC_VAULT_PATHS` must be present. (Comma separated vault key paths. For example, `secret/jenkins,secret/admin`.)
- The environment variable `CASC_VAULT_PATHS` must be present. (Comma or space separated vault key paths. For example, `secret/jenkins,secret/admin` or `secret/jenkins secret/admin`.)
- The environment variable `CASC_VAULT_URL` must be present. (Vault url, including port number.)
- The environment variable `CASC_VAULT_AGENT_ADDR` is optional. It takes precedence over `CASC_VAULT_URL` and is used for connecting to a Vault Agent. [See this section](#vault-agent)
- The environment variable `CASC_VAULT_MOUNT` is optional. (Vault auth mount. For example, `ldap` or another username & password authentication type, defaults to `userpass`.)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private void configureVault() {
.orElseGet(() -> getVariable(CASC_VAULT_URL));
Optional<String> vaultNamespace = getVariable(CASC_VAULT_NAMESPACE);
Optional<String> vaultPrefixPath = getVariable(CASC_VAULT_PREFIX_PATH);
Optional<String[]> vaultPaths = getCommaSeparatedVariables(CASC_VAULT_PATHS);
Optional<String[]> vaultPaths = getSeparatedVariables(CASC_VAULT_PATHS);
getVariable(CASC_VAULT_PATH).ifPresent(s -> LOGGER
.log(Level.SEVERE, "{0} is deprecated, please switch to {1}",
new Object[]{CASC_VAULT_PATH, CASC_VAULT_PATHS}));
Expand Down Expand Up @@ -227,8 +227,8 @@ private Optional<String> getVariable(String key) {
return Optional.ofNullable(prop.getProperty(key, System.getenv(key)));
}

private Optional<String[]> getCommaSeparatedVariables(String key) {
return getVariable(key).map(str -> str.split(","));
private Optional<String[]> getSeparatedVariables(String key) {
return getVariable(key).map(str -> str.split("\\s*(\\s|,)\\s*"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think ,\s? Will satisfy most use cases for splitting.
The current regex will break paths with spaces.

}

@Override
Expand Down