Add stepmon component
This commit is contained in:
34
config/config.go
Normal file
34
config/config.go
Normal file
@@ -0,0 +1,34 @@
|
||||
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
|
||||
}
|
Reference in New Issue
Block a user