MCPcopy
hub / github.com/kubernetes/client-go / getConfigFromFile

Function getConfigFromFile

tools/clientcmd/config.go:471–480  ·  view source on GitHub ↗

getConfigFromFile tries to read a kubeconfig file and if it can't, returns an error. One exception, missing files result in empty configs, not an error.

(filename string)

Source from the content-addressed store, hash-verified

469
470// getConfigFromFile tries to read a kubeconfig file and if it can't, returns an error. One exception, missing files result in empty configs, not an error.
471func getConfigFromFile(filename string) (*clientcmdapi.Config, error) {
472 config, err := LoadFromFile(filename)
473 if err != nil && !os.IsNotExist(err) {
474 return nil, err
475 }
476 if config == nil {
477 config = clientcmdapi.NewConfig()
478 }
479 return config, nil
480}
481
482// 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
483func GetConfigFromFileOrDie(filename string) *clientcmdapi.Config {

Callers 4

ModifyConfigFunction · 0.85
writeCurrentContextFunction · 0.85
writePreferencesFunction · 0.85
GetConfigFromFileOrDieFunction · 0.85

Calls 1

LoadFromFileFunction · 0.70

Tested by

no test coverage detected