cloudapi: Make container name and tag optional

If the user does not pass a name, use the distribution as a name
A provided tag is used only if name is provided. It
The tag's default is a generated using UUID to avoid collisions
This commit is contained in:
Ygal Blum 2022-08-01 18:47:20 +03:00 committed by Tom Gundersen
parent 1847a6ae05
commit ca32d7b729
4 changed files with 122 additions and 117 deletions

View file

@ -375,8 +375,17 @@ func (h *apiHandlers) PostCompose(ctx echo.Context) error {
return HTTPError(ErrorJSONUnMarshallingError)
}
var name = request.Distribution
var tag = uuid.New().String()
if containerUploadOptions.Name != nil {
name = *containerUploadOptions.Name
if containerUploadOptions.Tag != nil {
tag = *containerUploadOptions.Tag
}
}
t := target.NewContainerTarget(&target.ContainerTargetOptions{})
t.ImageName = fmt.Sprintf("%s:%s", containerUploadOptions.Name, containerUploadOptions.Tag)
t.ImageName = fmt.Sprintf("%s:%s", name, tag)
t.OsbuildArtifact.ExportFilename = imageType.Filename()
irTarget = t