Skip to content

Commit

Permalink
Recommited with sign
Browse files Browse the repository at this point in the history
  • Loading branch information
parthiv11 committed Sep 29, 2023
1 parent 983a1ee commit 2dcf34a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
15 changes: 7 additions & 8 deletions plugins/yugabytedb/database_credentials.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package yugabytedb

import (
"context"

"github.com/1Password/shell-plugins/sdk"
"github.com/1Password/shell-plugins/sdk/importer"
"github.com/1Password/shell-plugins/sdk/provision"
Expand All @@ -14,8 +12,8 @@ import (
func DatabaseCredentials() schema.CredentialType {
return schema.CredentialType{
Name: credname.DatabaseCredentials,
DocsURL: sdk.URL("https://docs.yugabyte.com/preview/admin/ysqlsh/#connect-to-a-database"),
ManagementURL: sdk.URL("https://cloud.yugabyte.com/"),
DocsURL: sdk.URL("https://docs.yugabyte.com/preview/admin/ysqlsh/#connect-to-a-database"),
ManagementURL: sdk.URL("https://cloud.yugabyte.com/clusters"),
Fields: []schema.CredentialField{
{
Name: fieldname.Host,
Expand All @@ -27,8 +25,8 @@ func DatabaseCredentials() schema.CredentialType {
Optional: true,
},
{
Name: fieldname.User,
MarkdownDescription: "Yugabyte user to authenticate as.",
Name: fieldname.Username,
MarkdownDescription: "Yugabyte user to get authenticate.",
},
{
Name: fieldname.Password,
Expand All @@ -37,18 +35,19 @@ func DatabaseCredentials() schema.CredentialType {
},
{
Name: fieldname.Database,
MarkdownDescription: "Database name to connect to.",
MarkdownDescription: "Database name to connect to Yugabyte.",
Optional: true,
},
},
DefaultProvisioner: provision.EnvVars(defaultEnvVarMapping),
Importer: importer.TryEnvVarPair(defaultEnvVarMapping),
}
}

var defaultEnvVarMapping = map[string]sdk.FieldName{
"PGHOST": fieldname.Host,
"PGPORT": fieldname.Port,
"PGUSER": fieldname.User,
"PGUSER": fieldname.Username,
"PGPASSWORD": fieldname.Password,
"PGDATABASE": fieldname.Database,
}
9 changes: 5 additions & 4 deletions plugins/yugabytedb/database_credentials_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

func TestDatabaseCredentialsImporter(t *testing.T) {
plugintest.TestImporter(t, DatabaseCredentials().Importer, map[string]plugintest.ImportCase{
"default": {
"yugabyte": {
Environment: map[string]string{
"PGHOST": "localhost",
"PGPORT": "5432",
Expand All @@ -23,7 +23,7 @@ func TestDatabaseCredentialsImporter(t *testing.T) {
Fields: map[sdk.FieldName]string{
fieldname.Host: "localhost",
fieldname.Port: "5432",
fieldname.User: "root",
fieldname.Username: "root",
fieldname.Password: "123456",
fieldname.Database: "test",
},
Expand All @@ -39,7 +39,7 @@ func TestDatabaseCredentialsProvisioner(t *testing.T) {
ItemFields: map[sdk.FieldName]string{
fieldname.Host: "localhost",
fieldname.Port: "5432",
fieldname.User: "root",
fieldname.Username: "root",
fieldname.Password: "123456",
fieldname.Database: "test",
},
Expand All @@ -53,5 +53,6 @@ func TestDatabaseCredentialsProvisioner(t *testing.T) {
},
},
},
})
},
)
}
7 changes: 3 additions & 4 deletions plugins/yugabytedb/ysqlsh.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ import (

func YugabyteDBCLI() schema.Executable {
return schema.Executable{
Name: "YugabyteDB SQL Shell",
Runs: []string{"ysqlsh"},
DocsURL: sdk.URL("https://docs.yugabyte.com/preview/admin/ysqlsh/"),
Name: "YugabyteDB SQL Shell",
Runs: []string{"ysqlsh"},
DocsURL: sdk.URL("https://docs.yugabyte.com/preview/admin/ysqlsh/"),
NeedsAuth: needsauth.IfAll(
needsauth.NotForHelpOrVersion(),
needsauth.NotWithoutArgs(),
),
Uses: []schema.CredentialUsage{
{
Expand Down

0 comments on commit 2dcf34a

Please sign in to comment.