Jobs & Workflows https://armen.surge.sh
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

43 lines
1.0 KiB

/*
------------------------------------------------------------------------------------------------------------------------
####### yaml ####### Copyright (c) 2021 mls-361 #################################################### MIT License #######
------------------------------------------------------------------------------------------------------------------------
*/
package yaml
import (
"io/ioutil"
"path/filepath"
"gopkg.in/yaml.v3"
"forge.chapril.org/armen/armen/internal/components"
)
const (
_defaultConfigDir = "/etc"
)
// LoadConfig AFAIRE.
func LoadConfig(app components.Application, destination interface{}) error {
file, ok := app.LookupEnv("CONFIG_FILE")
if !ok {
file = filepath.Join(_defaultConfigDir, app.Name(), app.Name()+".yaml")
}
data, err := ioutil.ReadFile(file)
if err != nil {
return err
}
if err := yaml.Unmarshal(data, destination); err != nil {
return err
}
return nil
}
/*
######################################################################################################## @(°_°)@ #######
*/