From 9ef9d22969259533c79ff8b4b41098f60097c23d Mon Sep 17 00:00:00 2001 From: Malte Poll <1780588+malt3@users.noreply.github.com> Date: Fri, 5 Jan 2024 09:49:11 +0100 Subject: [PATCH] image: only archive release images + QEMU / OpenStack image --- image/upload/internal/cmd/upload.go | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/image/upload/internal/cmd/upload.go b/image/upload/internal/cmd/upload.go index ce107c2347..22c8fa98ea 100644 --- a/image/upload/internal/cmd/upload.go +++ b/image/upload/internal/cmd/upload.go @@ -14,6 +14,7 @@ import ( "strings" "github.com/edgelesssys/constellation/v2/internal/api/versionsapi" + "github.com/edgelesssys/constellation/v2/internal/cloud/cloudprovider" "github.com/edgelesssys/constellation/v2/internal/osimage" ) @@ -24,10 +25,16 @@ func uploadImage(ctx context.Context, archiveC archivist, uploadC uploader, req return err } defer imageReader.Close() - archiveURL, err := archiveC.Archive(ctx, req.Version, strings.ToLower(req.Provider.String()), req.AttestationVariant, imageReader) - if err != nil { - return err + + var archiveURL string + if needsArchival(req.Provider, req.Version) { + var err error + archiveURL, err = archiveC.Archive(ctx, req.Version, strings.ToLower(req.Provider.String()), req.AttestationVariant, imageReader) + if err != nil { + return err + } } + // upload to CSP imageReferences, err := uploadC.Upload(ctx, req) if err != nil { @@ -56,3 +63,12 @@ func uploadImage(ctx context.Context, archiveC archivist, uploadC uploader, req return nil } + +func needsArchival(provider cloudprovider.Provider, version versionsapi.Version) bool { + switch provider { + case cloudprovider.OpenStack, cloudprovider.QEMU: // image upload for some CSPs only consists of this archival step + return true + } + + return version.Stream() == "stable" || version.Ref() == "-" +}