zrok/controller/config.go

41 lines
793 B
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"
2022-08-12 17:03:15 +02:00
"github.com/sirupsen/logrus"
2022-08-09 17:34:00 +02:00
)
type Config struct {
2022-08-09 17:34:00 +02:00
Endpoint *EndpointConfig
Proxy *ProxyConfig
2022-08-09 17:18:24 +02:00
Store *store.Config
2022-08-12 17:03:15 +02:00
Ziti *ZitiConfig
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
2022-08-12 17:03:15 +02:00
type ZitiConfig struct {
ApiEndpoint string
Username string
Password string
}
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)
}
2022-08-12 17:03:15 +02:00
logrus.Info(cf.Dump(cfg, cf.DefaultOptions()))
2022-08-09 17:34:00 +02:00
return cfg, nil
}