From 099de660883a54ec16e6dd9bf4b8116834ff6f69 Mon Sep 17 00:00:00 2001
From: Dave Syer
Spring Cloud Config Server supports a single or multiple git -repositories:
+repositories with pattern matching on the application and profile +name. The pattern format is a comma-separated list of +{application}/{profile} names with wildcards (where a pattern
+beginning with a wildcard may need to be quoted). Example:
In the above example, if {application} does not match any of the
-patterns, it will use the default uri defined under
-"spring.cloud.config.server.git.uri". For the "simple" repository, the
-pattern is "simple" (i.e. it only matches one application named "simple").
-The pattern format is a comma-separated list of application names with
-wildcards (a pattern beginning with a wildcard may need to be quoted).
If {application}/{profile} does not match any of the patterns, it
+will use the default uri defined under
+"spring.cloud.config.server.git.uri". In the above example, for the
+"simple" repository, the pattern is simple/* (i.e. it only matches
+one application named "simple" in all profiles). The "local"
+repository matches all application names beginning with "local" in all
+profiles (the /* suffix is added automatically to any pattern that
+doesn’t have a profile matcher).
The pattern property in the repo is actually an array, so you can
+use a YAML array (or [0], [1], etc. suffixes in properties files)
+to bind to multiple patterns. You may need to do this if you are going
+to run apps with multiple profiles. Example:
spring: + cloud: + config: + server: + git: + uri: https://github.com/spring-cloud-samples/config-repo + repos: + development: + pattern: + - */development + - */staging + uri: https://github.com/development/config-repo + staging: + pattern: + - */qa + - */production + uri: https://github.com/staging/config-repo+
|
+ Note
+ |
+
+Spring Cloud will guess that a pattern containing a profile that
+doesn’t end in * implies that you actually want to match a list of
+profiles starting with this pattern (so */staging is a shortcut for
+["*/staging", "*/staging,*"]). This is common where you need to run
+apps in the "development" profile locally but also the "cloud" profile
+remotely, for instance.
+ |
+
Every repository can also optionally store config files in
sub-directories, and patterns to search for those directories can be
specified as searchPaths. For example at the top level:
Instead of using the Environment abstraction (or one of the
+alternative representations of it in YAML or properties format) your
+applications might need generic plain text configuration files,
+tailored to their environment. The Config Server provides these
+through an additional endpoint at /{name}/{profile}/{label}/{path}
+where "name", "profile" and "label" have the same meaning as the
+regular environment endpoint, but "path" is a file name
+(e.g. log.xml). The source files for this endpoint are located in
+the same way as for the environment endpoints: the same search path is
+used as for properties or YAML files, but instead of aggregating all
+matching resources, only the first one to match is returned.
After a resource is located, placeholders in the normal format
+(${…}) are resolved using the effective Environment for the
+application name, profile and label supplied. In this way the resource
+endpoint is tightly integrated with the environment
+endpoints. Example, if you have this layout for a GIT (or SVN)
+repository:
application.yml +nginx.conf+
where nginx.conf looks like this:
server {
+ listen 80;
+ server_name ${nginx.server.name};
+}
+and application.yml like this:
nginx:
+ server:
+ name: example.com
+---
+spring:
+ profiles: development
+nginx:
+ server:
+ name: develop.com
+then the /foo/default/master/nginx.conf resource looks like this:
server {
+ listen 80;
+ server_name example.com;
+}
+and /foo/development/master/nginx.conf like this:
server {
+ listen 80;
+ server_name develop.com;
+}
+|
+ Note
+ |
+
+just like the source files for environment configuration, the
+"profile" is used to resolve the file name, so if you want a
+profile-specific file then /*/development/*/logback.xml will be
+resolved by a file called logback-development.xml (in preference
+to logback.xml).
+ |
+
Many source code repository providers (like Github or Gitlab for -instance) will notify you of changes in a repository through a +
Many source code repository providers (like Github, Gitlab or Bitbucket +for instance) will notify you of changes in a repository through a webhook. You can configure the webhook via the provider’s user interface as a URL and a set of events in which you are interested. For instance @@ -1339,14 +1486,18 @@ is enabled.
might have changed. The change detection can be strategized, but by default it just looks for changes in files that match the application name (e.g. "foo.properties" is targeted at the "foo" application, and -"application.properties" is targeted at all applications). The strategy if you want to override the behaviour isPropertyPathNotificationExtractor which accepts the request headers and body as parameters and returns a list of file paths that changed.
+"application.properties" is targeted at all applications). The strategy
+if you want to override the behaviour is PropertyPathNotificationExtractor
+which accepts the request headers and body as parameters and returns a list
+of file paths that changed.
The default configuration works out of the box with Github or
-Gitlab. In addition to the JSON notifications from Github and Gitlab
-you can trigger a change notification by POSTing to "/monitor" with a
-form-encoded body parameters path={name}. This will broadcast to
-applications matching the "{name}" pattern (can contain wildcards).
The default configuration works out of the box with Github, Gitlab or
+Bitbucket. In addition to the JSON notifications from Github, Gitlab
+or Bitbucket you can trigger a change notification by POSTing to
+"/monitor" with a form-encoded body parameters path={name}. This will
+broadcast to applications matching the "{name}" pattern (can contain
+wildcards).