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

Method getContext

tools/clientcmd/client_config.go:408–421  ·  view source on GitHub ↗

getContext returns the clientcmdapi.Context, or an error if a required context is not found.

()

Source from the content-addressed store, hash-verified

406
407// getContext returns the clientcmdapi.Context, or an error if a required context is not found.
408func (config *DirectClientConfig) getContext() (clientcmdapi.Context, error) {
409 contexts := config.config.Contexts
410 contextName, required := config.getContextName()
411
412 mergedContext := clientcmdapi.NewContext()
413 if configContext, exists := contexts[contextName]; exists {
414 mergo.MergeWithOverwrite(mergedContext, configContext)
415 } else if required {
416 return clientcmdapi.Context{}, fmt.Errorf("context %q does not exist", contextName)
417 }
418 mergo.MergeWithOverwrite(mergedContext, config.overrides.Context)
419
420 return *mergedContext, nil
421}
422
423// getAuthInfo returns the clientcmdapi.AuthInfo, or an error if a required auth info is not found.
424func (config *DirectClientConfig) getAuthInfo() (clientcmdapi.AuthInfo, error) {

Callers 4

ClientConfigMethod · 0.95
NamespaceMethod · 0.95
getAuthInfoNameMethod · 0.95
getClusterNameMethod · 0.95

Calls 2

getContextNameMethod · 0.95
ErrorfMethod · 0.65

Tested by

no test coverage detected