mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-10-19 10:47:13 +00:00
add test
This commit is contained in:
1 parent
22cfa4c8c7
commit
a15d8a3f7b
4 files changed
+265
-2
No files matched your search
@@ -294,6 +294,23 @@ func SaveConfigRaw(filename string, conf []byte) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// SaveConfigYAML write configuration to yaml file
|
||||
func SaveConfigYAML(filename string, config *ConfigStructure) error {
|
||||
f, err := os.Create(filename)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
yamlData, err := yaml.Marshal(&config)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error marshaling to YAML: %s", err)
|
||||
}
|
||||
|
||||
_, err = f.Write(yamlData)
|
||||
return err
|
||||
}
|
||||
|
||||
// GetRootDir returns the RootDir with expanded ~ as home directory
|
||||
func (conf *ConfigStructure) GetRootDir() string {
|
||||
return strings.Replace(conf.RootDir, "~", os.Getenv("HOME"), 1)
|
||||
|
||||
Reference in new issue
Block a user