/consul-cfg

Commandline utility to convert config formats like TOML, JSON, YAML etc to KV Pairs which can be imported via consul cli.

Primary LanguageGoMIT LicenseMIT

consul-cfg

consul-cfg is a set of utilities for managing app configurations with Consul and Consul template.

Commands

consul-cfg kv - Convert config formats like TOML, JSON, YAML etc to KV Pairs which can be bulk imported via consul cli. Output is same as JSON representation generated by the kv export command.

Get started

Config to KV Pairs

Export config file to Consul KV Pairs format which can be used for Consul bulk import.

# Read config from multiple files
consul-cfg kv --type toml config1.toml config2.toml

# Pipe stdin from other commands
cat config.toml | consul-cfg kv --type toml

# Specify prefix for all keys
cat config.toml | consul-cfg kv --type toml --prefix myconfig/app

Config to consul-template

Convert config file to consul-template (go template). Config values replaced with consul-template keyOrUpdate syntax with default value as current value.

# Read config from multiple files
consul-cfg tmpl --type toml config1.toml config2.toml

# Pipe stdin from other commands
cat config.toml | consul-cfg tmpl --type toml

# Specify prefix for all keys
cat config.toml | consul-cfg tmpl --type toml --prefix myconfig/app

Supported formats

Currently following config formats are supported - toml, yaml, hcl, json and props (JAVA properties).

Install

Install using go install

go install github.com/vividvilla/consul-cfg

Install binary

You can download latest binary from releases based on your OS.

Caveat

Array of maps are not supported by consul KV so it will be encoded as JSON string.