myENA / consul-backinator

Command line Consul backup and restore utility supporting KVs, ACLs and Queries
Mozilla Public License 2.0
226 stars 22 forks source link

transform does not match absolute key path #3

Closed vkhatri closed 8 years ago

vkhatri commented 8 years ago

Hello! This tool has saved me a lot of overhead, thank you for sharing this amazing tool.

I am having an issue with transform.

Currently transform matches the pattern anywhere in the path, e.g. --transform foo/x/y,foo/x/z will transform below mentioned key path:

a/b/c/foo/x/y/a/b/c -> a/b/c/foo/x/z/a/b/c
foo/x/y -> foo/x/z

But, i only intend to transform the foo/x/y to foo/x/z (which matches absolute path from left to right).

I know i can take the backup with prefix foo/x/y and then transform with the new key path as prefix matches absolute path from left to right. If this is the recommended way, i can submit a PR with this info for the transform option.

aaronhurt commented 8 years ago

The path transformation is actually just an implementation of strings.Replacer which takes value pairs as input. So you can actually specify multiple transforms with one option --transform="foo/x/y,foo/x/z,bar/x/y,bar/x/z"

I'll update the documentation to be more explicitly state that the transform option operates/matches anywhere within the path. To your specific use case you can also just fully qualify your transformations from the root, e.g. --transform="a/b/c/foo/x/y,a/b/c/foo/x/z" which will have your desired affect without having to add any extra steps or prefix options.