gitea-webhook-listener/kit/config/config.go

29 lines
465 B
Go
Raw Normal View History

2024-04-29 22:24:00 +02:00
package config
import (
"os"
"gopkg.in/yaml.v2"
)
type Config struct {
Secret string `yaml:"secret"`
Port int `yaml:"port"`
BinaryPath string `yaml:"binary_path"`
ScriptPath string `yaml:"script_path"`
}
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
}