worker: factor out kojiServer struct

In order to match the config structure.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
Ondřej Budai 2022-06-28 12:06:33 +02:00 committed by Tom Gundersen
parent 8666abc4ba
commit 3b32480d45
5 changed files with 26 additions and 20 deletions

View file

@ -37,6 +37,10 @@ type connectionConfig struct {
ClientCertFile string
}
type kojiServer struct {
creds koji.GSSAPICredentials
}
// Represents the implementation of a job type as defined by the worker API.
type JobImplementation interface {
Run(job worker.Job) error
@ -272,15 +276,17 @@ func main() {
output := path.Join(cacheDirectory, "output")
_ = os.Mkdir(output, os.ModeDir)
kojiServers := make(map[string]koji.GSSAPICredentials)
for server, creds := range config.Koji {
if creds.Kerberos == nil {
kojiServers := make(map[string]kojiServer)
for server, kojiConfig := range config.Koji {
if kojiConfig.Kerberos == nil {
// For now we only support Kerberos authentication.
continue
}
kojiServers[server] = koji.GSSAPICredentials{
Principal: creds.Kerberos.Principal,
KeyTab: creds.Kerberos.KeyTab,
kojiServers[server] = kojiServer{
creds: koji.GSSAPICredentials{
Principal: kojiConfig.Kerberos.Principal,
KeyTab: kojiConfig.Kerberos.KeyTab,
},
}
}