Fix bazel check complaints

Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
Daniel Weiße 2024-07-09 12:00:48 +02:00
parent 3a0ab8db86
commit 3f737240fc
No known key found for this signature in database
GPG Key ID: 7DD3015F3DDE4B9C
4 changed files with 14 additions and 8 deletions

View File

@ -1,3 +1,8 @@
/*
Copyright (c) Edgeless Systems GmbH
SPDX-License-Identifier: AGPL-3.0-only
*/
package main
import (
@ -20,7 +25,7 @@ func newCompareCmd() *cobra.Command {
Short: "Compare two or more attestation reports and return the lowest version",
Long: "Compare two or more attestation reports and return the lowest version.",
Example: "cli compare azure-sev-snp report1.json report2.json",
Args: cobra.MatchAll(cobra.MinimumNArgs(3), isAttestationVariant(0)),
Args: cobra.MatchAll(cobra.MinimumNArgs(3), arg0isAttestationVariant()),
RunE: runCompare,
}

View File

@ -30,7 +30,7 @@ func newDeleteCmd() *cobra.Command {
Short: "Delete an object from the attestationconfig API",
Long: "Delete a specific object version from the config api. <version> is the name of the object to delete (without .json suffix)",
Example: "COSIGN_PASSWORD=$CPW COSIGN_PRIVATE_KEY=$CKEY cli delete azure-sev-snp attestation-report 1.0.0",
Args: cobra.MatchAll(cobra.ExactArgs(3), isAttestationVariant(0), isValidKind(1)),
Args: cobra.MatchAll(cobra.ExactArgs(3), arg0isAttestationVariant(), isValidKind(1)),
PreRunE: envCheck,
RunE: runDelete,
}
@ -40,7 +40,7 @@ func newDeleteCmd() *cobra.Command {
Short: "delete all objects from the API path constellation/v1/attestation/<csp>",
Long: "Delete all objects from the API path constellation/v1/attestation/<csp>",
Example: "COSIGN_PASSWORD=$CPW COSIGN_PRIVATE_KEY=$CKEY cli delete recursive azure-sev-snp",
Args: cobra.MatchAll(cobra.ExactArgs(1), isAttestationVariant(0)),
Args: cobra.MatchAll(cobra.ExactArgs(1), arg0isAttestationVariant()),
RunE: runRecursiveDelete,
}

View File

@ -41,7 +41,7 @@ func newUploadCmd() *cobra.Command {
),
Example: "COSIGN_PASSWORD=$CPW COSIGN_PRIVATE_KEY=$CKEY cli upload azure-sev-snp attestation-report /some/path/report.json",
Args: cobra.MatchAll(cobra.ExactArgs(3), isAttestationVariant(0), isValidKind(1)),
Args: cobra.MatchAll(cobra.ExactArgs(3), arg0isAttestationVariant(), isValidKind(1)),
PreRunE: envCheck,
RunE: runUpload,
}

View File

@ -7,6 +7,7 @@ SPDX-License-Identifier: AGPL-3.0-only
package main
import (
"errors"
"fmt"
"strings"
@ -14,17 +15,17 @@ import (
"github.com/spf13/cobra"
)
func isAttestationVariant(arg int) cobra.PositionalArgs {
func arg0isAttestationVariant() cobra.PositionalArgs {
return func(_ *cobra.Command, args []string) error {
attestationVariant, err := variant.FromString(args[arg])
attestationVariant, err := variant.FromString(args[0])
if err != nil {
return fmt.Errorf("argument %s isn't a valid attestation variant", args[arg])
return errors.New("argument 0 isn't a valid attestation variant")
}
switch attestationVariant {
case variant.AWSSEVSNP{}, variant.AzureSEVSNP{}, variant.AzureTDX{}, variant.GCPSEVSNP{}:
return nil
default:
return fmt.Errorf("argument %s isn't a supported attestation variant", args[arg])
return errors.New("argument 0 isn't a supported attestation variant")
}
}
}