From e28fca493c2df3c0af2c47995ee6f2bf290b7cde Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Tue, 12 May 2020 01:43:02 +0200 Subject: [PATCH] store/json: split newComposesFromV0() Not a functional change, just for readability. Signed-off-by: Tom Gundersen --- internal/store/json.go | 53 +++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/internal/store/json.go b/internal/store/json.go index 70503f7e2..5334d2a2f 100644 --- a/internal/store/json.go +++ b/internal/store/json.go @@ -95,30 +95,7 @@ func newComposesFromV0(composesStruct composesV0, arch distro.Arch) map[uuid.UUI composes := make(map[uuid.UUID]Compose) for composeID, composeStruct := range composesStruct { - c := Compose{ - Blueprint: composeStruct.Blueprint, - } - for _, imgBuild := range composeStruct.ImageBuilds { - imgType := imageTypeFromCompatString(imgBuild.ImageType, arch) - if imgType == nil { - // Invalid type strings in serialization format, this may happen - // on upgrades. Ignore the image build. - continue - } - ib := ImageBuild{ - ID: imgBuild.ID, - ImageType: imgType, - Manifest: imgBuild.Manifest, - Targets: imgBuild.Targets, - JobCreated: imgBuild.JobCreated, - JobStarted: imgBuild.JobStarted, - JobFinished: imgBuild.JobFinished, - Size: imgBuild.Size, - JobID: imgBuild.JobID, - QueueStatus: imgBuild.QueueStatus, - } - c.ImageBuilds = append(c.ImageBuilds, ib) - } + c := newComposeFromV0(composeStruct, arch) if len(c.ImageBuilds) == 0 { // In case no valid image builds were found, ignore the compose. continue @@ -129,6 +106,34 @@ func newComposesFromV0(composesStruct composesV0, arch distro.Arch) map[uuid.UUI return composes } +func newComposeFromV0(composeStruct composeV0, arch distro.Arch) Compose { + c := Compose{ + Blueprint: composeStruct.Blueprint, + } + for _, imgBuild := range composeStruct.ImageBuilds { + imgType := imageTypeFromCompatString(imgBuild.ImageType, arch) + if imgType == nil { + // Invalid type strings in serialization format, this may happen + // on upgrades. Ignore the image build. + continue + } + ib := ImageBuild{ + ID: imgBuild.ID, + ImageType: imgType, + Manifest: imgBuild.Manifest, + Targets: imgBuild.Targets, + JobCreated: imgBuild.JobCreated, + JobStarted: imgBuild.JobStarted, + JobFinished: imgBuild.JobFinished, + Size: imgBuild.Size, + JobID: imgBuild.JobID, + QueueStatus: imgBuild.QueueStatus, + } + c.ImageBuilds = append(c.ImageBuilds, ib) + } + return c +} + func newSourceConfigsFromV0(sourcesStruct sourcesV0) map[string]SourceConfig { sources := make(map[string]SourceConfig)