upload/koji/uploadChunk: fix compilation errors
The API of kolo/xmlrpc changed after the commit that is shipped in Fedora. Pin the vendored version to that and adjust the API usage. This should make the RPM compile in both RHEL and Fedora. Signed-off-by: Tom Gundersen <teg@jklm.no>
This commit is contained in:
parent
3457038688
commit
b6f06da1a7
10 changed files with 93 additions and 59 deletions
2
go.mod
2
go.mod
|
|
@ -20,7 +20,7 @@ require (
|
||||||
github.com/google/uuid v1.1.1
|
github.com/google/uuid v1.1.1
|
||||||
github.com/gophercloud/gophercloud v0.11.0
|
github.com/gophercloud/gophercloud v0.11.0
|
||||||
github.com/julienschmidt/httprouter v1.2.0
|
github.com/julienschmidt/httprouter v1.2.0
|
||||||
github.com/kolo/xmlrpc v0.0.0-20190909154602-56d5ec7c422e
|
github.com/kolo/xmlrpc v0.0.0-20190417161013-de6d879202d7
|
||||||
github.com/labstack/echo/v4 v4.1.11
|
github.com/labstack/echo/v4 v4.1.11
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/stretchr/testify v1.5.1
|
github.com/stretchr/testify v1.5.1
|
||||||
|
|
|
||||||
4
go.sum
4
go.sum
|
|
@ -75,8 +75,8 @@ github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5i
|
||||||
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
||||||
github.com/julienschmidt/httprouter v1.2.0 h1:TDTW5Yz1mjftljbcKqRcrYhd4XeOoI98t+9HbQbYf7g=
|
github.com/julienschmidt/httprouter v1.2.0 h1:TDTW5Yz1mjftljbcKqRcrYhd4XeOoI98t+9HbQbYf7g=
|
||||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||||
github.com/kolo/xmlrpc v0.0.0-20190909154602-56d5ec7c422e h1:JZPIpxHmcXiQn101f6P9wkfRZs2A9268tHHnanj+esA=
|
github.com/kolo/xmlrpc v0.0.0-20190417161013-de6d879202d7 h1:kL2yi3DjwkRWFgKwD5COyl4XMLKhfOvqck4xyis7EIw=
|
||||||
github.com/kolo/xmlrpc v0.0.0-20190909154602-56d5ec7c422e/go.mod h1:o03bZfuBwAXHetKXuInt4S7omeXUu62/A845kiycsSQ=
|
github.com/kolo/xmlrpc v0.0.0-20190417161013-de6d879202d7/go.mod h1:o03bZfuBwAXHetKXuInt4S7omeXUu62/A845kiycsSQ=
|
||||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
|
|
|
||||||
|
|
@ -305,20 +305,20 @@ func (k *Koji) uploadChunk(chunk []byte, filepath, filename string, offset uint6
|
||||||
u.RawQuery = q.Encode()
|
u.RawQuery = q.Encode()
|
||||||
|
|
||||||
client := http.Client{Transport: k.transport}
|
client := http.Client{Transport: k.transport}
|
||||||
resp, err := client.Post(u.String(), "application/octet-stream", bytes.NewBuffer(chunk))
|
respData, err := client.Post(u.String(), "application/octet-stream", bytes.NewBuffer(chunk))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer respData.Body.Close()
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := ioutil.ReadAll(respData.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = xmlrpc.Response.Err(body)
|
resp := xmlrpc.NewResponse(body)
|
||||||
if err != nil {
|
if resp.Failed() {
|
||||||
return err
|
return resp.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
var reply struct {
|
var reply struct {
|
||||||
|
|
@ -326,7 +326,7 @@ func (k *Koji) uploadChunk(chunk []byte, filepath, filename string, offset uint6
|
||||||
HexDigest string `xmlrpc:"hexdigest"`
|
HexDigest string `xmlrpc:"hexdigest"`
|
||||||
}
|
}
|
||||||
|
|
||||||
err = xmlrpc.Response.Unmarshal(body, &reply)
|
err = resp.Unmarshal(&reply)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("cannot unmarshal the xmlrpc response: %v", err)
|
return fmt.Errorf("cannot unmarshal the xmlrpc response: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
47
vendor/github.com/kolo/xmlrpc/client.go
generated
vendored
47
vendor/github.com/kolo/xmlrpc/client.go
generated
vendored
|
|
@ -31,7 +31,7 @@ type clientCodec struct {
|
||||||
responses map[uint64]*http.Response
|
responses map[uint64]*http.Response
|
||||||
mutex sync.Mutex
|
mutex sync.Mutex
|
||||||
|
|
||||||
response Response
|
response *Response
|
||||||
|
|
||||||
// ready presents channel, that is used to link request and it`s response.
|
// ready presents channel, that is used to link request and it`s response.
|
||||||
ready chan uint64
|
ready chan uint64
|
||||||
|
|
@ -43,16 +43,16 @@ type clientCodec struct {
|
||||||
func (codec *clientCodec) WriteRequest(request *rpc.Request, args interface{}) (err error) {
|
func (codec *clientCodec) WriteRequest(request *rpc.Request, args interface{}) (err error) {
|
||||||
httpRequest, err := NewRequest(codec.url.String(), request.ServiceMethod, args)
|
httpRequest, err := NewRequest(codec.url.String(), request.ServiceMethod, args)
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if codec.cookies != nil {
|
if codec.cookies != nil {
|
||||||
for _, cookie := range codec.cookies.Cookies(codec.url) {
|
for _, cookie := range codec.cookies.Cookies(codec.url) {
|
||||||
httpRequest.AddCookie(cookie)
|
httpRequest.AddCookie(cookie)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
var httpResponse *http.Response
|
var httpResponse *http.Response
|
||||||
httpResponse, err = codec.httpClient.Do(httpRequest)
|
httpResponse, err = codec.httpClient.Do(httpRequest)
|
||||||
|
|
||||||
|
|
@ -75,39 +75,43 @@ func (codec *clientCodec) WriteRequest(request *rpc.Request, args interface{}) (
|
||||||
|
|
||||||
func (codec *clientCodec) ReadResponseHeader(response *rpc.Response) (err error) {
|
func (codec *clientCodec) ReadResponseHeader(response *rpc.Response) (err error) {
|
||||||
var seq uint64
|
var seq uint64
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case seq = <-codec.ready:
|
case seq = <-codec.ready:
|
||||||
case <-codec.close:
|
case <-codec.close:
|
||||||
return errors.New("codec is closed")
|
return errors.New("codec is closed")
|
||||||
}
|
}
|
||||||
response.Seq = seq
|
|
||||||
|
|
||||||
codec.mutex.Lock()
|
codec.mutex.Lock()
|
||||||
httpResponse := codec.responses[seq]
|
httpResponse := codec.responses[seq]
|
||||||
delete(codec.responses, seq)
|
|
||||||
codec.mutex.Unlock()
|
codec.mutex.Unlock()
|
||||||
|
|
||||||
defer httpResponse.Body.Close()
|
|
||||||
|
|
||||||
if httpResponse.StatusCode < 200 || httpResponse.StatusCode >= 300 {
|
if httpResponse.StatusCode < 200 || httpResponse.StatusCode >= 300 {
|
||||||
response.Error = fmt.Sprintf("request error: bad status code - %d", httpResponse.StatusCode)
|
return fmt.Errorf("request error: bad status code - %d", httpResponse.StatusCode)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(httpResponse.Body)
|
respData, err := ioutil.ReadAll(httpResponse.Body)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
response.Error = err.Error()
|
return err
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := Response(body)
|
httpResponse.Body.Close()
|
||||||
if err := resp.Err(); err != nil {
|
|
||||||
response.Error = err.Error()
|
resp := NewResponse(respData)
|
||||||
return nil
|
|
||||||
|
if resp.Failed() {
|
||||||
|
response.Error = fmt.Sprintf("%v", resp.Err())
|
||||||
}
|
}
|
||||||
|
|
||||||
codec.response = resp
|
codec.response = resp
|
||||||
|
|
||||||
|
response.Seq = seq
|
||||||
|
|
||||||
|
codec.mutex.Lock()
|
||||||
|
delete(codec.responses, seq)
|
||||||
|
codec.mutex.Unlock()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -115,7 +119,12 @@ func (codec *clientCodec) ReadResponseBody(v interface{}) (err error) {
|
||||||
if v == nil {
|
if v == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return codec.response.Unmarshal(v)
|
|
||||||
|
if err = codec.response.Unmarshal(v); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (codec *clientCodec) Close() error {
|
func (codec *clientCodec) Close() error {
|
||||||
|
|
|
||||||
5
vendor/github.com/kolo/xmlrpc/decoder.go
generated
vendored
5
vendor/github.com/kolo/xmlrpc/decoder.go
generated
vendored
|
|
@ -130,9 +130,8 @@ func (dec *decoder) decodeValue(val reflect.Value) error {
|
||||||
ismap = true
|
ismap = true
|
||||||
} else if checkType(val, reflect.Interface) == nil && val.IsNil() {
|
} else if checkType(val, reflect.Interface) == nil && val.IsNil() {
|
||||||
var dummy map[string]interface{}
|
var dummy map[string]interface{}
|
||||||
valType = reflect.TypeOf(dummy)
|
pmap = reflect.New(reflect.TypeOf(dummy)).Elem()
|
||||||
pmap = reflect.New(valType).Elem()
|
valType = pmap.Type()
|
||||||
val.Set(pmap)
|
|
||||||
ismap = true
|
ismap = true
|
||||||
} else {
|
} else {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
3
vendor/github.com/kolo/xmlrpc/encoder.go
generated
vendored
3
vendor/github.com/kolo/xmlrpc/encoder.go
generated
vendored
|
|
@ -10,9 +10,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Base64 represents value in base64 encoding
|
|
||||||
type Base64 string
|
|
||||||
|
|
||||||
type encodeFunc func(reflect.Value) ([]byte, error)
|
type encodeFunc func(reflect.Value) ([]byte, error)
|
||||||
|
|
||||||
func marshal(v interface{}) ([]byte, error) {
|
func marshal(v interface{}) ([]byte, error) {
|
||||||
|
|
|
||||||
50
vendor/github.com/kolo/xmlrpc/response.go
generated
vendored
50
vendor/github.com/kolo/xmlrpc/response.go
generated
vendored
|
|
@ -1,7 +1,6 @@
|
||||||
package xmlrpc
|
package xmlrpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -9,32 +8,43 @@ var (
|
||||||
faultRx = regexp.MustCompile(`<fault>(\s|\S)+</fault>`)
|
faultRx = regexp.MustCompile(`<fault>(\s|\S)+</fault>`)
|
||||||
)
|
)
|
||||||
|
|
||||||
// FaultError is returned from the server when an invalid call is made
|
type failedResponse struct {
|
||||||
type FaultError struct {
|
Code int `xmlrpc:"faultCode"`
|
||||||
Code int `xmlrpc:"faultCode"`
|
Error string `xmlrpc:"faultString"`
|
||||||
String string `xmlrpc:"faultString"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error implements the error interface
|
func (r *failedResponse) err() error {
|
||||||
func (e FaultError) Error() string {
|
return &xmlrpcError{
|
||||||
return fmt.Sprintf("Fault(%d): %s", e.Code, e.String)
|
code: r.Code,
|
||||||
}
|
err: r.Error,
|
||||||
|
|
||||||
type Response []byte
|
|
||||||
|
|
||||||
func (r Response) Err() error {
|
|
||||||
if !faultRx.Match(r) {
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
var fault FaultError
|
}
|
||||||
if err := unmarshal(r, &fault); err != nil {
|
|
||||||
|
type Response struct {
|
||||||
|
data []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewResponse(data []byte) *Response {
|
||||||
|
return &Response{
|
||||||
|
data: data,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Response) Failed() bool {
|
||||||
|
return faultRx.Match(r.data)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Response) Err() error {
|
||||||
|
failedResp := new(failedResponse)
|
||||||
|
if err := unmarshal(r.data, failedResp); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return fault
|
|
||||||
|
return failedResp.err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r Response) Unmarshal(v interface{}) error {
|
func (r *Response) Unmarshal(v interface{}) error {
|
||||||
if err := unmarshal(r, v); err != nil {
|
if err := unmarshal(r.data, v); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
6
vendor/github.com/kolo/xmlrpc/test_server.rb
generated
vendored
6
vendor/github.com/kolo/xmlrpc/test_server.rb
generated
vendored
|
|
@ -15,9 +15,9 @@ class Service
|
||||||
x + y
|
x + y
|
||||||
end
|
end
|
||||||
|
|
||||||
def error
|
def error
|
||||||
raise XMLRPC::FaultException.new(500, "Server error")
|
raise XMLRPC::FaultException.new(500, "Server error")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
server = XMLRPC::Server.new 5001, 'localhost'
|
server = XMLRPC::Server.new 5001, 'localhost'
|
||||||
|
|
|
||||||
19
vendor/github.com/kolo/xmlrpc/xmlrpc.go
generated
vendored
Normal file
19
vendor/github.com/kolo/xmlrpc/xmlrpc.go
generated
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
package xmlrpc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// xmlrpcError represents errors returned on xmlrpc request.
|
||||||
|
type xmlrpcError struct {
|
||||||
|
code int
|
||||||
|
err string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Error() method implements Error interface
|
||||||
|
func (e *xmlrpcError) Error() string {
|
||||||
|
return fmt.Sprintf("error: \"%s\" code: %d", e.err, e.code)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Base64 represents value in base64 encoding
|
||||||
|
type Base64 string
|
||||||
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
|
|
@ -119,7 +119,7 @@ github.com/gophercloud/gophercloud/pagination
|
||||||
github.com/jmespath/go-jmespath
|
github.com/jmespath/go-jmespath
|
||||||
# github.com/julienschmidt/httprouter v1.2.0
|
# github.com/julienschmidt/httprouter v1.2.0
|
||||||
github.com/julienschmidt/httprouter
|
github.com/julienschmidt/httprouter
|
||||||
# github.com/kolo/xmlrpc v0.0.0-20190909154602-56d5ec7c422e
|
# github.com/kolo/xmlrpc v0.0.0-20190417161013-de6d879202d7
|
||||||
github.com/kolo/xmlrpc
|
github.com/kolo/xmlrpc
|
||||||
# github.com/kr/pretty v0.1.0
|
# github.com/kr/pretty v0.1.0
|
||||||
github.com/kr/pretty
|
github.com/kr/pretty
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue