osbuild-worker: add target for upload to vmware

New upload target for VMWare, similar to the ones for AWS and Azure,
allowing users to set credentials for their vSphere instance.
Commit also includes function that performs the actual upload.
This commit is contained in:
Jozef Mikovic 2021-01-11 14:20:09 +01:00 committed by Tom Gundersen
parent d686abfffb
commit 1a81489ef1
4 changed files with 81 additions and 0 deletions

View file

@ -137,6 +137,35 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
r = append(r, err)
continue
}
case *target.VMWareTargetOptions:
// TODO
if !osbuildOutput.Success {
continue
}
var f *os.File
imagePath := path.Join(outputDirectory, options.Filename)
f, err = vmware.OpenAsStreamOptimizedVmdk(imagePath)
if err != nil {
r = append(r, err)
continue
}
// we don't need the file descriptor to be opened b/c import.vmdk operates on the file path
f.Close()
imagePath = f.Name()
credentials := vmware.Credentials{
Username: options.Username,
Password: options.Password,
Host: options.Host,
Cluster: options.Cluster,
Datacenter: options.Datacenter,
Datastore: options.Datastore,
}
err = vmware.UploadImage(credentials, imagePath, t.ImageName)
if err != nil {
r = append(r, err)
continue
}
case *target.AWSTargetOptions:
if !osbuildOutput.Success {