caddy-log-exporter/internal/config/config.go

25 lines
432 B
Go
Raw Normal View History

2024-09-19 11:21:05 +02:00
package config
import (
"fmt"
"github.com/caarlos0/env/v11"
)
type Config struct {
Addr string `env:"ADDR,required" envDefault:":2112"`
LogFiles []string `env:"LOG_FILES,required"`
}
func Parse() (Config, error) {
var cfg Config
if err := env.ParseWithOptions(&cfg, env.Options{
Prefix: "CADDY_LOG_EXPORTER_",
}); err != nil {
return Config{}, fmt.Errorf("parsing config: %w", err)
}
return cfg, nil
}