mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Merge pull request #63439 from liggitt/from-file
Automatic merge from submit-queue (batch tested with PRs 63315, 63383, 63318, 63439). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. compute configmap/secret key correctly cross-platform fixes #61710 ```release-note `kubectl create [secret | configmap] --from-file` now works on Windows with fully-qualified paths ```
This commit is contained in:
commit
5f5d4fd450
@ -21,6 +21,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path"
|
"path"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -60,7 +61,7 @@ func ParseFileSource(source string) (keyName, filePath string, err error) {
|
|||||||
numSeparators := strings.Count(source, "=")
|
numSeparators := strings.Count(source, "=")
|
||||||
switch {
|
switch {
|
||||||
case numSeparators == 0:
|
case numSeparators == 0:
|
||||||
return path.Base(source), source, nil
|
return path.Base(filepath.ToSlash(source)), source, nil
|
||||||
case numSeparators == 1 && strings.HasPrefix(source, "="):
|
case numSeparators == 1 && strings.HasPrefix(source, "="):
|
||||||
return "", "", fmt.Errorf("key name for file path %v missing.", strings.TrimPrefix(source, "="))
|
return "", "", fmt.Errorf("key name for file path %v missing.", strings.TrimPrefix(source, "="))
|
||||||
case numSeparators == 1 && strings.HasSuffix(source, "="):
|
case numSeparators == 1 && strings.HasSuffix(source, "="):
|
||||||
|
Loading…
Reference in New Issue
Block a user