Skip to content

Commit 17dea8c

Browse files
authored
Merge branch 'main' into add-aws-sam-cli
2 parents 2fb25d7 + 6e74fd8 commit 17dea8c

File tree

10 files changed

+63
-72
lines changed

10 files changed

+63
-72
lines changed

go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ require (
5353
github.com/oklog/run v1.0.0 // indirect
5454
github.com/pmezard/go-difflib v1.0.0 // indirect
5555
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 // indirect
56-
golang.org/x/mod v0.9.0
57-
golang.org/x/net v0.23.0 // indirect
58-
golang.org/x/sys v0.18.0 // indirect
59-
golang.org/x/term v0.18.0 // indirect
60-
golang.org/x/text v0.14.0 // indirect
56+
golang.org/x/mod v0.17.0
57+
golang.org/x/net v0.33.0 // indirect
58+
golang.org/x/sys v0.28.0 // indirect
59+
golang.org/x/term v0.27.0 // indirect
60+
golang.org/x/text v0.21.0 // indirect
6161
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
6262
google.golang.org/grpc v1.56.3 // indirect
6363
)

go.sum

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
120120
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
121121
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
122122
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
123-
golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs=
124-
golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
125-
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
126-
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
123+
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
124+
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
125+
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
126+
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
127127
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
128128
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
129129
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -133,14 +133,14 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc
133133
golang.org/x/sys v0.0.0-20210819135213-f52c844e1c1c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
134134
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
135135
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
136-
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
137-
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
136+
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
137+
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
138138
golang.org/x/term v0.0.0-20210503060354-a79de5458b56/go.mod h1:tfny5GFUkzUvx4ps4ajbZsCe5lw1metzhBm9T3x7oIY=
139-
golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8=
140-
golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58=
139+
golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q=
140+
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
141141
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
142-
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
143-
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
142+
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
143+
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
144144
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
145145
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
146146
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A=

plugins/aws/eksctl.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package aws
2+
3+
import (
4+
"github.com/1Password/shell-plugins/sdk"
5+
"github.com/1Password/shell-plugins/sdk/needsauth"
6+
"github.com/1Password/shell-plugins/sdk/schema"
7+
"github.com/1Password/shell-plugins/sdk/schema/credname"
8+
)
9+
10+
func eksctlCLI() schema.Executable {
11+
return schema.Executable{
12+
Name: "eksctl CLI",
13+
Runs: []string{"eksctl"},
14+
DocsURL: sdk.URL("https://eksctl.io/"),
15+
NeedsAuth: needsauth.IfAll(
16+
needsauth.NotForHelpOrVersion(),
17+
needsauth.NotWithoutArgs(),
18+
),
19+
Uses: []schema.CredentialUsage{
20+
{
21+
Name: credname.AccessKey,
22+
Provisioner: CLIProvisioner{},
23+
},
24+
},
25+
}
26+
}

plugins/aws/plugin.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ func New() schema.Plugin {
1919
AWSCLI(),
2020
AWSCDKToolkit(),
2121
AWSSAMCLI(),
22+
eksctlCLI(),
2223
},
2324
}
2425
}

plugins/ngrok/credentials.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func Credentials() schema.CredentialType {
4545
},
4646
},
4747
},
48-
DefaultProvisioner: ngrokEnvVarProvisioner{},
48+
DefaultProvisioner: ngrokProvisioner{},
4949
Importer: importer.TryAll(
5050
importer.TryEnvVarPair(defaultEnvVarMapping),
5151
importer.MacOnly(

plugins/ngrok/credentials_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
func TestCredentialsProvisioner(t *testing.T) {
13-
plugintest.TestProvisioner(t, ngrokProvisioner(), map[string]plugintest.ProvisionCase{
13+
plugintest.TestProvisioner(t, ngrokProvisioner{}, map[string]plugintest.ProvisionCase{
1414
"temp file": {
1515
ItemFields: map[sdk.FieldName]string{
1616
fieldname.Authtoken: "cxG2Im21Yzkh8VnvFQaetlPHcQ9ZDUUk1IzzyHhcGcEXAMPLE",

plugins/ngrok/env_var_provisioner.go

Lines changed: 0 additions & 42 deletions
This file was deleted.

plugins/ngrok/ngrok.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ func ngrokCLI() schema.Executable {
2323
),
2424
Uses: []schema.CredentialUsage{
2525
{
26-
Name: credname.Credentials,
27-
Provisioner: ngrokProvisioner(),
26+
Name: credname.Credentials,
2827
},
2928
},
3029
}

plugins/ngrok/provisioner.go

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ const (
2525
envVarAuthVersion = "v3.2.1"
2626
)
2727

28-
type fileProvisioner struct {
28+
type ngrokProvisioner struct {
2929
}
3030

31-
func ngrokProvisioner() sdk.Provisioner {
31+
func HasEnvVarSupport() bool {
3232
currentVersion, err := getNgrokVersion()
3333
if err != nil {
3434
// When ngrok version check fails for any reason,
3535
// use config file to provision as a fallback
36-
return fileProvisioner{}
36+
return false
3737
}
3838

3939
// If the current ngrok CLI version is 3.2.1 or higher,
@@ -42,14 +42,21 @@ func ngrokProvisioner() sdk.Provisioner {
4242
// semver.Compare resulting in 0 means 3.2.1 is in use
4343
// semver.Compare resulting in +1 means >3.2.1 is in use
4444
if semver.Compare(currentVersion, envVarAuthVersion) >= 0 {
45-
return ngrokEnvVarProvisioner{}
45+
return true
4646
}
4747

4848
// Otherwise use config file to provision credentials
49-
return fileProvisioner{}
49+
return false
5050
}
5151

52-
func (f fileProvisioner) Provision(ctx context.Context, in sdk.ProvisionInput, out *sdk.ProvisionOutput) {
52+
func (p ngrokProvisioner) Provision(ctx context.Context, in sdk.ProvisionInput, out *sdk.ProvisionOutput) {
53+
54+
if HasEnvVarSupport() {
55+
out.AddEnvVar("NGROK_AUTHTOKEN", in.ItemFields[fieldname.Authtoken])
56+
out.AddEnvVar("NGROK_API_KEY", in.ItemFields[fieldname.APIKey])
57+
return
58+
}
59+
5360
provisionedConfigFilePath := filepath.Join(in.TempDir, "config.yml")
5461
config := make(map[string]interface{})
5562

@@ -137,10 +144,10 @@ func getNgrokVersion() (string, error) {
137144
return currentVersion, nil
138145
}
139146

140-
func (f fileProvisioner) Deprovision(ctx context.Context, in sdk.DeprovisionInput, out *sdk.DeprovisionOutput) {
141-
// nothing to do here: files get deleted automatically by 1Password CLI
147+
func (p ngrokProvisioner) Deprovision(ctx context.Context, in sdk.DeprovisionInput, out *sdk.DeprovisionOutput) {
148+
// nothing to do here: files get deleted automatically by 1Password CLI and environment variables get wiped when process exits
142149
}
143150

144-
func (f fileProvisioner) Description() string {
145-
return "Config file aware provisioner. It will first check if an already existing config file is present."
151+
func (p ngrokProvisioner) Description() string {
152+
return "If ngrok version is 3.2.1 or higher than provision ngrok credentials as environment variables NGROK_AUTH_TOKEN and NGROK_API_KEY otherwise config file aware provisioner. It will first check if an already existing config file is present."
146153
}

plugins/terraform/terraform.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func TerraformCLI() schema.Executable {
2727
NeedsAuth: needsauth.IfAny(
2828
needsauth.ForCommand("refresh"),
2929
needsauth.ForCommand("init"),
30-
needsauth.ForCommand("state", "list"),
30+
needsauth.ForCommand("state"),
3131
needsauth.ForCommand("plan"),
3232
needsauth.ForCommand("apply"),
3333
needsauth.ForCommand("destroy"),

0 commit comments

Comments
 (0)