MCPcopy Index your code
hub / github.com/ake-persson/etcdtool

github.com/ake-persson/etcdtool @3.3.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release 3.3.2 ↗ · + Follow
32 symbols 125 edges 11 files 15 documented · 47%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

etcdtool

Export/Import/Edit etcd directory as JSON/YAML/TOML and validate directory using JSON schema.

Use cases

  • Backup/Restore in a format which is not database or version specific.
  • Migration of data from production to testing.
  • Store configuration in Git and use import to populate etcd.
  • Validate directory entries using JSON schema.

Build

git clone https://github.com/mickep76/etcdtool.git
cd etcdtool
make

Build RPM

Make sure you have Docker configured.

git clone https://github.com/mickep76/etcdtool.git
cd etcdtool
make rpm

Install using Homebrew on Mac OS X

brew tap mickep76/funk-gnarge
brew install etcdtool

Update

brew update
brew upgrade --all

Example

Make sure you have Docker configured.

Start etcd:

./init-etcd.sh start
eval "$(./init-etcd.sh env)"

Import some data:

cd examples/host/
etcdtool import /hosts/test1.example.com test1.example.com.json
etcdtool import /hosts/test2.example.com test2.example.com.json

Inspect the content:

etcdtool tree /
etcdtool export /

Validate data with different routes:

etcdtool -d -c etcdtool.toml validate /
etcdtool -d -c etcdtool.toml validate /hosts
etcdtool -d -c etcdtool.toml validate /hosts/test2.example.com
etcdtool -d -c etcdtool.toml validate /hosts/test2.example.com/interfaces
etcdtool -d -c etcdtool.toml validate /hosts/test2.example.com/interfaces/eth0

Import with validation:

etcdtool -d -c etcdtool.toml import -v /hosts/test3.example.com test2.example.com.json

Fix validation error:

etcdtool -d -c etcdtool.toml edit -v -f toml /hosts/test2.example.com
---
    gw = "1.192.168.0.1"
+++
    gw = "192.168.0.1"

Re-validate data:

etcdtool -d -c etcdtool.toml validate /hosts

Caveats

  • etcd doesn't support list's, this is handled by using the index as the key:

JSON Input:

{
    "users": [
        { "username": "jblack", "first_name": "John", "last_name": "Blackbeard" },
        { "username": "ltrier", "first_name": "Lars", "last_name": "Von Trier" }
    ]
}

Result in etcd:

users/0/username: jblack
users/0/first_name: John
users/0/last_name: Blackbeard
users/1/username: ltrier
users/1/first_name: Ludwig
users/1/last_name: Von Treimer

TODO

  • Add detection of format for import based on file type

Core symbols most depended-on inside this repo

fatal
called by 37
src/github.com/mickep76/etcdtool/command/log.go
infof
called by 8
src/github.com/mickep76/etcdtool/command/log.go
loadConfig
called by 6
src/github.com/mickep76/etcdtool/command/config.go
newKeyAPI
called by 5
src/github.com/mickep76/etcdtool/command/connect.go
askYesNo
called by 4
src/github.com/mickep76/etcdtool/command/import_command.go
contextWithCommandTimeout
called by 4
src/github.com/mickep76/etcdtool/command/connect.go
fatalf
called by 4
src/github.com/mickep76/etcdtool/command/log.go
exportFunc
called by 3
src/github.com/mickep76/etcdtool/command/export_command.go

Shape

Function 30
Struct 2

Languages

Go100%

Modules by API surface

src/github.com/mickep76/etcdtool/command/import_command.go6 symbols
src/github.com/mickep76/etcdtool/command/log.go4 symbols
src/github.com/mickep76/etcdtool/command/connect.go4 symbols
src/github.com/mickep76/etcdtool/command/validate_command.go3 symbols
src/github.com/mickep76/etcdtool/command/tree_command.go3 symbols
src/github.com/mickep76/etcdtool/command/export_command.go3 symbols
src/github.com/mickep76/etcdtool/command/edit_command.go3 symbols
src/github.com/mickep76/etcdtool/command/config.go3 symbols
src/github.com/mickep76/etcdtool/command/print_config_command.go2 symbols
src/github.com/mickep76/etcdtool/main.go1 symbols

For agents

$ claude mcp add etcdtool \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact