package config

import (
	"os"

	"gopkg.in/yaml.v3"
)

type Config struct {
	BackendURL      string `yaml:"backend_url"`
	APIKey          string `yaml:"api_key"`
	AgentName       string `yaml:"agent_name"`
	IntervalSeconds int    `yaml:"interval_seconds"`
	Insecure        bool   `yaml:"insecure"`
}

func Load(path string) (*Config, error) {
	data, err := os.ReadFile(path)
	if err != nil {
		return nil, err
	}
	cfg := &Config{
		IntervalSeconds: 60,
		Insecure:        true,
	}
	if err := yaml.Unmarshal(data, cfg); err != nil {
		return nil, err
	}
	return cfg, nil
}
