45 lines
1.4 KiB
Go
45 lines
1.4 KiB
Go
package config
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
// Services maps a registered service name to its connection settings. Names
|
|
// come from the registry in servicespec.go.
|
|
type Services map[string]ServiceConnection
|
|
|
|
// Get returns the connection configured for name, or the zero value when the
|
|
// configuration carries no section for it. A registered service always has an
|
|
// entry once defaults have been applied.
|
|
func (s Services) Get(name string) ServiceConnection {
|
|
return s[name]
|
|
}
|
|
|
|
// RequireTarget returns name's dial address, or an error naming the config
|
|
// key.
|
|
func (s Services) RequireTarget(name string) (string, error) {
|
|
target := strings.TrimSpace(s[name].Target)
|
|
if target == "" {
|
|
return "", fmt.Errorf("services.%s.target is required", name)
|
|
}
|
|
return target, nil
|
|
}
|
|
|
|
// ServiceConnection is a service's gRPC addresses.
|
|
// Restart-required.
|
|
type ServiceConnection struct {
|
|
Target string `toml:"target" yaml:"target"`
|
|
// Listen is the address the owning process binds. Always defaulted.
|
|
Listen string `toml:"listen" yaml:"listen"`
|
|
}
|
|
|
|
// TLS locates the operator-issued certificates. A process named <service>
|
|
// loads cert_dir/<service>.pem and cert_dir/<service>-key.pem, whose DNS name
|
|
// is <service>, and trusts ca_file for every peer. Both empty means plaintext,
|
|
// which is confined to loopback addresses.
|
|
type TLS struct {
|
|
CAFile string `toml:"ca_file" yaml:"ca_file"`
|
|
CertDir string `toml:"cert_dir" yaml:"cert_dir"`
|
|
}
|