Skip to content

Commit f7c423b

Browse files
committed
Added JWT in fieldname
1 parent 5857a30 commit f7c423b

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

plugins/cohere/credentials.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55

66
"encoding/json"
7-
"fmt"
87
"github.com/1Password/shell-plugins/sdk"
98
"github.com/1Password/shell-plugins/sdk/importer"
109
"github.com/1Password/shell-plugins/sdk/provision"
@@ -20,7 +19,7 @@ func Credentials() schema.CredentialType {
2019
ManagementURL: sdk.URL("https://dashboard.cohere.ai/"),
2120
Fields: []schema.CredentialField{
2221
{
23-
Name: fieldname.Authtoken,
22+
Name: fieldname.JWT,
2423
MarkdownDescription: "JWT used to authenticate to Cohere stored in disk.",
2524
Secret: true,
2625
},
@@ -58,7 +57,7 @@ func TryCohereConfigFile() sdk.Importer {
5857
out.AddCandidate(sdk.ImportCandidate{
5958
Fields: map[sdk.FieldName]string{
6059
fieldname.URL: config.CurrentURL,
61-
fieldname.Authtoken: config.Contexts[config.CurrentURL].JWT,
60+
fieldname.JWT: config.Contexts[config.CurrentURL].JWT,
6261
fieldname.Email: config.Contexts[config.CurrentURL].Email,
6362
},
6463
})
@@ -68,7 +67,7 @@ func TryCohereConfigFile() sdk.Importer {
6867
func cohereJSON(in sdk.ProvisionInput) ([]byte, error) {
6968
var currentURL, jwt, email string
7069

71-
if value, ok := in.ItemFields[fieldname.Authtoken]; ok {
70+
if value, ok := in.ItemFields[fieldname.JWT]; ok {
7271
jwt = value
7372
} else {
7473
return nil, nil
@@ -94,7 +93,7 @@ func cohereJSON(in sdk.ProvisionInput) ([]byte, error) {
9493

9594
jsonData, err := json.Marshal(data)
9695
if err != nil {
97-
fmt.Println("Error:", err)
96+
return nil, err
9897

9998
}
10099
return []byte(jsonData), nil

plugins/cohere/credentials_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ func TestCredentialsProvisioner(t *testing.T) {
1212
plugintest.TestProvisioner(t, Credentials().DefaultProvisioner, map[string]plugintest.ProvisionCase{
1313
"temp file": {
1414
ItemFields: map[sdk.FieldName]string{
15-
fieldname.Authtoken: "PLEzI1N--EXAMPLE",
16-
fieldname.URL: "https://api.os.cohere.ai",
17-
fieldname.Email: "wendy@appleseed.com",
15+
fieldname.JWT: "PLEzI1N--EXAMPLE",
16+
fieldname.URL: "https://api.os.cohere.ai",
17+
fieldname.Email: "wendy@appleseed.com",
1818
},
1919
ExpectedOutput: sdk.ProvisionOutput{
2020
Files: map[string]sdk.OutputFile{
@@ -37,9 +37,9 @@ func TestCredentialsImporter(t *testing.T) {
3737
ExpectedCandidates: []sdk.ImportCandidate{
3838
{
3939
Fields: map[sdk.FieldName]string{
40-
fieldname.Authtoken: "PLEzI1N--EXAMPLE",
41-
fieldname.URL: "https://api.os.cohere.ai",
42-
fieldname.Email: "wendy@appleseed.com",
40+
fieldname.JWT: "PLEzI1N--EXAMPLE",
41+
fieldname.URL: "https://api.os.cohere.ai",
42+
fieldname.Email: "wendy@appleseed.com",
4343
},
4444
},
4545
},

sdk/schema/fieldname/names.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const (
3131
Endpoint = sdk.FieldName("Endpoint")
3232
Host = sdk.FieldName("Host")
3333
HostAddress = sdk.FieldName("Host Address")
34+
JWT = sdk.FieldName("JWT")
3435
Key = sdk.FieldName("Key")
3536
MFASerial = sdk.FieldName("MFA Serial")
3637
Mode = sdk.FieldName("Mode")
@@ -81,6 +82,7 @@ func ListAll() []sdk.FieldName {
8182
Endpoint,
8283
Host,
8384
HostAddress,
85+
JWT,
8486
Key,
8587
MFASerial,
8688
Mode,

0 commit comments

Comments
 (0)