cloudapi/v2: Fix generated GCP name

The generated gcp name had an invalid `.tar.gz` extension. This
extension still needs to be supplied for the object name however.

The integration tests supply the image name rather than relying in the
generated one, which is why this slipped through.
This commit is contained in:
Sanne Raymaekers 2022-04-25 14:32:58 +02:00
parent 0eff6c3de7
commit e258947a58

View file

@ -376,21 +376,21 @@ func (h *apiHandlers) PostCompose(ctx echo.Context) error {
share = *gcpUploadOptions.ShareWithAccounts
}
// the uploaded object must have a valid extension
object := fmt.Sprintf("composer-api-%s.tar.gz", uuid.New().String())
imageName := fmt.Sprintf("composer-api-%s", uuid.New().String())
t := target.NewGCPTarget(&target.GCPTargetOptions{
Filename: imageType.Filename(),
Region: gcpUploadOptions.Region,
Os: imageType.Arch().Distro().Name(), // not exposed in cloudapi
Bucket: gcpUploadOptions.Bucket,
Object: object,
Filename: imageType.Filename(),
Region: gcpUploadOptions.Region,
Os: imageType.Arch().Distro().Name(), // not exposed in cloudapi
Bucket: gcpUploadOptions.Bucket,
// the uploaded object must have a valid extension
Object: fmt.Sprintf("%s.tar.gz", imageName),
ShareWithAccounts: share,
})
// Import will fail if an image with this name already exists
if gcpUploadOptions.ImageName != nil {
t.ImageName = *gcpUploadOptions.ImageName
} else {
t.ImageName = object
t.ImageName = imageName
}
irTarget = t