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:
parent
8666abc4ba
commit
3b32480d45
5 changed files with 26 additions and 20 deletions
|
|
@ -16,7 +16,7 @@ import (
|
|||
)
|
||||
|
||||
type KojiFinalizeJobImpl struct {
|
||||
KojiServers map[string]koji.GSSAPICredentials
|
||||
KojiServers map[string]kojiServer
|
||||
relaxTimeoutFactor uint
|
||||
}
|
||||
|
||||
|
|
@ -33,12 +33,12 @@ func (impl *KojiFinalizeJobImpl) kojiImport(
|
|||
return err
|
||||
}
|
||||
|
||||
creds, exists := impl.KojiServers[serverURL.Hostname()]
|
||||
kojiServer, exists := impl.KojiServers[serverURL.Hostname()]
|
||||
if !exists {
|
||||
return fmt.Errorf("Koji server has not been configured: %s", serverURL.Hostname())
|
||||
}
|
||||
|
||||
k, err := koji.NewFromGSSAPI(server, &creds, transport)
|
||||
k, err := koji.NewFromGSSAPI(server, &kojiServer.creds, transport)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -65,12 +65,12 @@ func (impl *KojiFinalizeJobImpl) kojiFail(server string, buildID int, token stri
|
|||
return err
|
||||
}
|
||||
|
||||
creds, exists := impl.KojiServers[serverURL.Hostname()]
|
||||
kojiServer, exists := impl.KojiServers[serverURL.Hostname()]
|
||||
if !exists {
|
||||
return fmt.Errorf("Koji server has not been configured: %s", serverURL.Hostname())
|
||||
}
|
||||
|
||||
k, err := koji.NewFromGSSAPI(server, &creds, transport)
|
||||
k, err := koji.NewFromGSSAPI(server, &kojiServer.creds, transport)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import (
|
|||
)
|
||||
|
||||
type KojiInitJobImpl struct {
|
||||
KojiServers map[string]koji.GSSAPICredentials
|
||||
KojiServers map[string]kojiServer
|
||||
relaxTimeoutFactor uint
|
||||
}
|
||||
|
||||
|
|
@ -24,12 +24,12 @@ func (impl *KojiInitJobImpl) kojiInit(server, name, version, release string) (st
|
|||
return "", 0, err
|
||||
}
|
||||
|
||||
creds, exists := impl.KojiServers[serverURL.Hostname()]
|
||||
kojiServer, exists := impl.KojiServers[serverURL.Hostname()]
|
||||
if !exists {
|
||||
return "", 0, fmt.Errorf("Koji server has not been configured: %s", serverURL.Hostname())
|
||||
}
|
||||
|
||||
k, err := koji.NewFromGSSAPI(server, &creds, transport)
|
||||
k, err := koji.NewFromGSSAPI(server, &kojiServer.creds, transport)
|
||||
if err != nil {
|
||||
return "", 0, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import (
|
|||
type OSBuildKojiJobImpl struct {
|
||||
Store string
|
||||
Output string
|
||||
KojiServers map[string]koji.GSSAPICredentials
|
||||
KojiServers map[string]kojiServer
|
||||
relaxTimeoutFactor uint
|
||||
}
|
||||
|
||||
|
|
@ -30,12 +30,12 @@ func (impl *OSBuildKojiJobImpl) kojiUpload(file *os.File, server, directory, fil
|
|||
return "", 0, err
|
||||
}
|
||||
|
||||
creds, exists := impl.KojiServers[serverURL.Hostname()]
|
||||
kojiServer, exists := impl.KojiServers[serverURL.Hostname()]
|
||||
if !exists {
|
||||
return "", 0, fmt.Errorf("Koji server has not been configured: %s", serverURL.Hostname())
|
||||
}
|
||||
|
||||
k, err := koji.NewFromGSSAPI(server, &creds, transport)
|
||||
k, err := koji.NewFromGSSAPI(server, &kojiServer.creds, transport)
|
||||
if err != nil {
|
||||
return "", 0, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ type S3Configuration struct {
|
|||
type OSBuildJobImpl struct {
|
||||
Store string
|
||||
Output string
|
||||
KojiServers map[string]koji.GSSAPICredentials
|
||||
KojiServers map[string]kojiServer
|
||||
KojiRelaxTimeoutFactor uint
|
||||
GCPCreds string
|
||||
AzureCreds *azure.Credentials
|
||||
|
|
@ -728,7 +728,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
creds, exists := impl.KojiServers[kojiServerURL.Hostname()]
|
||||
kojiServer, exists := impl.KojiServers[kojiServerURL.Hostname()]
|
||||
if !exists {
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, fmt.Sprintf("Koji server has not been configured: %s", kojiServerURL.Hostname()))
|
||||
return nil
|
||||
|
|
@ -736,7 +736,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
|
||||
kojiTransport := koji.CreateKojiTransport(impl.KojiRelaxTimeoutFactor)
|
||||
|
||||
kojiAPI, err := koji.NewFromGSSAPI(options.Server, &creds, kojiTransport)
|
||||
kojiAPI, err := koji.NewFromGSSAPI(options.Server, &kojiServer.creds, kojiTransport)
|
||||
if err != nil {
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, fmt.Sprintf("failed to authenticate with Koji server %q: %v", kojiServerURL.Hostname(), err))
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue