worker: pass build environment to osbuild

Detect it from the host using the distro package.
This commit is contained in:
Lars Karlitski 2019-11-28 21:05:31 +01:00
parent 85e6182bdc
commit 5dad3bfc8e
6 changed files with 48 additions and 6 deletions

View file

@ -9,6 +9,7 @@ import (
"net"
"net/http"
"github.com/osbuild/osbuild-composer/internal/distro"
"github.com/osbuild/osbuild-composer/internal/jobqueue"
)
@ -74,7 +75,7 @@ func (c *ComposerClient) UpdateJob(job *jobqueue.Job, status string) error {
return nil
}
func handleJob(client *ComposerClient) {
func handleJob(client *ComposerClient, distro distro.Distro) {
fmt.Println("Waiting for a new job...")
job, err := client.AddJob()
if err != nil {
@ -84,7 +85,7 @@ func handleJob(client *ComposerClient) {
client.UpdateJob(job, "RUNNING")
fmt.Printf("Running job %s\n", job.ID.String())
err, errs := job.Run()
err, errs := job.Run(distro)
if err != nil {
client.UpdateJob(job, "FAILED")
return
@ -101,9 +102,13 @@ func handleJob(client *ComposerClient) {
}
func main() {
client := NewClient()
distro, err := distro.FromHost()
if err != nil {
panic(err)
}
client := NewClient()
for {
handleJob(client)
handleJob(client, distro)
}
}