From c3377247687f1f8aceecaf72d5f714b4c1aef5ca Mon Sep 17 00:00:00 2001 From: Derek Burdick Date: Thu, 30 Mar 2023 23:33:48 -0400 Subject: [PATCH] Return helpful message if --module-path or COSIGN_PKCS11_MODULE_PATH is not set Signed-off-by: Derek Burdick --- cmd/cosign/cli/pkcs11cli/commands.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/cosign/cli/pkcs11cli/commands.go b/cmd/cosign/cli/pkcs11cli/commands.go index fd356515c03..6d4609f5161 100644 --- a/cmd/cosign/cli/pkcs11cli/commands.go +++ b/cmd/cosign/cli/pkcs11cli/commands.go @@ -205,6 +205,9 @@ func GetKeysInfo(_ context.Context, modulePath string, slotID uint, pin string) } func ListTokensCmd(ctx context.Context, modulePath string) error { + if modulePath == "" { + return fmt.Errorf("please specify --module-path or set COSIGN_PKCS11_MODULE_PATH") + } tokens, err := GetTokens(ctx, modulePath) if err != nil { return err @@ -223,6 +226,9 @@ func ListTokensCmd(ctx context.Context, modulePath string) error { } func ListKeysUrisCmd(ctx context.Context, modulePath string, slotID uint, pin string) error { + if modulePath == "" { + return fmt.Errorf("please specify --module-path or set COSIGN_PKCS11_MODULE_PATH") + } keysInfo, err := GetKeysInfo(ctx, modulePath, slotID, pin) if err != nil { return err