Skip to content

Commit

Permalink
cli: Fix broken KV import on Windows (#10820)
Browse files Browse the repository at this point in the history
Consul 1.10 (PR #9792) introduced the ability to specify a prefix when
importing KV's. This however introduced a regression on Windows
systems which breaks `kv import`. The key name is joined with
specified`-prefix` using `filepath.Join()` which uses a forward slash
(/) to delimit values on Unix-based systems, and a backslash (\) to
delimit values on Windows – the latter of which is incompatible with
Consul KV paths.

This commit replaces filepath.Join() with path.Join() which uses a
forward slash as the delimiter, providing consistent key join behavior
across supported operating systems.

Fixes #10583
  • Loading branch information
blake authored and hc-github-team-consul-core committed Aug 10, 2021
1 parent b62f9a4 commit b01fa1f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .changelog/10820.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
cli: Fix broken KV import command on Windows.
```
4 changes: 2 additions & 2 deletions command/kv/imp/kv_import.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"io"
"io/ioutil"
"os"
"path/filepath"
"path"

"github.com/hashicorp/consul/api"
"github.com/hashicorp/consul/command/flags"
Expand Down Expand Up @@ -79,7 +79,7 @@ func (c *cmd) Run(args []string) int {
}

pair := &api.KVPair{
Key: filepath.Join(c.prefix, entry.Key),
Key: path.Join(c.prefix, entry.Key),
Flags: entry.Flags,
Value: value,
}
Expand Down

0 comments on commit b01fa1f

Please sign in to comment.