Skip to content

Commit

Permalink
cloudapi/v2: support local upload target
Browse files Browse the repository at this point in the history
The target validation rework broke the local upload target, which is
needed for cockpit-image-builder.
  • Loading branch information
croissanne authored and achilleas-k committed Jan 22, 2025
1 parent 7c101fd commit 425581f
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 82 deletions.
27 changes: 27 additions & 0 deletions internal/cloudapi/v2/imagerequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,31 @@ func targetSupportMap() map[UploadTypes]map[ImageTypes]bool {
ImageTypesEdgeCommit: true,
ImageTypesIotCommit: true,
},
UploadTypesLocal: {
ImageTypesAws: true,
ImageTypesAwsRhui: true,
ImageTypesAwsHaRhui: true,
ImageTypesAwsSapRhui: true,
ImageTypesAzure: true,
ImageTypesAzureRhui: true,
ImageTypesAzureEap7Rhui: true,
ImageTypesAzureSapRhui: true,
ImageTypesEdgeCommit: true,
ImageTypesEdgeContainer: true,
ImageTypesEdgeInstaller: true,
ImageTypesGuestImage: true,
ImageTypesImageInstaller: true,
ImageTypesIotBootableContainer: true,
ImageTypesIotCommit: true,
ImageTypesIotInstaller: true,
ImageTypesIotRawImage: true,
ImageTypesLiveInstaller: true,
ImageTypesMinimalRaw: true,
ImageTypesOci: true,
ImageTypesVsphereOva: true,
ImageTypesVsphere: true,
ImageTypesWsl: true,
},
}
}

Expand Down Expand Up @@ -437,6 +462,8 @@ func getTarget(targetType UploadTypes, options UploadOptions, request *ComposeRe
case UploadTypesPulpOstree:
irTarget, err = newPulpOSTreeTarget(options, imageType)

case UploadTypesLocal:
irTarget = target.NewWorkerServerTarget()
default:
return nil, HTTPError(ErrorInvalidUploadTarget)
}
Expand Down
6 changes: 6 additions & 0 deletions internal/cloudapi/v2/imagerequest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ func TestGetTargets(t *testing.T) {
includeDefault: true,
expected: []target.TargetName{target.TargetNameAWSS3, target.TargetNameAWSS3},
},
"guest:local": {
imageType: ImageTypesGuestImage,
targets: []UploadTypes{UploadTypesLocal},
includeDefault: false,
expected: []target.TargetName{target.TargetNameWorkerServer},
},
"guest:azure:fail": {
imageType: ImageTypesGuestImage,
targets: []UploadTypes{UploadTypesAzure},
Expand Down
158 changes: 78 additions & 80 deletions internal/cloudapi/v2/openapi.v2.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions internal/cloudapi/v2/openapi.v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1226,8 +1226,7 @@ components:
default: false
description: |
This is used in combination with the OSBUILD_LOCALSAVE environmental
variable on the server to enable saving the compose locally. This
is for development use only, and is not available to users.
variable on the server to enable saving the compose locally.
AWSEC2UploadOptions:
type: object
additionalProperties: false
Expand Down

0 comments on commit 425581f

Please sign in to comment.