worker: implement koji job types
The three new job types osbuild-koji, koji-init, and koji-finalize allows the different tasks to be split appart and in particular for there to be several builds on different architectures as part of a given compose.
This commit is contained in:
parent
a2895376ae
commit
0e382e9cf4
6 changed files with 429 additions and 0 deletions
|
|
@ -25,6 +25,8 @@ type Job interface {
|
|||
Id() uuid.UUID
|
||||
Type() string
|
||||
Args(args interface{}) error
|
||||
DynamicArgs(i int, args interface{}) error
|
||||
NDynamicArgs() int
|
||||
Update(result interface{}) error
|
||||
Canceled() (bool, error)
|
||||
UploadArtifact(name string, reader io.Reader) error
|
||||
|
|
@ -151,6 +153,18 @@ func (j *job) Args(args interface{}) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (j *job) NDynamicArgs() int {
|
||||
return len(j.dynamicArgs)
|
||||
}
|
||||
|
||||
func (j *job) DynamicArgs(i int, args interface{}) error {
|
||||
err := json.Unmarshal(j.dynamicArgs[i], args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error parsing job arguments: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (j *job) Update(result interface{}) error {
|
||||
var buf bytes.Buffer
|
||||
err := json.NewEncoder(&buf).Encode(api.UpdateJobJSONRequestBody{
|
||||
|
|
|
|||
|
|
@ -26,6 +26,51 @@ type OSBuildJobResult struct {
|
|||
TargetErrors []string `json:"target_errors,omitempty"`
|
||||
}
|
||||
|
||||
type KojiInitJob struct {
|
||||
Server string `json:"server"`
|
||||
Name string `json:"name"`
|
||||
Version string `json:"version"`
|
||||
Release string `json:"release"`
|
||||
}
|
||||
|
||||
type KojiInitJobResult struct {
|
||||
BuildID uint64 `json:"build_id"`
|
||||
Token string `json:"token"`
|
||||
KojiError error `json:"koji_error"`
|
||||
}
|
||||
|
||||
type OSBuildKojiJob struct {
|
||||
Manifest distro.Manifest `json:"manifest"`
|
||||
ImageName string `json:"image_name"`
|
||||
KojiServer string `json:"koji_server"`
|
||||
KojiDirectory string `json:"koji_directory"`
|
||||
KojiFilename string `json:"koji_filename"`
|
||||
}
|
||||
|
||||
type OSBuildKojiJobResult struct {
|
||||
HostOS string `json:"host_os"`
|
||||
Arch string `json:"arch"`
|
||||
OSBuildOutput *osbuild.Result `json:"osbuild_output"`
|
||||
ImageHash string `json:"image_hash"`
|
||||
ImageSize uint64 `json:"image_size"`
|
||||
KojiError error `json:"koji_error"`
|
||||
}
|
||||
|
||||
type KojiFinalizeJob struct {
|
||||
Server string `json:"server"`
|
||||
Name string `json:"name"`
|
||||
Version string `json:"version"`
|
||||
Release string `json:"release"`
|
||||
KojiFilenames []string `json:"koji_filenames"`
|
||||
KojiDirectory string `json:"koji_directory"`
|
||||
TaskID uint64 `json:"task_id"` /* https://pagure.io/koji/issue/215 */
|
||||
StartTime uint64 `json:"start_time"`
|
||||
}
|
||||
|
||||
type KojiFinalizeJobResult struct {
|
||||
KojiError error `json:"koji_error"`
|
||||
}
|
||||
|
||||
//
|
||||
// JSON-serializable types for the HTTP API
|
||||
//
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue