Blame internal/upload/koji/xmlrpc-response.go
|
Packit Service |
509fd4 |
// +build !kolo_xmlrpc_oldapi
|
|
Packit Service |
509fd4 |
//
|
|
Packit Service |
509fd4 |
// This file provides a wrapper around kolo/xmlrpc response handling.
|
|
Packit Service |
509fd4 |
//
|
|
Packit Service |
509fd4 |
// Commit e3ad6d89 of the xmlrpc library changed the API of response handling.
|
|
Packit Service |
509fd4 |
// This means that different APIs are available in Fedora 32 and 33 (it does
|
|
Packit Service |
509fd4 |
// not matter for RHEL as uses vendored libraries).
|
|
Packit Service |
509fd4 |
// This wrapper allows us to use both xmlrpc's APIs using buildflags.
|
|
Packit Service |
509fd4 |
//
|
|
Packit Service |
509fd4 |
// This file is a wrapper for xmlrpc equal or newer than e3ad6d89.
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
package koji
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
import (
|
|
Packit Service |
509fd4 |
"fmt"
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
"github.com/kolo/xmlrpc"
|
|
Packit Service |
509fd4 |
)
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
// processXMLRPCResponse is a wrapper around kolo/xmlrpc
|
|
Packit Service |
509fd4 |
func processXMLRPCResponse(body []byte, reply interface{}) error {
|
|
Packit Service |
509fd4 |
resp := xmlrpc.Response(body)
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
if resp.Err() != nil {
|
|
Packit Service |
509fd4 |
return fmt.Errorf("xmlrpc server returned an error: %v", resp.Err())
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
err := resp.Unmarshal(reply)
|
|
Packit Service |
509fd4 |
if err != nil {
|
|
Packit Service |
509fd4 |
return fmt.Errorf("cannot unmarshal the xmlrpc response: %v", err)
|
|
Packit Service |
509fd4 |
}
|
|
Packit Service |
509fd4 |
|
|
Packit Service |
509fd4 |
return nil
|
|
Packit Service |
509fd4 |
}
|