Save writes the data of a config to its yaml file
(path string, config *latest.Config)
| 10 | |
| 11 | // Save writes the data of a config to its yaml file |
| 12 | func Save(path string, config *latest.Config) error { |
| 13 | var buffer bytes.Buffer |
| 14 | |
| 15 | yamlEncoder := yaml.NewEncoder(&buffer) |
| 16 | yamlEncoder.SetIndent(2) |
| 17 | |
| 18 | err := yamlEncoder.Encode(config) |
| 19 | if err != nil { |
| 20 | return err |
| 21 | } |
| 22 | |
| 23 | // Path to save the configuration to |
| 24 | err = os.WriteFile(path, buffer.Bytes(), os.ModePerm) |
| 25 | if err != nil { |
| 26 | return err |
| 27 | } |
| 28 | |
| 29 | return nil |
| 30 | } |
no outgoing calls
no test coverage detected