MCPcopy Create free account
hub / github.com/aptly-dev/aptly / SaveConfigYAML

Function SaveConfigYAML

utils/config.go:340–356  ·  view source on GitHub ↗

SaveConfigYAML write configuration to yaml file

(filename string, config *ConfigStructure)

Source from the content-addressed store, hash-verified

338
339// SaveConfigYAML write configuration to yaml file
340func SaveConfigYAML(filename string, config *ConfigStructure) error {
341 f, err := os.Create(filename)
342 if err != nil {
343 return err
344 }
345 defer func() {
346 _ = f.Close()
347 }()
348
349 yamlData, err := yaml.Marshal(&config)
350 if err != nil {
351 return fmt.Errorf("error marshaling to YAML: %s", err)
352 }
353
354 _, err = f.Write(yamlData)
355 return err
356}
357
358// GetRootDir returns the RootDir with expanded ~ as home directory
359func (conf *ConfigStructure) GetRootDir() string {

Callers 2

TestSaveYAMLConfigMethod · 0.85
TestSaveYAML2ConfigMethod · 0.85

Calls 2

CloseMethod · 0.65
WriteMethod · 0.65

Tested by 2

TestSaveYAMLConfigMethod · 0.68
TestSaveYAML2ConfigMethod · 0.68