cloudapi: expose upload status

Expose a more detailed job status result - specifically, include upload status
alongside image status. Expand openapi.yml accordingly and add an UploadStatus
field to the OSBuildJobResult struct. At the moment, only represent the
"success" and "failure" states of UploadStatus - to differentiate between
"pending" and "running" would involve significant design decisions and should be
addressed in a separate commit.
This commit is contained in:
Chloe Kaubisch 2021-02-05 12:34:28 +01:00 committed by GitHub
parent 80f833a69b
commit 899d78f7e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 51 additions and 33 deletions

View file

@ -39,11 +39,6 @@ type AWSUploadRequestOptionsS3 struct {
SecretAccessKey string `json:"secret_access_key"`
}
// AWSUploadStatus defines model for AWSUploadStatus.
type AWSUploadStatus struct {
AmiId *string `json:"ami_id,omitempty"`
}
// ComposeRequest defines model for ComposeRequest.
type ComposeRequest struct {
Customizations *Customizations `json:"customizations,omitempty"`
@ -58,8 +53,7 @@ type ComposeResult struct {
// ComposeStatus defines model for ComposeStatus.
type ComposeStatus struct {
ImageStatuses *[]ImageStatus `json:"image_statuses,omitempty"`
Status string `json:"status"`
ImageStatus ImageStatus `json:"image_status"`
}
// Customizations defines model for Customizations.
@ -77,8 +71,8 @@ type ImageRequest struct {
// ImageStatus defines model for ImageStatus.
type ImageStatus struct {
Status string `json:"status"`
UploadStatuses *[]UploadStatus `json:"upload_statuses,omitempty"`
Status string `json:"status"`
UploadStatus *UploadStatus `json:"upload_status,omitempty"`
}
// Repository defines model for Repository.
@ -101,11 +95,22 @@ type Subscription struct {
// UploadRequest defines model for UploadRequest.
type UploadRequest struct {
Options interface{} `json:"options"`
Type string `json:"type"`
Type UploadTypes `json:"type"`
}
// UploadStatus defines model for UploadStatus.
type UploadStatus interface{}
type UploadStatus struct {
Status string `json:"status"`
Type UploadTypes `json:"type"`
}
// UploadTypes defines model for UploadTypes.
type UploadTypes string
// List of UploadTypes
const (
UploadTypes_aws UploadTypes = "aws"
)
// ComposeJSONBody defines parameters for Compose.
type ComposeJSONBody ComposeRequest

View file

@ -65,16 +65,10 @@ components:
schemas:
ComposeStatus:
required:
- status
- image_status
properties:
status:
type: string
enum: ['success', 'failure', 'pending', 'running']
example: 'success'
image_statuses:
type: array
items:
$ref: '#/components/schemas/ImageStatus'
image_status:
$ref: '#/components/schemas/ImageStatus'
ImageStatus:
required:
- status
@ -83,13 +77,18 @@ components:
type: string
enum: ['success', 'failure', 'pending', 'building', 'uploading', 'registering']
example: 'success'
upload_statuses:
type: array
items:
$ref: '#/components/schemas/UploadStatus'
upload_status:
$ref: '#/components/schemas/UploadStatus'
UploadStatus:
oneOf:
- $ref: '#/components/schemas/AWSUploadStatus'
required:
- status
- type
properties:
status:
type: string
enum: ['success', 'failure', 'pending', 'running']
type:
$ref: '#/components/schemas/UploadTypes'
AWSUploadStatus:
type: object
properties:
@ -158,11 +157,13 @@ components:
- options
properties:
type:
type: string
enum: ['aws']
$ref: '#/components/schemas/UploadTypes'
options:
oneOf:
- $ref: '#/components/schemas/AWSUploadRequestOptions'
UploadTypes:
type: string
enum: ['aws']
AWSUploadRequestOptions:
type: object
required:

View file

@ -248,10 +248,11 @@ func (server *Server) ComposeStatus(w http.ResponseWriter, r *http.Request, id s
}
response := ComposeStatus{
Status: composeStatusFromJobStatus(status, &result),
ImageStatuses: &[]ImageStatus{
{
Status: composeStatusFromJobStatus(status, &result),
ImageStatus: ImageStatus{
Status: composeStatusFromJobStatus(status, &result),
UploadStatus: &UploadStatus{
Status: result.UploadStatus,
Type: "aws",
},
},
}