mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
Merge pull request #6479 from TamerTas/refactor
Refactor kubectl/cmd/config/getConfigFromFileOrDie
This commit is contained in:
commit
dbbfac3b54
@ -122,14 +122,13 @@ func (o *pathOptions) getStartingConfig() (*clientcmdapi.Config, string, error)
|
|||||||
|
|
||||||
// getConfigFromFileOrDie tries to read a kubeconfig file and if it can't, it calls exit. One exception, missing files result in empty configs, not an exit
|
// getConfigFromFileOrDie tries to read a kubeconfig file and if it can't, it calls exit. One exception, missing files result in empty configs, not an exit
|
||||||
func getConfigFromFileOrDie(filename string) *clientcmdapi.Config {
|
func getConfigFromFileOrDie(filename string) *clientcmdapi.Config {
|
||||||
var err error
|
|
||||||
config, err := clientcmd.LoadFromFile(filename)
|
config, err := clientcmd.LoadFromFile(filename)
|
||||||
if err != nil && !os.IsNotExist(err) {
|
if err != nil && !os.IsNotExist(err) {
|
||||||
glog.FatalDepth(1, err)
|
glog.FatalDepth(1, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if config == nil {
|
if config == nil {
|
||||||
config = clientcmdapi.NewConfig()
|
return clientcmdapi.NewConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
return config
|
return config
|
||||||
|
Loading…
Reference in New Issue
Block a user