Allow specifying a Vault URI.
Closes gh-115.
This commit is contained in:
@@ -166,6 +166,7 @@ spring.cloud.vault:
|
||||
host: localhost
|
||||
port: 8200
|
||||
scheme: https
|
||||
uri: https://localhost:8200
|
||||
connection-timeout: 5000
|
||||
read-timeout: 15000
|
||||
config:
|
||||
@@ -178,6 +179,7 @@ for SSL certificate validation
|
||||
* `port` sets the Vault port
|
||||
* `scheme` setting the scheme to `http` will use plain HTTP.
|
||||
Supported schemes are `http` and `https`.
|
||||
* `uri` configure the Vault endpoint with an URI. Takes precedence over host/port/scheme configuration
|
||||
* `connection-timeout` sets the connection timeout in milliseconds
|
||||
* `read-timeout` sets the read timeout in milliseconds
|
||||
* `config.order` sets the order for the property source
|
||||
|
||||
@@ -110,6 +110,10 @@ public class VaultBootstrapConfiguration implements InitializingBean {
|
||||
|
||||
private VaultEndpoint getVaultEndpoint(VaultProperties vaultProperties) {
|
||||
|
||||
if (StringUtils.hasText(vaultProperties.getUri())) {
|
||||
return VaultEndpoint.from(URI.create(vaultProperties.getUri()));
|
||||
}
|
||||
|
||||
VaultEndpoint vaultEndpoint = new VaultEndpoint();
|
||||
vaultEndpoint.setHost(vaultProperties.getHost());
|
||||
vaultEndpoint.setPort(vaultProperties.getPort());
|
||||
|
||||
@@ -60,6 +60,11 @@ public class VaultProperties implements EnvironmentAware {
|
||||
*/
|
||||
private String scheme = "https";
|
||||
|
||||
/**
|
||||
* Vault URI. Can be set with scheme, host and port.
|
||||
*/
|
||||
private String uri;
|
||||
|
||||
/**
|
||||
* Connection timeout;
|
||||
*/
|
||||
|
||||
@@ -49,7 +49,9 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringBootTest(classes = VaultConfigTests.TestApplication.class)
|
||||
@SpringBootTest(classes = VaultConfigTests.TestApplication.class, properties = {
|
||||
"spring.cloud.vault.host=foo", "spring.cloud.vault.port=80",
|
||||
"spring.cloud.vault.uri=https://localhost:8200" })
|
||||
public class VaultConfigTests {
|
||||
|
||||
@BeforeClass
|
||||
|
||||
Reference in New Issue
Block a user