Git Configuration Store
The Git Configuration Store is an extension to the Vert.x Configuration Retriever to retrieve configuration from a Git repository.
Using the Git Configuration Store
To use the Git Configuration, add the following dependency to the dependencies section of your build descriptor:
-
Maven (in your
pom.xml):
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-config-git</artifactId>
<version>4.2.0.Beta1</version>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-config</artifactId>
<version>4.2.0.Beta1</version>
</dependency>
-
Gradle (in your
build.gradlefile):
compile 'io.vertx:vertx-config:4.2.0.Beta1'
compile 'io.vertx:vertx-config-git:4.2.0.Beta1'
Configuring the store
Once added to your classpath or dependencies, you need to configure the
ConfigRetriever to use this store:
ConfigStoreOptions git = new ConfigStoreOptions()
.setType("git")
.setConfig(new JsonObject()
.put("url", "https://github.com/cescoffier/vertx-config-test.git")
.put("path", "local")
.put("filesets",
new JsonArray().add(new JsonObject().put("pattern", "*.json"))));
ConfigRetriever retriever = ConfigRetriever.create(vertx,
new ConfigRetrieverOptions().addStore(git));
The configuration requires:
-
the
urlof the repository -
the
pathwhere the repository is cloned (local directory) -
the
userfor private repository (no authentication by default) -
the
passwordof the user -
the
idRsaKeyPathfor private repository and requires ssh uri -
at least
filesetindicating the set of files to read (same behavior as the directory configuration store).
You can also configure the branch (master by default) to use and the name of the
remote repository (origin by default).
How does it works
If the local path does not exist, the configuration store clones the repository into
this directory. Then it reads the file matching the different file sets.
It the local path exist, it tried to update it (it switches branch if needed)). If the
update failed the configuration retrieval fails.
Periodically, the repositories is updated to check if the configuration has been updated.