diff --git a/README.adoc b/README.adoc index 50b8916f..b951a5eb 100644 --- a/README.adoc +++ b/README.adoc @@ -180,6 +180,8 @@ spring.cloud.vault: scheme: https connection-timeout: 5000 read-timeout: 15000 + config: + order: -10 ---- * `host` sets the hostname of the Vault host. The host name will be used diff --git a/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/VaultPropertySourceLocator.java b/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/VaultPropertySourceLocator.java index 7e83765f..4c390334 100644 --- a/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/VaultPropertySourceLocator.java +++ b/spring-cloud-vault-config/src/main/java/org/springframework/cloud/vault/config/VaultPropertySourceLocator.java @@ -29,6 +29,7 @@ import org.springframework.core.env.CompositePropertySource; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.Environment; import org.springframework.core.env.PropertySource; +import org.springframework.core.PriorityOrdered; import org.springframework.util.Assert; import org.springframework.util.StringUtils; @@ -40,7 +41,7 @@ import static org.springframework.cloud.vault.config.SecureBackendAccessors.*; * @author Spencer Gibb * @author Mark Paluch */ -class VaultPropertySourceLocator implements PropertySourceLocator { +class VaultPropertySourceLocator implements PropertySourceLocator, PriorityOrdered { private final VaultConfigOperations operations; private final VaultProperties properties; @@ -85,6 +86,11 @@ class VaultPropertySourceLocator implements PropertySourceLocator { return null; } + @Override + public int getOrder() { + return properties.getConfig().getOrder(); + } + private List buildContexts(ConfigurableEnvironment env) { String appName = env.getProperty("spring.application.name"); diff --git a/spring-cloud-vault-core/src/main/java/org/springframework/cloud/vault/VaultProperties.java b/spring-cloud-vault-core/src/main/java/org/springframework/cloud/vault/VaultProperties.java index 5f885dc0..88462a1c 100644 --- a/spring-cloud-vault-core/src/main/java/org/springframework/cloud/vault/VaultProperties.java +++ b/spring-cloud-vault-core/src/main/java/org/springframework/cloud/vault/VaultProperties.java @@ -78,6 +78,8 @@ public class VaultProperties { private Ssl ssl = new Ssl(); + private Config config = new Config(); + /** * Application name for AppId authentication. */ @@ -177,6 +179,15 @@ public class VaultProperties { private String certAuthPath = "cert"; } + @Data + public static class Config { + /** + * Used to force a PropertySourceLocator ordering. + * This is useful to use Vault as an override on consul properties; + */ + private int order = 0; + } + public enum AuthenticationMethod { TOKEN, APPID, AWS_EC2, CERT }