33 lines
620 B
Go
Executable File
33 lines
620 B
Go
Executable File
package config
|
|
|
|
import (
|
|
"os"
|
|
|
|
"gopkg.in/yaml.v2"
|
|
)
|
|
|
|
type Config struct {
|
|
Secret string `yaml:"secret"`
|
|
Port int `yaml:"port"`
|
|
Projects map[string][]ConfigScript `yaml:"projects"`
|
|
}
|
|
type ConfigScript struct {
|
|
Environment string `yaml:"environment"`
|
|
Command string `yaml:"command"`
|
|
Arguments []string `yaml:"args"`
|
|
}
|
|
|
|
func LoadConfig(path string) (*Config, error) {
|
|
data, err := os.ReadFile(path)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var config Config
|
|
if err := yaml.Unmarshal(data, &config); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &config, nil
|
|
}
|