Coder Social home page Coder Social logo

consulator's Introduction

Consulator

Consulator lets you import and synchronize your KV data from JSON or YAML sources directly to Consul. This allows you to easily version your configuration data, storing it in git or anywhere else you see fit.

CircleCI

Getting Consulator

Docker is the easiest way. You can find it on the Docker Hub.

docker run -it --rm lewispeckover/consulator -help

Alternatively, download a binary from the releases page, or clone the repo and build it yourself.

Running Consulator

Usage: consulator [--version] [--help] <command> [<options>] [<path> ...]

Available commands are:
    dump       Dumps parsed config as JSON suitable for use with consul kv import
    import     Imports data into consul
    sync       Syncs data into consul (like import, but with deletes)
    version    Prints the version

Options:
  -glue string
    	Glue to use for joining array values (default "\n")
  -json
    	Parse stdin as JSON
  -prefix string
    	Key prefix to use for output / Consul import destination
  -tar
    	Parse stdin as a tarball
  -yaml
    	Parse stdin as YAML

Multiple paths (files or directories) may be provided, they are parsed in order. 
This allows you to specify some default values in the first path.
If no paths are provided, stdin is used. In this case, -yaml or -json must be specified.

The usual Consul client environment variables can be used to configure the connection:

 - CONSUL_HTTP_ADDR
 - CONSUL_HTTP_TOKEN
 - CONSUL_HTTP_SSL

Etc. See https://www.consul.io/docs/commands/ for a complete list.

Source data

JSON, YAML, and plain text sources are supported. Data can be loaded from files, piped directly to standard input, or provided as a tarball. Note that Consul KV values are only allowed to be strings, so non-string values are converted where possible. Most significantly, array values are joined with a configurable glue string (default: "\n").

Given a myapp.yaml:

tags:
 - production
 - web

or equivalent myapp.json:

{ 
 "tags": ["production", "web"]
}

Running consulator import -glue=, myapp.yaml will result in a Consul key tags with the value production,web

When a directory is specified as the source, it is scanned for files with extensions .json, .yaml or .yml. Subdirectories and filenames are used to build key prefixes.

Suppose that the above file is located at /etc/consuldata/config/myapp.yaml. When consulator is executed as consulator import -glue=, /etc/consuldata, it will result in a Consul key config/myapp/tags with value production,web.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.