MCPcopy Create free account
hub / github.com/containers/image / loadFromFile

Function loadFromFile

openshift/openshift-copies.go:600–635  ·  view source on GitHub ↗

loadFromFile is a modified copy of k8s.io/kubernetes/pkg/client/unversioned/clientcmd.LoadFromFile LoadFromFile takes a filename and deserializes the contents into Config object

(filename string)

Source from the content-addressed store, hash-verified

598// loadFromFile is a modified copy of k8s.io/kubernetes/pkg/client/unversioned/clientcmd.LoadFromFile
599// LoadFromFile takes a filename and deserializes the contents into Config object
600func loadFromFile(filename string) (*clientcmdConfig, error) {
601 kubeconfigBytes, err := os.ReadFile(filename)
602 if err != nil {
603 return nil, err
604 }
605 config, err := load(kubeconfigBytes)
606 if err != nil {
607 return nil, err
608 }
609
610 // set LocationOfOrigin on every Cluster, User, and Context
611 for key, obj := range config.AuthInfos {
612 obj.LocationOfOrigin = filename
613 config.AuthInfos[key] = obj
614 }
615 for key, obj := range config.Clusters {
616 obj.LocationOfOrigin = filename
617 config.Clusters[key] = obj
618 }
619 for key, obj := range config.Contexts {
620 obj.LocationOfOrigin = filename
621 config.Contexts[key] = obj
622 }
623
624 if config.AuthInfos == nil {
625 config.AuthInfos = map[string]*clientcmdAuthInfo{}
626 }
627 if config.Clusters == nil {
628 config.Clusters = map[string]*clientcmdCluster{}
629 }
630 if config.Contexts == nil {
631 config.Contexts = map[string]*clientcmdContext{}
632 }
633
634 return config, nil
635}
636
637// load is a modified copy of k8s.io/kubernetes/pkg/client/unversioned/clientcmd.Load
638// Load takes a byte slice and deserializes the contents into Config object.

Callers 1

LoadMethod · 0.85

Calls 1

loadFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…