Skip to content

Commit e19db8d

Browse files
committed
Change naming of function and struct and clean up code
Signed-off-by: Omar Miraj <[email protected]>
1 parent fa1dd73 commit e19db8d

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

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: fileProvisioner{},
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, fileProvisioner{}, 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/provisioner.go

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

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

31-
func IsNgrokAPIKeySupported() bool {
31+
func HasEnvVarSupport() bool {
3232
currentVersion, err := getNgrokVersion()
3333
if err != nil {
3434
// When ngrok version check fails for any reason,
@@ -49,10 +49,9 @@ func IsNgrokAPIKeySupported() bool {
4949
return false
5050
}
5151

52-
func (f fileProvisioner) Provision(ctx context.Context, in sdk.ProvisionInput, out *sdk.ProvisionOutput) {
53-
ngrokProvisioner := IsNgrokAPIKeySupported()
52+
func (p ngrokProvisioner) Provision(ctx context.Context, in sdk.ProvisionInput, out *sdk.ProvisionOutput) {
5453

55-
if ngrokProvisioner {
54+
if ngrokProvisioner := HasEnvVarSupport(); ngrokProvisioner {
5655
out.AddEnvVar("NGROK_AUTHTOKEN", in.ItemFields[fieldname.Authtoken])
5756
out.AddEnvVar("NGROK_API_KEY", in.ItemFields[fieldname.APIKey])
5857
return
@@ -145,10 +144,10 @@ func getNgrokVersion() (string, error) {
145144
return currentVersion, nil
146145
}
147146

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

152-
func (f fileProvisioner) Description() string {
151+
func (p ngrokProvisioner) Description() string {
153152
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."
154153
}

0 commit comments

Comments
 (0)