35 lines
574 B
Go
35 lines
574 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/pelletier/go-toml/v2"
|
|
)
|
|
|
|
type StepMonitor struct {
|
|
Enabled bool `toml:"Enabled"`
|
|
BaseURL string `toml:"BaseURL"`
|
|
RootID string `toml:"RootID"`
|
|
}
|
|
|
|
type Config struct {
|
|
ListenAddr string `toml:"ListenAddr"`
|
|
StepMonitors []StepMonitor `toml:"StepMonitors"`
|
|
}
|
|
|
|
func FromFile(file string) (*Config, error) {
|
|
var config Config
|
|
|
|
f, err := os.Open(file)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
decoder := toml.NewDecoder(f)
|
|
|
|
if err := decoder.Decode(&config); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &config, nil
|
|
}
|