consulkv-maven-plugin

A maven plugin to put application configuration into consul

License

License

Categories

Categories

Maven Build Tools
GroupId

GroupId

ch.carve
ArtifactId

ArtifactId

consulkv-maven-plugin
Last Version

Last Version

0.2
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

consulkv-maven-plugin
A maven plugin to put application configuration into consul
Project URL

Project URL

https://github.com/rikcarve/consulkv-maven-plugin
Source Code Management

Source Code Management

https://github.com/rikcarve/consulkv-maven-plugin.git

Download consulkv-maven-plugin

How to add to project

<plugin>
    <groupId>ch.carve</groupId>
    <artifactId>consulkv-maven-plugin</artifactId>
    <version>0.2</version>
</plugin>

Dependencies

compile (5)

Group / Artifact Type Version
com.ecwid.consul : consul-api jar 1.3.0
org.slf4j : slf4j-api jar 1.7.25
org.apache.maven : maven-plugin-api jar 3.5.2
org.apache.maven : maven-project jar 2.2.1
commons-cli : commons-cli jar 1.4

provided (1)

Group / Artifact Type Version
org.apache.maven.plugin-tools : maven-plugin-annotations jar 3.5.1

test (4)

Group / Artifact Type Version
junit : junit jar 4.12
org.mockito : mockito-all jar 1.10.19
com.pszymczyk.consul : embedded-consul jar 1.0.2
org.apache.maven.shared : maven-verifier jar 1.6

Project Modules

There are no modules declared in this project.

Maven Central License: MIT

consulkv-maven-plugin

Put application config into consul from your maven build.

Configuration of an application is often tightly coupled with the feature/version of you code. Keeping them together helps a lot in CI/CD pipelines. As there are many ways putting your config into Consul for production, having a maven plugin simplifies sytsem tests a lot. Put your config into consul in the pre-integration test phase, build and start your docker container and voila, your tests work as if they are a live system :-)

Add plugin

            <plugin>
                <groupId>ch.carve</groupId>
                <artifactId>consulkv-maven-plugin</artifactId>
                <version>0.2</version>
                <configuration>
                    <url>localhost</url>
                    <configDirs>
                        <configDir>src/main/resources/consul</configDir>
                        <configDir>src/main/resources/consul/dev</configDir>
                    </configDirs>
                    <prefix>hello</prefix>
                </configuration>            
            </plugin>

Configuration

  • url: url to consul, e.g. localhost, or 192.168.99.100:8500
  • prefix: prefix for the key, e.g. app --> app/key = value
  • configDirs: one or multiple configDir directories with property files

Link

https://github.com/rikcarve/mp-config-consul

CLI

There's also a cli version which can be used for staging and production deployment in case maven is not option there. You can build it through:

mvn package -Pcli

Usage:

usage: ConsulKvCli
 -configDirs <arg>   comma separated list of directories (absolute)
                     containing property files
 -prefix <arg>       consul key prefix
 -url <arg>          consul url

CLI docker image

In case you can use docker (and I hope you can), there's also a docker image :-)

Build

mvn package docker:build -Pcli

Run

docker run rikcarve/consulkv -configDirs /patch/to/config

Versions

Version
0.2
0.1