-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cli: Add KV export
and import
#2633
Conversation
b1ef59b
to
44bba65
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted a few minor things, otherwise LGTM.
|
||
` + apiOptsText + ` | ||
|
||
KV Get Options: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should say KV Export Options:
@@ -81,7 +81,7 @@ KV Get Options: | |||
|
|||
func (c *KVGetCommand) Run(args []string) int { | |||
cmdFlags := flag.NewFlagSet("get", flag.ContinueOnError) | |||
cmdFlags.Usage = func() { c.Ui.Output(c.Help()) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like an unrelated change, but if this is implied by not setting .Usage
then makes sense and is fine.
|
||
` + apiOptsText + ` | ||
|
||
KV Get Options: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is stale, too.
|
||
Or it can be read from stdin using the "-" symbol: | ||
|
||
$ cat filename.json | consul kv put config/program/license - |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs an update.
|
||
data := args[0] | ||
|
||
switch data[0] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this crash if you pass an empty quoted string in as the first arg?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likely yes - this is copied from kv put
so that probably has the same behaviour. I'll update.
if strings.TrimSpace(string(pair.Value)) != "bar" { | ||
t.Fatalf("bad: expected: bar, got %s", pair.Value) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might as well check foo/a
as well.
@@ -81,7 +81,7 @@ KV Get Options: | |||
|
|||
func (c *KVGetCommand) Run(args []string) int { | |||
cmdFlags := flag.NewFlagSet("get", flag.ContinueOnError) | |||
cmdFlags.Usage = func() { c.Ui.Output(c.Help()) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this intended? Maybe I missed it but I didn't see this move elsewhere.
69fe814
to
f26d387
Compare
I've fixed up most of the review comments, probably also need to look at |
Latest changes look good to merge. I think it's fine if you want to fix the empty arg issue here for |
This commit adds two new commands to the Consul KV CLI, which export and import a JSON formatted representation of the Consul KV tree. It is useful to migrate parts of the KV tree between unrelated Consul clusters, and could also be used for initial data population of the KV store.
f26d387
to
d4e8c8a
Compare
This commit adds two new commands to the Consul KV CLI, which export and import a JSON formatted representation of the Consul KV tree. It is useful to migrate parts of the KV tree between unrelated Consul clusters, and could also be used for initial data population of the KV store.