From 891e413b8bbc3805c62eba7b3a49d3dbc1acde19 Mon Sep 17 00:00:00 2001 From: Simon McCartney Date: Tue, 18 Jun 2024 21:45:07 +0100 Subject: [PATCH 1/2] feat(aws): Add support AWS SAM CLI --- plugins/aws/plugin.go | 1 + plugins/aws/sam.go | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 plugins/aws/sam.go diff --git a/plugins/aws/plugin.go b/plugins/aws/plugin.go index a19eeca1a..05a6494ed 100644 --- a/plugins/aws/plugin.go +++ b/plugins/aws/plugin.go @@ -18,6 +18,7 @@ func New() schema.Plugin { Executables: []schema.Executable{ AWSCLI(), AWSCDKToolkit(), + AWSSAMCLI(), }, } } diff --git a/plugins/aws/sam.go b/plugins/aws/sam.go new file mode 100644 index 000000000..b53cb688e --- /dev/null +++ b/plugins/aws/sam.go @@ -0,0 +1,26 @@ +package aws + +import ( + "github.com/1Password/shell-plugins/sdk" + "github.com/1Password/shell-plugins/sdk/needsauth" + "github.com/1Password/shell-plugins/sdk/schema" + "github.com/1Password/shell-plugins/sdk/schema/credname" +) + +func AWSSAMCLI() schema.Executable { + return schema.Executable{ + Name: "AWS SAM CLI", + Runs: []string{"sam"}, + DocsURL: sdk.URL("https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/reference-sam-cli.html"), + NeedsAuth: needsauth.IfAll( + needsauth.NotForHelpOrVersion(), + needsauth.NotWithoutArgs(), + ), + Uses: []schema.CredentialUsage{ + { + Name: credname.AccessKey, + Provisioner: CLIProvisioner{}, + }, + }, + } +} From 2fb25d7078e0719f62d0e3abcdce5cc46a7f583d Mon Sep 17 00:00:00 2001 From: Simon McCartney Date: Wed, 19 Jun 2024 12:32:19 +0100 Subject: [PATCH 2/2] AWS SAM: Skip auth on docs, init, local & validate subcommands --- plugins/aws/sam.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/aws/sam.go b/plugins/aws/sam.go index b53cb688e..33286a1c8 100644 --- a/plugins/aws/sam.go +++ b/plugins/aws/sam.go @@ -15,6 +15,11 @@ func AWSSAMCLI() schema.Executable { NeedsAuth: needsauth.IfAll( needsauth.NotForHelpOrVersion(), needsauth.NotWithoutArgs(), + // skip 1Password authentication for "sam docs", "sam init", "sam local" and "sam validate" and their subcommands + needsauth.NotWhenContainsArgs("docs"), + needsauth.NotWhenContainsArgs("init"), + needsauth.NotWhenContainsArgs("local"), + needsauth.NotWhenContainsArgs("validate"), ), Uses: []schema.CredentialUsage{ {