https://github.com/ngerakines/consul-patch-json
A tool to patch JSON values in consul.
https://github.com/ngerakines/consul-patch-json
consul rust utility
Last synced: 2 months ago
JSON representation
A tool to patch JSON values in consul.
- Host: GitHub
- URL: https://github.com/ngerakines/consul-patch-json
- Owner: ngerakines
- License: mit
- Created: 2023-04-28T12:44:18.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-28T20:02:04.000Z (about 2 years ago)
- Last Synced: 2025-02-04T18:08:48.017Z (3 months ago)
- Topics: consul, rust, utility
- Language: Shell
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# consul-patch-json
A small tool used to patch JSON values in consul.
Usage:
$ consul-patch-json apps/foo/config version='"1.0.0"'
# Installation
$ cargo install consul-patch-json
# Consul Configuration
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`# Examples
# Adding attributes
$ 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"}# Replacing attributes
$ 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"}# Complex attributes
$ 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"}# Reading standard input for single attributes
$ 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"}# JSON Merge Patch (RFC 7396)
$ 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
# JSON Patch (RFC 6902)
$ consul kv put apps/foo/config '{"version": "1.0.0","features":["coffee"]}'
$ cat > patch.json <