From a7dd8ff94f735fa2131c8053f800dc6a8634cd80 Mon Sep 17 00:00:00 2001 From: Achilleas Koutsou Date: Fri, 17 Mar 2023 15:19:41 +0100 Subject: [PATCH] container: add ListDigest to the spec Add the ListDigest to the container Spec struct and all its copies so we can store list digests when they are available and pass them on to the appropriate osbuild stages, sources, and inputs. Copy the value whenever a spec is moved to a different representation. --- cmd/osbuild-worker/jobimpl-container-resolve.go | 11 ++++++----- internal/cloudapi/v2/server.go | 1 + internal/container/spec.go | 11 ++++++----- internal/weldr/api.go | 1 + internal/worker/json.go | 5 +++-- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/cmd/osbuild-worker/jobimpl-container-resolve.go b/cmd/osbuild-worker/jobimpl-container-resolve.go index ebeaff9d9..b92f5c893 100644 --- a/cmd/osbuild-worker/jobimpl-container-resolve.go +++ b/cmd/osbuild-worker/jobimpl-container-resolve.go @@ -42,11 +42,12 @@ func (impl *ContainerResolveJobImpl) Run(job worker.Job) error { } else { for i, spec := range specs { result.Specs[i] = worker.ContainerSpec{ - Source: spec.Source, - Name: spec.LocalName, - TLSVerify: spec.TLSVerify, - ImageID: spec.ImageID, - Digest: spec.Digest, + Source: spec.Source, + Name: spec.LocalName, + TLSVerify: spec.TLSVerify, + ImageID: spec.ImageID, + Digest: spec.Digest, + ListDigest: spec.ListDigest, } } } diff --git a/internal/cloudapi/v2/server.go b/internal/cloudapi/v2/server.go index 7c863c36d..5bb70e0a2 100644 --- a/internal/cloudapi/v2/server.go +++ b/internal/cloudapi/v2/server.go @@ -434,6 +434,7 @@ func generateManifest(ctx context.Context, workers *worker.Server, depsolveJobID containerSpecs[i].LocalName = s.Name containerSpecs[i].TLSVerify = s.TLSVerify containerSpecs[i].ImageID = s.ImageID + containerSpecs[i].ListDigest = s.ListDigest } } diff --git a/internal/container/spec.go b/internal/container/spec.go index ffd781c8d..b7bfbe37e 100644 --- a/internal/container/spec.go +++ b/internal/container/spec.go @@ -11,11 +11,12 @@ import ( // at the Source via Digest and ImageID. The latter one // should remain the same in the target image as well. type Spec struct { - Source string // does not include the manifest digest - Digest string // digest of the manifest at the Source - TLSVerify *bool // controls TLS verification - ImageID string // container image identifier - LocalName string // name to use inside the image + Source string // does not include the manifest digest + Digest string // digest of the manifest at the Source + TLSVerify *bool // controls TLS verification + ImageID string // container image identifier + LocalName string // name to use inside the image + ListDigest string // digest of the list manifest at the Source (optional) } // NewSpec creates a new Spec from the essential information. diff --git a/internal/weldr/api.go b/internal/weldr/api.go index 4f473743b..fc040b793 100644 --- a/internal/weldr/api.go +++ b/internal/weldr/api.go @@ -2306,6 +2306,7 @@ func (api *API) resolveContainersForImageType(bp blueprint.Blueprint, imageType specs[i].LocalName = s.Name specs[i].TLSVerify = s.TLSVerify specs[i].ImageID = s.ImageID + specs[i].ListDigest = s.ListDigest } return specs, nil diff --git a/internal/worker/json.go b/internal/worker/json.go index a8813d5db..9c5268451 100644 --- a/internal/worker/json.go +++ b/internal/worker/json.go @@ -253,8 +253,9 @@ type ContainerSpec struct { Name string `json:"name"` TLSVerify *bool `json:"tls-verify,omitempty"` - ImageID string `json:"image_id"` - Digest string `json:"digest"` + ImageID string `json:"image_id"` + Digest string `json:"digest"` + ListDigest string `json:"list-digest,omitempty"` } type ContainerResolveJob struct {