Crates.io | consul-patch-json |
lib.rs | consul-patch-json |
version | 0.3.0 |
source | src |
created_at | 2023-04-28 14:45:33.27395 |
updated_at | 2023-04-28 19:45:16.60877 |
description | A tool to patch json values for consul keys |
homepage | https://github.com/ngerakines/consul-patch-json |
repository | https://github.com/ngerakines/consul-patch-json |
max_upload_size | |
id | 851437 |
size | 58,107 |
A small tool used to patch JSON values in consul.
Usage:
$ consul-patch-json apps/foo/config version='"1.0.0"'
$ cargo install consul-patch-json
The following environment variables are used to configure consul interaction:
CONSUL_HTTP_ADDR
CONSUL_CACERT
CONSUL_CAPATH
CONSUL_CLIENT_CERT
CONSUL_CLIENT_KEY
CONSUL_HTTP_TOKEN
CONSUL_HTTP_SSL_VERIFY
$ consul kv put apps/foo/config '{"version": "1.0.0"}'
$ consul-patch-json apps/foo/config description='"My app"'
$ consul kv get apps/foo/config
{"description":"My app","version":"1.0.0"}
$ consul kv put apps/foo/config '{"version": "1.0.0"}'
$ consul-patch-json apps/foo/config version='"1.0.1"'
$ consul kv get apps/foo/config
{"version":"1.0.1"}
$ consul kv put apps/foo/config '{"version": "1.0.0"}'
$ consul-patch-json apps/foo/config features='["metrics"]'
$ consul kv get apps/foo/config
{"features":["metrics"],"version":"1.0.0"}
$ consul kv put apps/foo/config '{"version": "1.0.0"}'
$ echo '["coffee"]' | consul-patch-json apps/foo/config features=--
$ consul kv get apps/foo/config
{"features":["coffee"],"version":"1.0.0"}
$ consul kv put apps/foo/config '{"version": "1.0.0"}'
$ jo features=$(jo -a coffee metrics) | consul-patch-json apps/foo/config --
$ consul kv get apps/foo/config
{"features":["coffee","metrics"],"version":"1.0.0"}
See also: https://datatracker.ietf.org/doc/html/rfc7396
$ consul kv put apps/foo/config '{"version": "1.0.0","features":["coffee"]}'
$ cat > patch.json <<EOF
[
{"op": "test", "path": "/version", "value": "1.0.0"},
{"op": "add","path": "/features/0", "value": "metrics"}
]
EOF
$ cat patch.json | consul-patch-json apps/foo/config --json-patch --
$ consul kv get apps/foo/config
{"features":["coffee","metrics"],"version":"1.0.0"}
See also: https://datatracker.ietf.org/doc/html/rfc6902