upload/koji: return the CGImport result

Currently, only build id is returned, more will come when needed.
This commit is contained in:
Ondřej Budai 2020-05-15 14:49:21 +02:00 committed by Tom Gundersen
parent e43eb4da7b
commit 87a7e90c98
2 changed files with 11 additions and 7 deletions

View file

@ -100,11 +100,11 @@ func main() {
}, },
} }
err = k.CGImport(build, buildRoots, output, dir) result, err := k.CGImport(build, buildRoots, output, dir)
if err != nil { if err != nil {
println(err.Error()) println(err.Error())
return return
} }
fmt.Printf("Success!\n") fmt.Printf("Success, build id: %d\n", result.BuildID)
} }

View file

@ -104,6 +104,10 @@ type Metadata struct {
Output []Output `json:"output"` Output []Output `json:"output"`
} }
type CGImportResult struct {
BuildID int `xmlrpc:"build_id"`
}
// RoundTrip implements the RoundTripper interface, using the default // RoundTrip implements the RoundTripper interface, using the default
// transport. When a session has been established, also pass along the // transport. When a session has been established, also pass along the
// session credentials. This may not be how the RoundTripper interface // session credentials. This may not be how the RoundTripper interface
@ -185,7 +189,7 @@ func (k *Koji) Logout() error {
// CGImport imports previously uploaded content, by specifying its metadata, and the temporary // CGImport imports previously uploaded content, by specifying its metadata, and the temporary
// directory where it is located. // directory where it is located.
func (k *Koji) CGImport(build Build, buildRoots []BuildRoot, output []Output, directory string) error { func (k *Koji) CGImport(build Build, buildRoots []BuildRoot, output []Output, directory string) (*CGImportResult, error) {
m := &Metadata{ m := &Metadata{
Build: build, Build: build,
BuildRoots: buildRoots, BuildRoots: buildRoots,
@ -193,16 +197,16 @@ func (k *Koji) CGImport(build Build, buildRoots []BuildRoot, output []Output, di
} }
metadata, err := json.Marshal(m) metadata, err := json.Marshal(m)
if err != nil { if err != nil {
return err return nil, err
} }
var result interface{} var result CGImportResult
err = k.xmlrpc.Call("CGImport", []interface{}{string(metadata), directory}, &result) err = k.xmlrpc.Call("CGImport", []interface{}{string(metadata), directory}, &result)
if err != nil { if err != nil {
return err return nil, err
} }
return nil return &result, nil
} }
// uploadChunk uploads a byte slice to a given filepath/filname at a given offset // uploadChunk uploads a byte slice to a given filepath/filname at a given offset