worker: deprecate the local target
Add "image_name" and "stream_optimized" fields to the osbuild job as replacement for the local target options. The former signifies the name of the uploaded artifact and whether an artifact should be uploaded at all (only weldr API). The latter will be deprecated at some point, when osbuild itself can make streamoptimized vmdk images. This change separates what have always been two distinct concepts: artifacts that are reported back to the composer node (in practice always running on the same machine), and upload targets to clouds and such. Separating them makes it easier to add job types that only allow one upload target while keeping artifacts. Keep the local target around, so that jobs that are scheduled can still be run after an upgrade.
This commit is contained in:
parent
d1f322ec6f
commit
0cd7174598
9 changed files with 66 additions and 65 deletions
|
|
@ -119,14 +119,14 @@ func RunJob(job worker.Job, store string, kojiServers map[string]koji.GSSAPICred
|
|||
}
|
||||
}()
|
||||
|
||||
manifest, targets, err := job.OSBuildArgs()
|
||||
args, err := job.OSBuildArgs()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
start_time := time.Now()
|
||||
|
||||
result, err := RunOSBuild(manifest, store, outputDirectory, os.Stderr)
|
||||
result, err := RunOSBuild(args.Manifest, store, outputDirectory, os.Stderr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -138,9 +138,29 @@ func RunJob(job worker.Job, store string, kojiServers map[string]koji.GSSAPICred
|
|||
return result, nil
|
||||
}
|
||||
|
||||
if args.ImageName != "" {
|
||||
var f *os.File
|
||||
imagePath := path.Join(outputDirectory, args.ImageName)
|
||||
if args.StreamOptimized {
|
||||
f, err = vmware.OpenAsStreamOptimizedVmdk(imagePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
f, err = os.Open(imagePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
err = job.UploadArtifact(args.ImageName, f)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
var r []error
|
||||
|
||||
for _, t := range targets {
|
||||
for _, t := range args.Targets {
|
||||
switch options := t.Options.(type) {
|
||||
case *target.LocalTargetOptions:
|
||||
var f *os.File
|
||||
|
|
@ -322,12 +342,12 @@ func RunJob(job worker.Job, store string, kojiServers map[string]koji.GSSAPICred
|
|||
}
|
||||
|
||||
func FailJob(job worker.Job, kojiServers map[string]koji.GSSAPICredentials) {
|
||||
_, targets, err := job.OSBuildArgs()
|
||||
args, err := job.OSBuildArgs()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
for _, t := range targets {
|
||||
for _, t := range args.Targets {
|
||||
switch options := t.Options.(type) {
|
||||
case *target.KojiTargetOptions:
|
||||
// Koji for some reason needs TLS renegotiation enabled.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue