store/json: move queue status backwards compatibility
Apply the backwards compatibility where the ImageBuild struct is assembled. This should make the code simpler to reason about, by reducing the structs we produce and later fix up. Signed-off-by: Tom Gundersen <teg@jklm.no>
This commit is contained in:
parent
cdc4b1bd53
commit
15a0e78c15
1 changed files with 10 additions and 14 deletions
|
|
@ -114,6 +114,15 @@ func newImageBuildFromV0(imageBuildStruct imageBuildV0, arch distro.Arch) (Image
|
|||
// on upgrades.
|
||||
return ImageBuild{}, errors.New("invalid Image Type string")
|
||||
}
|
||||
// Backwards compatibility: fail all builds that are queued or
|
||||
// running. Jobs status is now handled outside of the store
|
||||
// (and the compose). The fields are kept so that previously
|
||||
// succeeded builds still show up correctly.
|
||||
queueStatus := imageBuildStruct.QueueStatus
|
||||
switch queueStatus {
|
||||
case common.IBRunning, common.IBWaiting:
|
||||
queueStatus = common.IBFailed
|
||||
}
|
||||
return ImageBuild{
|
||||
ID: imageBuildStruct.ID,
|
||||
ImageType: imgType,
|
||||
|
|
@ -124,7 +133,7 @@ func newImageBuildFromV0(imageBuildStruct imageBuildV0, arch distro.Arch) (Image
|
|||
JobFinished: imageBuildStruct.JobFinished,
|
||||
Size: imageBuildStruct.Size,
|
||||
JobID: imageBuildStruct.JobID,
|
||||
QueueStatus: imageBuildStruct.QueueStatus,
|
||||
QueueStatus: queueStatus,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
@ -190,19 +199,6 @@ func newStoreFromV0(storeStruct storeV0, arch distro.Arch) *Store {
|
|||
blueprintsCommits: newCommitsFromV0(storeStruct.Commits),
|
||||
}
|
||||
|
||||
// Backwards compatibility: fail all builds that are queued or
|
||||
// running. Jobs status is now handled outside of the store
|
||||
// (and the compose). The fields are kept so that previously
|
||||
// succeeded builds still show up correctly.
|
||||
for composeID, compose := range store.composes {
|
||||
switch compose.ImageBuild.QueueStatus {
|
||||
case common.IBRunning, common.IBWaiting:
|
||||
compose.ImageBuild.QueueStatus = common.IBFailed
|
||||
store.composes[composeID] = compose
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Populate BlueprintsCommits for existing blueprints without commit history
|
||||
// BlueprintsCommits tracks the order of the commits in BlueprintsChanges,
|
||||
// but may not be in-sync with BlueprintsChanges because it was added later.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue