store: add image size to compose
When a use defines the image size for a compose this size is stored in the compose struct so that the virtual image size can be returned by the api instead of the file size of the image.
This commit is contained in:
parent
8c19364b65
commit
e30f40873d
3 changed files with 6 additions and 4 deletions
|
|
@ -59,6 +59,7 @@ type Compose struct {
|
|||
JobStarted time.Time `json:"job_started"`
|
||||
JobFinished time.Time `json:"job_finished"`
|
||||
Image *Image `json:"image"`
|
||||
Size uint64 `json:"size"`
|
||||
}
|
||||
|
||||
// A Job contains the information about a compose a worker needs to process it.
|
||||
|
|
@ -495,6 +496,7 @@ func (s *Store) PushCompose(composeID uuid.UUID, bp *blueprint.Blueprint, checks
|
|||
OutputType: composeType,
|
||||
Targets: targets,
|
||||
JobCreated: time.Now(),
|
||||
Size: size,
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1481,7 +1481,7 @@ func (api *API) composeInfoHandler(writer http.ResponseWriter, request *http.Req
|
|||
Deps Dependencies `json:"deps"` // empty for now
|
||||
ComposeType string `json:"compose_type"`
|
||||
QueueStatus string `json:"queue_status"`
|
||||
ImageSize int64 `json:"image_size"`
|
||||
ImageSize uint64 `json:"image_size"`
|
||||
Uploads []UploadResponse `json:"uploads,omitempty"`
|
||||
}
|
||||
|
||||
|
|
@ -1493,7 +1493,7 @@ func (api *API) composeInfoHandler(writer http.ResponseWriter, request *http.Req
|
|||
reply.ComposeType = compose.OutputType
|
||||
reply.QueueStatus = compose.QueueStatus
|
||||
if compose.Image != nil {
|
||||
reply.ImageSize = compose.Image.Size
|
||||
reply.ImageSize = compose.Size
|
||||
}
|
||||
|
||||
if isRequestVersionAtLeast(params, 1) {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ type ComposeEntry struct {
|
|||
Blueprint string `json:"blueprint"`
|
||||
Version string `json:"version"`
|
||||
ComposeType string `json:"compose_type"`
|
||||
ImageSize int64 `json:"image_size"`
|
||||
ImageSize uint64 `json:"image_size"`
|
||||
QueueStatus string `json:"queue_status"`
|
||||
JobCreated float64 `json:"job_created"`
|
||||
JobStarted float64 `json:"job_started,omitempty"`
|
||||
|
|
@ -43,7 +43,7 @@ func composeToComposeEntry(id uuid.UUID, compose store.Compose, includeUploads b
|
|||
|
||||
case "FINISHED":
|
||||
if compose.Image != nil {
|
||||
composeEntry.ImageSize = compose.Image.Size
|
||||
composeEntry.ImageSize = compose.Size
|
||||
} else {
|
||||
log.Printf("finished compose with id %s has nil image\n", id.String())
|
||||
composeEntry.ImageSize = 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue