mirror of
https://github.com/kubernetes/client-go.git
synced 2025-06-29 00:17:46 +00:00
Cleanup currentMigrationRules
1. Use filepath for filename manipulations 2. Restructure method logic Kubernetes-commit: 11800147f51e85b9a4fb7eb2654cae3ded9d8cf0
This commit is contained in:
parent
62f63bbbfe
commit
277eea62aa
@ -21,7 +21,6 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
goruntime "runtime"
|
goruntime "runtime"
|
||||||
@ -48,24 +47,24 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
RecommendedConfigDir = path.Join(homedir.HomeDir(), RecommendedHomeDir)
|
RecommendedConfigDir = filepath.Join(homedir.HomeDir(), RecommendedHomeDir)
|
||||||
RecommendedHomeFile = path.Join(RecommendedConfigDir, RecommendedFileName)
|
RecommendedHomeFile = filepath.Join(RecommendedConfigDir, RecommendedFileName)
|
||||||
RecommendedSchemaFile = path.Join(RecommendedConfigDir, RecommendedSchemaName)
|
RecommendedSchemaFile = filepath.Join(RecommendedConfigDir, RecommendedSchemaName)
|
||||||
)
|
)
|
||||||
|
|
||||||
// currentMigrationRules returns a map that holds the history of recommended home directories used in previous versions.
|
// currentMigrationRules returns a map that holds the history of recommended home directories used in previous versions.
|
||||||
// Any future changes to RecommendedHomeFile and related are expected to add a migration rule here, in order to make
|
// Any future changes to RecommendedHomeFile and related are expected to add a migration rule here, in order to make
|
||||||
// sure existing config files are migrated to their new locations properly.
|
// sure existing config files are migrated to their new locations properly.
|
||||||
func currentMigrationRules() map[string]string {
|
func currentMigrationRules() map[string]string {
|
||||||
oldRecommendedHomeFile := path.Join(os.Getenv("HOME"), "/.kube/.kubeconfig")
|
var oldRecommendedHomeFileName string
|
||||||
oldRecommendedWindowsHomeFile := path.Join(os.Getenv("HOME"), RecommendedHomeDir, RecommendedFileName)
|
|
||||||
|
|
||||||
migrationRules := map[string]string{}
|
|
||||||
migrationRules[RecommendedHomeFile] = oldRecommendedHomeFile
|
|
||||||
if goruntime.GOOS == "windows" {
|
if goruntime.GOOS == "windows" {
|
||||||
migrationRules[RecommendedHomeFile] = oldRecommendedWindowsHomeFile
|
oldRecommendedHomeFileName = RecommendedFileName
|
||||||
|
} else {
|
||||||
|
oldRecommendedHomeFileName = ".kubeconfig"
|
||||||
|
}
|
||||||
|
return map[string]string{
|
||||||
|
RecommendedHomeFile: filepath.Join(os.Getenv("HOME"), RecommendedHomeDir, oldRecommendedHomeFileName),
|
||||||
}
|
}
|
||||||
return migrationRules
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ClientConfigLoader interface {
|
type ClientConfigLoader interface {
|
||||||
|
Loading…
Reference in New Issue
Block a user