cloudapi: make Bucket optional in GCPUploadOptions

GCP Bucket to use can be now configured in the worker configuration.
Make the `Bucket` optional in the Cloud API when uploading image to GCP.

Adjust the Cloud API test case to configure GCP Bucket on the worker and
not provide it in the API request.
This commit is contained in:
Tomáš Hozza 2022-09-27 11:17:12 +02:00 committed by Ondřej Budai
parent ad34043087
commit 809107cd45
5 changed files with 80 additions and 73 deletions

View file

@ -448,10 +448,14 @@ func (h *apiHandlers) PostCompose(ctx echo.Context) error {
}
imageName := fmt.Sprintf("composer-api-%s", uuid.New().String())
var bucket string
if gcpUploadOptions.Bucket != nil {
bucket = *gcpUploadOptions.Bucket
}
t := target.NewGCPTarget(&target.GCPTargetOptions{
Region: gcpUploadOptions.Region,
Os: imageType.Arch().Distro().Name(), // not exposed in cloudapi
Bucket: gcpUploadOptions.Bucket,
Bucket: bucket,
// the uploaded object must have a valid extension
Object: fmt.Sprintf("%s.tar.gz", imageName),
ShareWithAccounts: share,