worker/client: pass arch explicitly

The API client guessed the arch, let's pass it explicitly so a caller
can specify it.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
Ondřej Budai 2020-11-19 11:41:07 +01:00 committed by Sanne Raymaekers
parent 8fa822c02e
commit 0a304f659d
2 changed files with 5 additions and 4 deletions

View file

@ -15,6 +15,7 @@ import (
"github.com/BurntSushi/toml"
"github.com/osbuild/osbuild-composer/internal/common"
"github.com/osbuild/osbuild-composer/internal/upload/azure"
"github.com/osbuild/osbuild-composer/internal/upload/koji"
"github.com/osbuild/osbuild-composer/internal/worker"
@ -228,7 +229,7 @@ func main() {
for {
fmt.Println("Waiting for a new job...")
job, err := client.RequestJob(acceptedJobTypes)
job, err := client.RequestJob(acceptedJobTypes, common.CurrentArch())
if err != nil {
log.Fatal(err)
}

View file

@ -15,7 +15,7 @@ import (
"time"
"github.com/google/uuid"
"github.com/osbuild/osbuild-composer/internal/common"
"github.com/osbuild/osbuild-composer/internal/worker/api"
)
@ -162,7 +162,7 @@ func (c *Client) NewRequest(method, url string, body io.Reader) (*http.Request,
return req, nil
}
func (c *Client) RequestJob(types []string) (Job, error) {
func (c *Client) RequestJob(types []string, arch string) (Job, error) {
url, err := c.server.Parse("jobs")
if err != nil {
// This only happens when "jobs" cannot be parsed.
@ -172,7 +172,7 @@ func (c *Client) RequestJob(types []string) (Job, error) {
var buf bytes.Buffer
err = json.NewEncoder(&buf).Encode(api.RequestJobJSONRequestBody{
Types: types,
Arch: common.CurrentArch(),
Arch: arch,
})
if err != nil {
panic(err)