Skip to content

Commit

Permalink
fix(export): remove delimiter
Browse files Browse the repository at this point in the history
  • Loading branch information
FalcoSuessgott committed May 10, 2024
1 parent b6b66a1 commit ad9ddfc
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 61 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ secret/ [desc=key/value secret storage] [type=kv2] # engine description & type
│ └── sub=********
├── demo [v=1]
│ └── foo=***
└── sub/
└── sub
├── demo [v=1]
│ ├── demo=***********
│ ├── password=******
Expand Down
32 changes: 16 additions & 16 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ export VKV_PATH="secret"
If everything worked fine, you should be able to run:

```sh
go run main.go
secret/
├── demo
│ └── foo=***
├── sub
go run main.go export -p secret
secret/ [desc=key/value secret storage] [type=kv2]
├── admin [v=1] [key=value]
│ └── sub=********
├── sub/
│ └── demo
│ ├── demo=***********
│ ├── password=******
│ └── user=*****
└── sub/
└── sub2/
└── demo
├── password=*******
├── user=********
└── value=*********
├── demo [v=1]
│ └── foo=***
└── sub
├── demo [v=1]
│ ├── demo=***********
│ ├── password=******
│ └── user=*****
└── sub2
└── demo [v=2] [admin=false key=value]
├── admin=***
├── foo=***
├── password=********
└── user=****
```
6 changes: 3 additions & 3 deletions docs/example_migrate_kvv1_kvv2.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ successfully imported all secrets
result:

kvv2/
└── v1: dev
└── dev [v=2]
├── admin=****

# verify
$> vkv export -p kvv2 --show-values
kvv2/
└── v1: dev
└── dev [v=1]
├── admin=user
└── password=ok
```
Expand All @@ -54,7 +54,7 @@ engine/subpath/
$> vkv export -p engine
engine/
└── subpath/
└── v1: dev
└── dev [v=1]
├── admin=****
└── password=**
```
2 changes: 1 addition & 1 deletion docs/export.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ secret/ [desc=key/value secret storage] [type=kv2]
│ └── sub=********
├── demo [v=1]
│ └── foo=***
└── sub/
└── sub
├── demo [v=1]
│ ├── demo=***********
│ ├── password=******
Expand Down
14 changes: 7 additions & 7 deletions docs/import.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ successfully imported all secrets

result:

copy/
├── v1: admin
copy/ [type=kv2]
├── admin [v=1] [key=value]
│ └── sub=********
├── v1: demo
├── demo [v=1]
│ └── foo=***
└── sub/
├── v1: demo
└── sub
├── demo [v=1]
│ ├── demo=***********
│ ├── password=******
│ └── user=*****
└── sub2
└── v1: demo
└── demo [v=2] [admin=false key=value]
├── admin=***
├── foo=***
├── password=********
Expand All @@ -50,4 +50,4 @@ vkv export -p <source> --show-values -f=yaml | vkv import - -p <destination>
* `<source>` and `<destination>` dont have to be the root path of a secret engine, you also specify subpaths and copy them another secret engine.
* `vkv` will error if the enabled secret engine already exist, you can use `--force` to overwrite the destination engine, if the destination path contains a subpath (`root/sub`), `vkv` will then insert the secrets to that specific directory

**⚠️ `vkv import` can overwrite important secrets, always double check the commmand by using the dry-run mode (`--dry-run`) first**
**⚠️ `vkv import` can overwrite important secrets, always double check the command by using the dry-run mode (`--dry-run`) first**
35 changes: 19 additions & 16 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ secret/ [desc=key/value secret storage] [type=kv2]
│ └── sub=********
├── demo [v=1]
│ └── foo=***
└── sub/
└── sub
├── demo [v=1]
│ ├── demo=***********
│ ├── password=******
Expand Down Expand Up @@ -112,7 +112,7 @@ secret/ [desc=key/value secret storage] [type=kv2]
│ └── sub=********
├── demo [v=1]
│ └── foo=***
└── sub/
└── sub
├── demo [v=1]
│ ├── demo=***********
│ ├── password=******
Expand Down Expand Up @@ -228,19 +228,22 @@ successfully imported all secrets

result:

copy/
├── v1: admin
│ ├── password=********
│ └── username=****
└── db/
├── v1: dev
│ ├── env=***
│ ├── password=************
│ └── username=****
└── v1: prod
├── env=****
├── password=************
└── username=****
copy/ [type=kv2]
├── admin [v=1] [key=value]
│ └── sub=********
├── demo [v=1]
│ └── foo=***
└── sub
├── demo [v=1]
│ ├── demo=***********
│ ├── password=******
│ └── user=*****
└── sub2
└── demo [v=2] [admin=false key=value]
├── admin=***
├── foo=***
├── password=********
└── user=****
```

Or even to another Vault instance:
Expand All @@ -266,7 +269,7 @@ successfully imported all secrets
result:

admin/
└── v1: admin
└── admin [v=1]
├── password=********
└── username=****
```
Expand Down
22 changes: 6 additions & 16 deletions docs/server.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,12 @@ listening on 127.0.0.1:8080
## Client side
```bash
$> curl localhost:8080/export
secret/
├── v1: admin [key=value]
│ └── sub=********
├── v1: demo
│ └── foo=***
└── sub/
├── v1: demo
│ ├── demo=***********
│ ├── password=******
│ └── user=*****
└── sub2
└── v2: demo [admin=false key=value]
├── admin=***
├── foo=***
├── password=********
└── user=****
export admin='key'
export demo='hello world'
export foo='bar'
export password='password'
export sub='password'
export user='user'
```

## Output Format
Expand Down
2 changes: 1 addition & 1 deletion pkg/printer/secret/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (p *Printer) printTree(rootPath, subPath string, m map[string]interface{})

// nolint: cyclop
func (p *Printer) buildTreeName(rootPath, subPath string) string {
name := subPath
name := strings.TrimSuffix(subPath, utils.Delimiter)

subPathParts := strings.Split(strings.TrimSuffix(subPath, utils.Delimiter), utils.Delimiter)
if len(subPathParts) > 1 {
Expand Down

0 comments on commit ad9ddfc

Please sign in to comment.