Merge branch 'master' into 2.0.x

This commit is contained in:
Dave Syer
2017-11-09 15:15:21 +00:00
4 changed files with 57 additions and 6 deletions

View File

@@ -153,9 +153,10 @@ git branch or tag name contains a slash ("/") then the label in the
HTTP URL should be specified with the special string "(\_)" instead (to
avoid ambiguity with other URL paths). For example, if the label is
`foo/bar`, replacing the slash would result in a label that looks like
`foo(_)bar`. Be careful with the brackets in
the URL if you are using a command line client like curl (e.g. escape
them from the shell with quotes '').
`foo(_)bar`. The inclusion of the special string "(\_)" can also be
applied to the `{application}` parameter. Be careful with the brackets
in the URL if you are using a command line client like curl (e.g.
escape them from the shell with quotes '').
===== Placeholders in Git URI
@@ -178,6 +179,23 @@ spring:
or a "one repo per profile" policy using a similar pattern but with
`{profile}`.
Additionally, using the special string "(\_)" within your
`{application}` parameters can enable support for multiple
organizations (for example):
[source,yaml]
----
spring:
cloud:
config:
server:
git:
uri: https://github.com/{application}
----
where `{application}` is provided at request time in the format
"organization(\_)application".
===== Pattern Matching and Multiple Repositories
There is also support for more complex requirements with pattern
@@ -969,7 +987,7 @@ The key argument is mandatory (despite having a `--` prefix).
The Config Server can use a symmetric (shared) key or an asymmetric
one (RSA key pair). The asymmetric choice is superior in terms of
security, but it is often more convenient to use a symmetric key since
it is just a single property value to configure.
it is just a single property value to configure in the `bootstrap.properties`.
To configure a symmetric key you just need to set `encrypt.key` to a
secret String (or use an enviroment variable `ENCRYPT_KEY` to keep it
@@ -1006,7 +1024,7 @@ $ keytool -genkeypair -alias mytestkey -keyalg RSA \
----
Put the `server.jks` file in the classpath (for instance) and then in
your `application.yml` for the Config Server:
your `bootstrap.yml` for the Config Server:
[source,yaml]
----

View File

@@ -32,6 +32,7 @@ import org.springframework.context.annotation.Primary;
* @author Ryan Baxter
*/
@Configuration
@ConditionalOnMissingBean(CompositeEnvironmentRepository.class)
public class CompositeConfiguration {
private List<EnvironmentRepository> environmentRepos = new ArrayList<>();

View File

@@ -61,6 +61,14 @@ public class JdbcEnvironmentRepository implements EnvironmentRepository, Ordered
public JdbcEnvironmentRepository(JdbcTemplate jdbc) {
this.jdbc = jdbc;
}
public void setSql(String sql) {
this.sql = sql;
}
public String getSql() {
return this.sql;
}
@Override
public Environment findOne(String application, String profile, String label) {

View File

@@ -16,10 +16,17 @@
package org.springframework.cloud.config.server.environment;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.junit.Test;
import org.springframework.cloud.config.environment.Environment;
import org.springframework.cloud.config.environment.PropertySource;
import org.springframework.cloud.config.server.config.CompositeConfiguration;
import org.springframework.cloud.config.server.config.ConfigServerHealthIndicator;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.Ordered;
import static org.junit.Assert.assertEquals;
@@ -31,7 +38,7 @@ import static org.mockito.Mockito.mock;
*/
public class CompositeEnvironmentRepositoryTests {
private class TestOrderedEnvironmentRepository implements EnvironmentRepository, SearchPathLocator, Ordered {
private static class TestOrderedEnvironmentRepository implements EnvironmentRepository, SearchPathLocator, Ordered {
private Environment env;
private Locations locations;
@@ -144,4 +151,21 @@ public class CompositeEnvironmentRepositoryTests {
assertEquals(null, multiEnv.getState());
}
@Test
public void overridingCompositeEnvRepo_contextLoads() {
try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) {
context.register(OverrideCompositeConfig.class, CompositeConfiguration.class, ConfigServerHealthIndicator.class);
context.refresh();
}
}
@Configuration
static class OverrideCompositeConfig {
@Bean
@Primary
CompositeEnvironmentRepository customCompositeEnvironmentRepository() {
return new CompositeEnvironmentRepository(Arrays.<EnvironmentRepository>asList(new TestOrderedEnvironmentRepository(1, new Environment("app", "dev"), null)));
}
}
}