29
pkg/config/config.go
Normal file
29
pkg/config/config.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package config
|
||||
|
||||
import "io"
|
||||
|
||||
type Config struct {
|
||||
Services []*Service `json:"services,omitempty" yaml:"services,omitempty"`
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
Addr string `json:"addr,omitempty" yaml:"addr,omitempty"`
|
||||
Checks []Check `json:"checks,omitempty" yaml:"checks,omitempty"`
|
||||
}
|
||||
|
||||
type Check struct {
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
Type string `json:"type,omitempty" yaml:"type,omitempty"`
|
||||
Data string `json:"data,omitempty" yaml:"data,omitempty"`
|
||||
Timeout string `json:"timeout,omitempty" yaml:"timeout,omitempty"`
|
||||
}
|
||||
|
||||
func (cfg *Config) Parse(r io.Reader) error {
|
||||
buf, err := io.ReadAll(r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return yaml.Unmarshal(buf, cfg)
|
||||
}
|
Reference in New Issue
Block a user