Skip to content

Instantly share code, notes, and snippets.

@MaxymVlasov
Created November 28, 2017 14:31
Show Gist options
  • Save MaxymVlasov/fb9a1e536c25921a1a7ef2397183c348 to your computer and use it in GitHub Desktop.
Save MaxymVlasov/fb9a1e536c25921a1a7ef2397183c348 to your computer and use it in GitHub Desktop.

If you need to get all the keys from the branch of Consul and put in .ini file:

[service]
{{range tree "path/to/service"}}{{.Key | replaceAll "/" "." }}={{.Value}} 
  1. tree get all keys by path.
  2. range get access to {{.Key}} and {{.Value}} constructions.
  3. {{.Key | replaceAll "/" "." }} - replace all / in path to nested keys in dir (path/to/service) to ..

For expamle,

path/to/service/key
path/to/service/dir/key
path/to/service/dir/dir/key

wil be replace to

[service]
key=foo
dir.key=bar
dir.dir.key=baz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment