osbuild-composer/config: rework the structure

Prior this change, the structure was following:

[koji.localhost.kerberos]

This change modifies it to:

[koji.servers.localhost.kerberos]

This allows us to put more config options under the koji section. See
following commits, they use this new possibility.
This commit is contained in:
Ondřej Budai 2020-09-21 12:16:46 +02:00 committed by Tom Gundersen
parent 9a26d077db
commit c9abb66637
2 changed files with 12 additions and 7 deletions

View file

@ -72,11 +72,13 @@ func createTLSConfig(c *connectionConfig) (*tls.Config, error) {
func main() { func main() {
var config struct { var config struct {
KojiServers map[string]struct { Koji *struct {
Kerberos *struct { Servers map[string]struct {
Principal string `toml:"principal"` Kerberos *struct {
KeyTab string `toml:"keytab"` Principal string `toml:"principal"`
} `toml:"kerberos,omitempty"` KeyTab string `toml:"keytab"`
} `toml:"kerberos,omitempty"`
} `toml:"servers"`
} `toml:"koji"` } `toml:"koji"`
Worker *struct { Worker *struct {
AllowedDomains []string `toml:"allowed_domains"` AllowedDomains []string `toml:"allowed_domains"`
@ -190,8 +192,11 @@ func main() {
// Optionally run Koji API // Optionally run Koji API
if kojiListeners, exists := listeners["osbuild-composer-koji.socket"]; exists { if kojiListeners, exists := listeners["osbuild-composer-koji.socket"]; exists {
if config.Koji == nil {
log.Fatal("koji not configured in the config file")
}
kojiServers := make(map[string]koji.GSSAPICredentials) kojiServers := make(map[string]koji.GSSAPICredentials)
for server, creds := range config.KojiServers { for server, creds := range config.Koji.Servers {
if creds.Kerberos == nil { if creds.Kerberos == nil {
// For now we only support Kerberos authentication. // For now we only support Kerberos authentication.
continue continue

View file

@ -1,4 +1,4 @@
[koji.localhost.kerberos] [koji.servers.localhost.kerberos]
principal = "osbuild-krb@LOCAL" principal = "osbuild-krb@LOCAL"
keytab = "/etc/osbuild-composer/client.keytab" keytab = "/etc/osbuild-composer/client.keytab"