worker: pass build environment to osbuild
Detect it from the host using the distro package.
This commit is contained in:
parent
85e6182bdc
commit
5dad3bfc8e
6 changed files with 48 additions and 6 deletions
|
|
@ -31,6 +31,9 @@ type Distro interface {
|
|||
// output format with all packages and customizations specified in the
|
||||
// given blueprint.
|
||||
Pipeline(b *blueprint.Blueprint, outputFormat string) (*pipeline.Pipeline, error)
|
||||
|
||||
// Returns a osbuild runner that can be used on this distro.
|
||||
Runner() string
|
||||
}
|
||||
|
||||
var registered map[string]Distro
|
||||
|
|
|
|||
|
|
@ -343,6 +343,10 @@ func (r *Fedora30) Pipeline(b *blueprint.Blueprint, outputFormat string) (*pipel
|
|||
return p, nil
|
||||
}
|
||||
|
||||
func (r *Fedora30) Runner() string {
|
||||
return "org.osbuild.fedora30"
|
||||
}
|
||||
|
||||
func (r *Fedora30) buildPipeline() *pipeline.Pipeline {
|
||||
packages := []string{
|
||||
"dnf",
|
||||
|
|
|
|||
|
|
@ -373,6 +373,10 @@ func (r *RHEL82) Pipeline(b *blueprint.Blueprint, outputFormat string) (*pipelin
|
|||
return p, nil
|
||||
}
|
||||
|
||||
func (r *RHEL82) Runner() string {
|
||||
return "org.osbuild.rhel82"
|
||||
}
|
||||
|
||||
func (r *RHEL82) buildPipeline() *pipeline.Pipeline {
|
||||
packages := []string{
|
||||
"dnf",
|
||||
|
|
|
|||
|
|
@ -36,3 +36,7 @@ func (d *TestDistro) FilenameFromType(outputFormat string) (string, string, erro
|
|||
func (d *TestDistro) Pipeline(b *blueprint.Blueprint, outputFormat string) (*pipeline.Pipeline, error) {
|
||||
return nil, errors.New("invalid output format: " + outputFormat)
|
||||
}
|
||||
|
||||
func (d *TestDistro) Runner() string {
|
||||
return "org.osbuild.test"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,10 +3,12 @@ package jobqueue
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
"github.com/osbuild/osbuild-composer/internal/pipeline"
|
||||
"github.com/osbuild/osbuild-composer/internal/target"
|
||||
"github.com/osbuild/osbuild-composer/internal/upload/awsupload"
|
||||
|
|
@ -22,8 +24,28 @@ type JobStatus struct {
|
|||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
func (job *Job) Run() (error, []error) {
|
||||
cmd := exec.Command("osbuild", "--store", "/var/cache/osbuild-composer/store", "--json", "-")
|
||||
func (job *Job) Run(d distro.Distro) (error, []error) {
|
||||
build := pipeline.Build{
|
||||
Runner: d.Runner(),
|
||||
}
|
||||
|
||||
buildFile, err := ioutil.TempFile("", "osbuild-worker-build-env-*")
|
||||
if err != nil {
|
||||
return err, nil
|
||||
}
|
||||
defer os.Remove(buildFile.Name())
|
||||
|
||||
err = json.NewEncoder(buildFile).Encode(build)
|
||||
if err != nil {
|
||||
return err, nil
|
||||
}
|
||||
|
||||
cmd := exec.Command(
|
||||
"osbuild",
|
||||
"--store", "/var/cache/osbuild-composer/store",
|
||||
"--build-env", buildFile.Name(),
|
||||
"--json", "-",
|
||||
)
|
||||
cmd.Stderr = os.Stderr
|
||||
|
||||
stdin, err := cmd.StdinPipe()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue