Add fetch() to existing repository

This commit is contained in:
Dave Syer
2014-06-15 10:37:13 +01:00
parent 7c50e413eb
commit d8c51cec81
2 changed files with 29 additions and 23 deletions

View File

@@ -1,15 +1,15 @@
Spring Platform Config provides server and client-side support for
externalized configuration in a distributed system. With the Config
Server you have a central place to manage external properties for the
applications across all environments. The concepts on both sides map
identically to the Spring `Environment` and `PropertySource`
abstractions, so they fit very well with Spring applications. As an
application moves through the deployment pipeline from dev to test and
into production you can manage the configuration that needs to change
Server you have a central place to manage external properties for
applications across all environments. The concepts on both client and
server map identically to the Spring `Environment` and
`PropertySource` abstractions, so they fit very well with Spring
applications. As an application moves through the deployment pipeline
from dev to test and into production you can manage the configuration
between those environments and be certain that applications have
everything they need to run when they migrate. The default
implementation of the server repository strategy uses git as a storage
backend so it easily supports labelled versions of configurations.
implementation of the server storage uses git so it easily supports
labelled versions of configuration environments.
## Quick Start
@@ -33,29 +33,31 @@ $ curl localhost:8888/foo/development
```
The default strategy for locating property sources is to clone a git
repository (at "spring.platform.config.server.uri") and use it to initialize
a `SpringApplication`. The application's `Environment` is used to
enumerate property sources. The service has resources in the form:
repository (at "spring.platform.config.server.uri") and use it to
initialize a mini `SpringApplication`. The mini-application's
`Environment` is used to enumerate property sources and publish them
via a JSON endpoint. The service has resources in the form:
```
/{name}/{profile}[/{label}]
/{application}/{profile}[/{label}]
```
where the "name" is used as the config name in the `SpringApplication`
(i.e. what is normally "application" in a regular Spring Boot app),
"profile" is an active profile (or comma-separated list of
properties), and "label" is an optional git label (defaults to
where the "application" is injected as the "spring.config.name" in the
`SpringApplication` (i.e. what is normally "application" in a regular
Spring Boot app), "profile" is an active profile (or comma-separated
list of properties), and "label" is an optional git label (defaults to
"master").
### Client Side Usage
Build a client (e.g. see the test cases for the config-client) as a
Spring Boot application that depends on spring-platform-config-client.
To use these features in an application, just build it as a Spring
Boot application that depends on spring-platform-config-client
(e.g. see the test cases for the config-client, or the sample app).
When it runs it will pick up the external configuration from the
default local config server on port 8888 if it is running. To modify
the startup behaviour you can change the location of the server using
`bootstrap.properties` (like `application.properties` but for the
bootstrap phase of an application context), e.g.
the startup behaviour you can change the location of the config server
using `bootstrap.properties` (like `application.properties` but for
the bootstrap phase of an application context), e.g.
```
spring.platform.config.uri: http://myconfigserver.com
@@ -70,6 +72,9 @@ mechanisms (for instance "mvn spring-boot:run"). When it runs it will
look for the config server on "http://localhost:8888" by default, so
you could run the server as well to see it all working together.
The sample has a tets case where the config server is also started in
The sample has a test case where the config server is also started in
the same JVM (with a different port), and the test asserts that an
environment property from the git configuration repo is present.
environment property from the git configuration repo is present. To
change the location of the config server just set
"spring.platform.config.uri" in "bootstrap.yml" (or via System
properties etc.).

View File

@@ -79,6 +79,7 @@ public class JGitEnvironmentRepository implements EnvironmentRepository {
Git git;
if (new File(basedir, ".git").exists()) {
git = Git.open(basedir);
git.fetch().call();
} else {
if (basedir.exists()) {
try {