Skip to content

Commit

Permalink
fixup! fix delete + behavior without any version
Browse files Browse the repository at this point in the history
  • Loading branch information
elchead committed Sep 22, 2023
1 parent 7fd1c5b commit 764743c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion internal/api/attestationconfigapi/cli/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/api/attestationconfigapi/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/api/fetcher/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand Down

0 comments on commit 764743c

Please sign in to comment.