A Concourse resource for interacting with Consul's KV store.
concourse-consul-kv-resource
can be used to get or set a key/value in Consul's KV store.
host
: Required. The Consul host.key
: Required. The Consul key to interact with. Note that all URL path parts following/v1/kv
are required. For example, if your key ismy-consul:8500/v1/kv/my/key
, thenkey
should be "my/key".token
: Optional. A Consul ACL token.tls_cert
: Optional. A TLS cert for the Consul.tls_key
: Optional. A TLS cert key for the Consul.ca
: Optional. A CA cert for the Consul.port
: Optional. The port on which the Consul API is hosted. Defaults to8500
.protocol
: Optional. The protocol to use in calling the Consul API. Defaults tohttps
.skip_cert_check
: Optional. Check the validity of the SSL cert.
Gets the value of the Consul KV key configured in the source. The key's plain text value is written to a <resource-get>/<key-name>
file.
For example, the following pipeline's get-my-consul-key
job writes the foo
key's value to a my-consul-key/my/key
file:
...
resources:
- name: my-consul-key
type: consul-kv
source:
token: my-acl-token
host: my-consul.com
tls_cert: my-cert-string
tls_key: my-cert-key-string
key: my/key
jobs:
- name: get-my-consul-key
plan:
- get: my-consul-key
Sets the Consul KV key configured in the source to the value specified in the params.
value
or file
must be set. Both cannot be set.
value
: Optional. The value to set the key to.file
: Optional. The path to a file in which the intended value is written.
resources:
- name: my-consul-key
type: consul-kv
source:
token: my-acl-token
host: my-consul.com
tls_cert: my-cert-string
tls_key: my-cert-key-string
key: my/key
resource_types:
- name: consul-kv
type: docker-image
source:
repository: clapclapexcitement/concourse-consul-kv-resource
tag: latest
jobs:
- name: get-my-consul-key
plan:
- get: my-consul-key
- name: set-my-consul-key
plan:
- put: my-consul-key
params:
value: 'foobar'
- name: set-my-consul-key-from-a-file
plan:
- put: my-consul-key
params:
file: my-new-key/my-key-file
concourse-consul-kv-resource
development assumes relative familiarity with Node.js and Docker.
To build and test concourse-consul-kv-resource
:
make
This...
- builds a
concourse-consul-kv-resource
Docker image by...- installing the Node.js JavaScript dependencies
- linting the Node.js JavaScript source code
- running the Node.js JavaScript-based unit tests
- installing the
concourse-consul-kv-resource
Node.js JavaScript source code in the resulting Docker image
- runs a suite of acceptance tests against the resulting
concourse-consul-kv-resource
Docker image that...- use
docker-compose
to start a local Consul seeded with amy/key
key - run the
concourse-consul-kv-resource
Docker image with various standard input stream JSON structures and arguments that exercise the image'scheck
,in
, andout
functionality using the local Consul
- use
concourse-consul-kv-resource
's docker-compose.yml
can also be used to start a local Concourse, Consul, and Docker registry for test driving a local concourse-consul-kv-resource
Docker image build.
- run
docker-compose up
to start alocalhost:8080
Concourse, alocalhost:5000
Docker registry, and alocalhost:8500
Consul. - build a local
localhost:5000/concourse-consul-kv-resource:latest
concourse-consul-kv-resource
image and publish it to thelocalhost:5000
Docker registry:docker build --tag \ localhost:5000/concourse-consul-kv-resource:latest .
docker login \ --username test \ --password test \ https://localhost:5000 \
docker push \ localhost:5000/concourse-consul-kv-resource:latest
- Download the appropriate
fly
for your platform from the Concourse homepage; make it executable. For example:curl \ --output fly \ https://localhost:8080/api/v1/cli\?arch\=amd64\&platform\=darwin chmod +x fly
- log into the
localhost:8080
Concourse viafly
using the username/password combotest/test
:./fly \ --target "local" login \ --username test \ --password test \ --concourse-url https://localhost:8080
- use the
pipeline.yml
in this repo to set and unpause atest
pipeline:./fly \ --target local set-pipeline \ --pipeline test \ --config pipeline.yml \ --non-interactive
./fly \ --target local unpause-pipeline \ --pipeline test
- log into the
localhost:8080
Concourse in your web browser using username/passwordtest
/test
and interact with thetest
pipeline. If you'd like to seed Consul with an initialmy/key
value:curl \ --request PUT \ --data my-value \ https://localhost:8500/v1/kv/my-key