zrok/controller/config.go

66 lines
1.2 KiB
Go
Raw Normal View History

package controller
2022-08-09 17:34:00 +02:00
import (
"github.com/michaelquigley/cf"
"github.com/openziti-test-kitchen/zrok/controller/store"
"github.com/pkg/errors"
)
type Config struct {
Endpoint *EndpointConfig
Proxy *ProxyConfig
Email *EmailConfig
Registration *RegistrationConfig
Store *store.Config
Ziti *ZitiConfig
Metrics *MetricsConfig
Influx *InfluxConfig
2022-08-09 17:18:24 +02:00
}
type EndpointConfig struct {
Host string
Port int
}
type ProxyConfig struct {
UrlTemplate string
Identities []string
}
2022-08-09 17:34:00 +02:00
type EmailConfig struct {
Host string
Port int
Username string
Password string `cf:"+secret"`
}
2022-09-09 19:23:30 +02:00
type RegistrationConfig struct {
EmailFrom string
RegistrationUrlTemplate string
2022-09-09 19:23:30 +02:00
}
2022-08-12 17:03:15 +02:00
type ZitiConfig struct {
ApiEndpoint string
Username string
Password string `cf:"+secret"`
2022-08-12 17:03:15 +02:00
}
type MetricsConfig struct {
ServiceName string
}
type InfluxConfig struct {
Url string
Bucket string
Org string
Token string `cf:"+secret"`
}
2022-08-09 17:34:00 +02:00
func LoadConfig(path string) (*Config, error) {
cfg := &Config{}
if err := cf.BindYaml(cfg, path, cf.DefaultOptions()); err != nil {
return nil, errors.Wrapf(err, "error loading controller config '%v'", path)
}
return cfg, nil
}