Load takes a byte slice and deserializes the contents into Config object. Encapsulates deserialization without assuming the source is a file.
(data []byte)
| 388 | // Load takes a byte slice and deserializes the contents into Config object. |
| 389 | // Encapsulates deserialization without assuming the source is a file. |
| 390 | func 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 |
no test coverage detected