2024-04-29 22:24:00 +02:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"gopkg.in/yaml.v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Config struct {
|
2024-05-24 22:07:55 +02:00
|
|
|
Secret string `yaml:"secret"`
|
|
|
|
Port int `yaml:"port"`
|
|
|
|
Projects map[string][]ConfigScript `yaml:"projects"`
|
2024-05-06 17:03:56 +02:00
|
|
|
}
|
|
|
|
type ConfigScript struct {
|
2024-05-25 06:31:37 +02:00
|
|
|
Environment string `yaml:"environment"`
|
|
|
|
Command string `yaml:"command"`
|
|
|
|
Arguments []string `yaml:"args"`
|
2024-04-29 22:24:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|