Allow specifying a Vault URI.

Closes gh-115.
This commit is contained in:
Mark Paluch
2017-05-27 23:41:06 +02:00
parent 14b6c9ad02
commit 1c9be8b4ad
4 changed files with 14 additions and 1 deletions

View File

@@ -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

View File

@@ -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());

View File

@@ -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;
*/

View File

@@ -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