34 lines
575 B
Go
34 lines
575 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
|
|
"gopkg.in/yaml.v3"
|
|
)
|
|
|
|
type Config struct {
|
|
BackendURL string `yaml:"backend_url"`
|
|
APIKey string `yaml:"api_key"`
|
|
IntervalSeconds int `yaml:"interval_seconds"`
|
|
AgentName string `yaml:"agent_name"`
|
|
Insecure bool `yaml:"insecure"`
|
|
}
|
|
|
|
func Load(path string) (*Config, error) {
|
|
cfg := &Config{
|
|
IntervalSeconds: 60,
|
|
Insecure: true,
|
|
}
|
|
|
|
data, err := os.ReadFile(path)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if err := yaml.Unmarshal(data, cfg); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return cfg, nil
|
|
}
|