Skip to content

Commit

Permalink
files modified
Browse files Browse the repository at this point in the history
  • Loading branch information
siddhikhapare committed Jun 29, 2023
1 parent addf6f1 commit b58afee
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
16 changes: 8 additions & 8 deletions plugins/upstash/api_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
func APIKey() schema.CredentialType {
return schema.CredentialType{
Name: credname.APIKey,
DocsURL: sdk.URL("https://docs.upstash.com/redis/account/developerapi#create-an-api-key"),
ManagementURL: sdk.URL("https://console.upstash.com/account/api"),
DocsURL: sdk.URL("https://docs.upstash.com/redis/account/developerapi#create-an-api-key"),
ManagementURL: sdk.URL("https://console.upstash.com/account/api"),
Fields: []schema.CredentialField{
{
Name: fieldname.APIKey,
Expand All @@ -42,16 +42,16 @@ func APIKey() schema.CredentialType {
},
},
},
DefaultProvisioner: provision.EnvVars(defaultEnvVarMapping),
DefaultProvisioner: provision.EnvVars(defaultEnvVarMapping),
Importer: importer.TryAll(
importer.TryEnvVarPair(defaultEnvVarMapping),
TryUpstashConfigFile(),
)}
}

var defaultEnvVarMapping = map[string]sdk.FieldName{
"UPSTASH_API_KEY": fieldname.APIKey,
"UPSTASH_EMAIL" : fieldname.Email,
"UPSTASH_API_KEY": fieldname.APIKey,
"UPSTASH_EMAIL": fieldname.Email,
}

func TryUpstashConfigFile() sdk.Importer {
Expand All @@ -69,13 +69,13 @@ func TryUpstashConfigFile() sdk.Importer {
out.AddCandidate(sdk.ImportCandidate{
Fields: map[sdk.FieldName]string{
fieldname.APIKey: config.APIKey,
fieldname.Email : config.Email,
fieldname.Email: config.Email,
},
})
})
}

type Config struct {
APIKey string `json:"apiKey"`
Email string `json:"email"`
APIKey string `json:"apiKey"`
Email string `json:"email"`
}
20 changes: 10 additions & 10 deletions plugins/upstash/api_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ package upstash

import (
"testing"

"github.com/1Password/shell-plugins/sdk"
"github.com/1Password/shell-plugins/sdk/plugintest"
"github.com/1Password/shell-plugins/sdk/schema/fieldname"
)

func TestAPIKeyProvisioner(t *testing.T) {
plugintest.TestProvisioner(t, APIKey().DefaultProvisioner, map[string]plugintest.ProvisionCase{
"default": {
ItemFields: map[sdk.FieldName]string{
ItemFields: map[sdk.FieldName]string{
fieldname.APIKey: "d68850db-69f7-qxe9pubcmjnqfgyexample",
fieldname.Email : "fakememail12@gmail.com",
fieldname.Email: "fakememail12@gmail.com",
},
ExpectedOutput: sdk.ProvisionOutput{
Environment: map[string]string{
"UPSTASH_API_KEY": "d68850db-69f7-qxe9pubcmjnqfgyexample",
"UPSTASH_EMAIL" : "fakememail12@gmail.com",
"UPSTASH_EMAIL": "fakememail12@gmail.com",
},
},
},
Expand All @@ -28,20 +28,20 @@ func TestAPIKeyProvisioner(t *testing.T) {
func TestAPIKeyImporter(t *testing.T) {
plugintest.TestImporter(t, APIKey().Importer, map[string]plugintest.ImportCase{
"environment": {
Environment: map[string]string{
Environment: map[string]string{
"UPSTASH_API_KEY": "d68850db-69f7-qxe9pubcmjnqfgyexample",
"UPSTASH_EMAIL" : "fakememail12@gmail.com",
"UPSTASH_EMAIL": "fakememail12@gmail.com",
},
ExpectedCandidates: []sdk.ImportCandidate{
{
Fields: map[sdk.FieldName]string{
fieldname.APIKey: "d68850db-69f7-qxe9pubcmjnqfgyexample",
fieldname.Email : "fakememail12@gmail.com",
fieldname.Email: "fakememail12@gmail.com",
},
},
},
},

"config file": {
Files: map[string]string{
"~/.upstash.json": plugintest.LoadFixture(t, ".upstash.json"),
Expand All @@ -50,7 +50,7 @@ func TestAPIKeyImporter(t *testing.T) {
{
Fields: map[sdk.FieldName]string{
fieldname.APIKey: "d68850db-69f7-qxe9pubcmjnqfgyexample",
fieldname.Email : "fakememail12@gmail.com",
fieldname.Email: "fakememail12@gmail.com",
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion plugins/upstash/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ func New() schema.Plugin {
Name: "upstash",
Platform: schema.PlatformInfo{
Name: "Upstash",
Homepage: sdk.URL("https://upstash.com"),
Homepage: sdk.URL("https://upstash.com"),
},
Credentials: []schema.CredentialType{
APIKey(),
Expand Down
6 changes: 3 additions & 3 deletions plugins/upstash/upstash.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (

func UpstashCLI() schema.Executable {
return schema.Executable{
Name: "Upstash CLI",
Runs: []string{"upstash"},
DocsURL: sdk.URL("https://github.com/upstash/cli"),
Name: "Upstash CLI",
Runs: []string{"upstash"},
DocsURL: sdk.URL("https://github.com/upstash/cli"),
NeedsAuth: needsauth.IfAll(
needsauth.NotForHelpOrVersion(),
needsauth.NotWithoutArgs(),
Expand Down

0 comments on commit b58afee

Please sign in to comment.