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

Function Load

tools/clientcmd/loader.go:390–401  ·  view source on GitHub ↗

Load takes a byte slice and deserializes the contents into Config object. Encapsulates deserialization without assuming the source is a file.

(data []byte)

Source from the content-addressed store, hash-verified

388// Load takes a byte slice and deserializes the contents into Config object.
389// Encapsulates deserialization without assuming the source is a file.
390func Load(data []byte) (*clientcmdapi.Config, error) {
391 config := clientcmdapi.NewConfig()
392 // if there's no data in a file, return the default object instead of failing (DecodeInto reject empty input)
393 if len(data) == 0 {
394 return config, nil
395 }
396 decoded, _, err := clientcmdlatest.Codec.Decode(data, &schema.GroupVersionKind{Version: clientcmdlatest.Version, Kind: "Config"}, config)
397 if err != nil {
398 return nil, err
399 }
400 return decoded.(*clientcmdapi.Config), nil
401}
402
403// WriteToFile serializes the config to yaml and writes it out to a file. If not present, it creates the file with the mode 0600. If it is present
404// it stomps the contents

Callers 2

LoadFromFileFunction · 0.85
NewClientConfigFromBytesFunction · 0.85

Calls 1

DecodeMethod · 0.45

Tested by

no test coverage detected