Skip to content

Commit

Permalink
image: only archive release images + QEMU / OpenStack image
Browse files Browse the repository at this point in the history
  • Loading branch information
malt3 committed Jan 5, 2024
1 parent 8f234cc commit 3d9404f
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions image/upload/internal/cmd/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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 {
Expand Down Expand Up @@ -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() == "-"
}

0 comments on commit 3d9404f

Please sign in to comment.