target: add explicit target for uploading back to worker server
The uploading of artifacts back to the worker server for the on-premise (Weldr) use case was signaled to the worker by setting the `ImageName` in the `OSBuildJob` definition. The code also relies on the osbuild exports being specified in the `OSBuildJob`, instead of in the target (this is not implemented yet). Prepare the ground for moving osbuild export definition from `OSBuildJob` to `Target` by introducing an explicit `Worker Server" upload target. This target will signal to the worker that it should upload the image back to the worker server. The new target is not yet used by any API implementation. Extend the worker osbuild job implementation to handle the new upload target.
This commit is contained in:
parent
a61b8af261
commit
a12827865d
3 changed files with 39 additions and 0 deletions
|
|
@ -362,6 +362,22 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
for _, jobTarget := range jobArgs.Targets {
|
||||
var targetResult *target.TargetResult
|
||||
switch targetOptions := jobTarget.Options.(type) {
|
||||
case *target.WorkerServerTargetOptions:
|
||||
targetResult = target.NewWorkerServerTargetResult()
|
||||
var f *os.File
|
||||
imagePath := path.Join(outputDirectory, exportPath, jobTarget.OsbuildArtifact.ExportFilename)
|
||||
f, err = os.Open(imagePath)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, err.Error())
|
||||
break
|
||||
}
|
||||
defer f.Close()
|
||||
err = job.UploadArtifact(jobTarget.ImageName, f)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error())
|
||||
break
|
||||
}
|
||||
|
||||
case *target.VMWareTargetOptions:
|
||||
targetResult = target.NewVMWareTargetResult()
|
||||
credentials := vmware.Credentials{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue