@@ -32,6 +32,8 @@ public class VaultConfigSource implements ConfigSource {
32
32
33
33
private static final EnvironmentLoader ENVIRONMENT_LOADER = new EnvironmentLoader ();
34
34
35
+ private static final String PATHS_SEPARATOR = ":" ;
36
+
35
37
private final VaultInvoker vault ;
36
38
private final List <String > secretsPaths ;
37
39
@@ -73,13 +75,17 @@ public static final class Builder {
73
75
private List <String > secretsPaths =
74
76
Optional .ofNullable (ENVIRONMENT_LOADER .loadVariable ("VAULT_SECRETS_PATH" ))
75
77
.or (() -> Optional .ofNullable (ENVIRONMENT_LOADER .loadVariable ("VAULT_SECRETS_PATHS" )))
76
- .map (s -> s .split (":" ))
78
+ .map (s -> s .split (PATHS_SEPARATOR ))
77
79
.map (Arrays ::asList )
78
80
.orElseGet (ArrayList ::new );
79
81
80
82
private Builder () {}
81
83
82
84
/**
85
+ * Appends {@code secretsPath} to {@code secretsPaths}.
86
+ *
87
+ * @param secretsPath secretsPath (may contain value with paths separated by {@code :})
88
+ * @return this builder
83
89
* @deprecated will be removed in future releases without notice, use {@link
84
90
* #addSecretsPath(String...)} or {@link #secretsPaths(Collection)}.
85
91
*/
@@ -89,19 +95,33 @@ public Builder secretsPath(String secretsPath) {
89
95
return this ;
90
96
}
91
97
98
+ /**
99
+ * Appends one or several secretsPath\es to {@code secretsPaths}.
100
+ *
101
+ * @param secretsPath one or several secretsPath\es (each value may contain paths separated by
102
+ * {@code :})
103
+ * @return this builder
104
+ */
92
105
public Builder addSecretsPath (String ... secretsPath ) {
93
106
this .secretsPaths .addAll (toSecretsPaths (Arrays .asList (secretsPath )));
94
107
return this ;
95
108
}
96
109
110
+ /**
111
+ * Setter for {@code secretsPaths}.
112
+ *
113
+ * @param secretsPaths collection of secretsPath\es (each value may contain paths separated by
114
+ * {@code :})
115
+ * @return this builder
116
+ */
97
117
public Builder secretsPaths (Collection <String > secretsPaths ) {
98
118
this .secretsPaths = toSecretsPaths (secretsPaths );
99
119
return this ;
100
120
}
101
121
102
122
private static List <String > toSecretsPaths (Collection <String > secretsPaths ) {
103
123
return secretsPaths .stream ()
104
- .flatMap (s -> Arrays .stream (s .split (":" )))
124
+ .flatMap (s -> Arrays .stream (s .split (PATHS_SEPARATOR )))
105
125
.distinct ()
106
126
.collect (Collectors .toList ());
107
127
}
0 commit comments