mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-05 07:45:27 -04:00
config: Azure SNP tool can delete specific version from attestation API (#1863)
* client supports delete version * rename to new attestation / fetcher naming * add delete command to upload tool * test client delete * bazel update * use general client in attestation client * Update hack/configapi/cmd/delete.go Co-authored-by: Daniel Weiße <66256922+daniel-weisse@users.noreply.github.com> * daniel feedback * unit test azure sev upload * Update hack/configapi/cmd/delete.go Co-authored-by: Daniel Weiße <66256922+daniel-weisse@users.noreply.github.com> * add client integration test * new client cmds use apiObject --------- Co-authored-by: Daniel Weiße <66256922+daniel-weisse@users.noreply.github.com>
This commit is contained in:
parent
315b6c2f01
commit
c446f36b0f
22 changed files with 549 additions and 228 deletions
63
hack/configapi/cmd/delete.go
Normal file
63
hack/configapi/cmd/delete.go
Normal file
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
Copyright (c) Edgeless Systems GmbH
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/edgelesssys/constellation/v2/internal/api/attestationconfig/client"
|
||||
"github.com/edgelesssys/constellation/v2/internal/staticupload"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// newDeleteCmd creates the delete command.
|
||||
func newDeleteCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "delete",
|
||||
Short: "delete a specific version from the config api",
|
||||
RunE: runDelete,
|
||||
}
|
||||
cmd.Flags().StringP("version", "v", "", "Name of the version to delete (without .json suffix)")
|
||||
must(enforceRequiredFlags(cmd, "version"))
|
||||
return cmd
|
||||
}
|
||||
|
||||
type deleteCmd struct {
|
||||
attestationClient deleteClient
|
||||
}
|
||||
|
||||
type deleteClient interface {
|
||||
DeleteAzureSEVSNPVersion(ctx context.Context, versionStr string) error
|
||||
}
|
||||
|
||||
func (d deleteCmd) delete(cmd *cobra.Command) error {
|
||||
version, err := cmd.Flags().GetString("version")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return d.attestationClient.DeleteAzureSEVSNPVersion(cmd.Context(), version)
|
||||
}
|
||||
|
||||
func runDelete(cmd *cobra.Command, _ []string) error {
|
||||
cfg := staticupload.Config{
|
||||
Bucket: awsBucket,
|
||||
Region: awsRegion,
|
||||
}
|
||||
repo, closefn, err := client.New(cmd.Context(), cfg, []byte(cosignPwd), []byte(privateKey), false, log())
|
||||
if err != nil {
|
||||
return fmt.Errorf("create attestation client: %w", err)
|
||||
}
|
||||
defer func() {
|
||||
if err := closefn(cmd.Context()); err != nil {
|
||||
cmd.Printf("close client: %s\n", err.Error())
|
||||
}
|
||||
}()
|
||||
deleteCmd := deleteCmd{
|
||||
attestationClient: repo,
|
||||
}
|
||||
return deleteCmd.delete(cmd)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue