2022-07-21 22:43:42 +02:00
|
|
|
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"
|
|
|
|
)
|
2022-07-22 19:53:39 +02:00
|
|
|
|
2022-07-21 22:43:42 +02:00
|
|
|
type Config struct {
|
2022-10-13 21:50:12 +02:00
|
|
|
Endpoint *EndpointConfig
|
|
|
|
Proxy *ProxyConfig
|
|
|
|
Email *EmailConfig
|
|
|
|
Registration *RegistrationConfig
|
|
|
|
Store *store.Config
|
|
|
|
Ziti *ZitiConfig
|
|
|
|
Metrics *MetricsConfig
|
2022-10-19 19:20:47 +02:00
|
|
|
Influx *InfluxConfig
|
2022-08-09 17:18:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type EndpointConfig struct {
|
|
|
|
Host string
|
|
|
|
Port int
|
|
|
|
}
|
|
|
|
|
|
|
|
type ProxyConfig struct {
|
|
|
|
UrlTemplate string
|
2022-08-10 17:56:00 +02:00
|
|
|
Identities []string
|
2022-07-21 22:43:42 +02:00
|
|
|
}
|
2022-08-09 17:34:00 +02:00
|
|
|
|
2022-09-09 16:23:14 +02:00
|
|
|
type EmailConfig struct {
|
|
|
|
Host string
|
2022-09-12 21:28:59 +02:00
|
|
|
Port int
|
2022-09-09 16:23:14 +02:00
|
|
|
Username string
|
2022-10-31 20:56:59 +01:00
|
|
|
Password string `cf:"+secret"`
|
2022-09-09 16:23:14 +02:00
|
|
|
}
|
|
|
|
|
2022-09-09 19:23:30 +02:00
|
|
|
type RegistrationConfig struct {
|
2022-09-12 20:35:11 +02:00
|
|
|
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
|
2022-10-31 20:56:59 +01:00
|
|
|
Password string `cf:"+secret"`
|
2022-08-12 17:03:15 +02:00
|
|
|
}
|
|
|
|
|
2022-10-19 19:20:47 +02:00
|
|
|
type MetricsConfig struct {
|
|
|
|
ServiceName string
|
|
|
|
}
|
|
|
|
|
|
|
|
type InfluxConfig struct {
|
|
|
|
Url string
|
|
|
|
Bucket string
|
|
|
|
Org string
|
2022-10-31 20:56:59 +01:00
|
|
|
Token string `cf:"+secret"`
|
2022-10-19 19:20:47 +02:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
}
|