mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 14:07:14 +00:00
compute configmap/secret key correctly cross-platform
This commit is contained in:
parent
bb4745da99
commit
17e62d91af
@ -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