cli: Fix broken KV import on Windows (#10820)
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
This commit is contained in:
parent
82565fdf55
commit
41b2f08695
|
@ -0,0 +1,3 @@
|
|||
```release-note:bug
|
||||
cli: Fix broken KV import command on Windows.
|
||||
```
|
|
@ -10,7 +10,7 @@ import (
|
|||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"path"
|
||||
|
||||
"github.com/hashicorp/consul/api"
|
||||
"github.com/hashicorp/consul/command/flags"
|
||||
|
@ -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,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue