MCPcopy
hub / github.com/vmware-tanzu/sonobuoy / Set

Method Set

cmd/sonobuoy/app/sonobuoyconfig.go:46–62  ·  view source on GitHub ↗

Set attempts to read a file, then deserialize the json into a config.Config struct.

(str string)

Source from the content-addressed store, hash-verified

44
45// Set attempts to read a file, then deserialize the json into a config.Config struct.
46func (c *SonobuoyConfig) Set(str string) error {
47 if !reflect.DeepEqual(c.Config, *config.New()) {
48 return errors.New("if a custom config file is set, it must be set before other flags that modify configuration fields")
49 }
50
51 bytes, err := os.ReadFile(str)
52 if err != nil {
53 return errors.Wrap(err, "couldn't open config file")
54 }
55
56 if err := json.Unmarshal(bytes, &c.Config); err != nil {
57 return errors.Wrap(err, "couldn't Unmarshal sonobuoy config")
58 }
59
60 c.raw = string(bytes)
61 return nil
62}
63
64// Get will return the config.Config.
65func (c *SonobuoyConfig) Get() *config.Config {

Callers

nothing calls this directly

Calls 2

NewFunction · 0.92
NewMethod · 0.80

Tested by

no test coverage detected