From 764743c7344c349a4a3c0ba77dd7d6ac04c4ec86 Mon Sep 17 00:00:00 2001 From: Adrian Stobbe Date: Fri, 22 Sep 2023 16:09:47 +0200 Subject: [PATCH] fixup! fix delete + behavior without any version --- internal/api/attestationconfigapi/cli/delete.go | 8 +++++++- internal/api/attestationconfigapi/cli/main.go | 4 ++-- internal/api/fetcher/fetcher.go | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/internal/api/attestationconfigapi/cli/delete.go b/internal/api/attestationconfigapi/cli/delete.go index 55c9a7f12c4..2b602e04cf0 100644 --- a/internal/api/attestationconfigapi/cli/delete.go +++ b/internal/api/attestationconfigapi/cli/delete.go @@ -74,12 +74,18 @@ func runDelete(cmd *cobra.Command, _ []string) (retErr error) { return fmt.Errorf("getting distribution: %w", err) } + windowSize, err := cmd.Flags().GetInt("cache-window-size") + if err != nil { + return fmt.Errorf("getting cache window size: %w", err) + } + cfg := staticupload.Config{ Bucket: bucket, Region: region, DistributionID: distribution, } - client, clientClose, err := attestationconfigapi.NewClient(cmd.Context(), cfg, []byte(cosignPwd), []byte(privateKey), false, log) + client, clientClose, err := attestationconfigapi.NewClient(cmd.Context(), cfg, + []byte(cosignPwd), []byte(privateKey), false, windowSize, log) if err != nil { return fmt.Errorf("create attestation client: %w", err) } diff --git a/internal/api/attestationconfigapi/cli/main.go b/internal/api/attestationconfigapi/cli/main.go index 9279e068c3c..785f2753306 100644 --- a/internal/api/attestationconfigapi/cli/main.go +++ b/internal/api/attestationconfigapi/cli/main.go @@ -133,8 +133,8 @@ func runCmd(cmd *cobra.Command, _ []string) (retErr error) { url := "https://d33dzgxuwsgbpw.cloudfront.net" latestAPIVersionAPI, err := attestationconfigapi.NewFetcherWithCustomCDN(url).FetchAzureSEVSNPVersionLatest(ctx) if err != nil { - if errors.Is(err, attestationconfigapi.ErrNoVersionsFound) && flags.force { - log.Infof("No versions found in API, but assuming that we are uploading the first version.\n") + if errors.Is(err, attestationconfigapi.ErrNoVersionsFound) { + log.Infof("No versions found in API, but assuming that we are uploading the first version.") } else { return fmt.Errorf("fetching latest version: %w", err) } diff --git a/internal/api/fetcher/fetcher.go b/internal/api/fetcher/fetcher.go index a64db745bc0..c9503b3b459 100644 --- a/internal/api/fetcher/fetcher.go +++ b/internal/api/fetcher/fetcher.go @@ -130,7 +130,7 @@ type apiObject interface { // signature manages the signature of a object saved at location 'Signed'. type signature struct { // Signed is the object that is signed. - Signed string `json:"signed"` + Signed string `json:"-"` // Signature is the signature of `Signed`. Signature []byte `json:"signature"` }