Skip to content

Commit

Permalink
Configure arguments to provision and index to provision at
Browse files Browse the repository at this point in the history
  • Loading branch information
arunsathiya committed Jun 9, 2023
1 parent 0e1ac78 commit 652e62b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
18 changes: 18 additions & 0 deletions plugins/atlas/database_credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import (
"github.com/1Password/shell-plugins/sdk/schema/fieldname"
)

const (
index uint = 1
)

func DatabaseCredentials() schema.CredentialType {
return schema.CredentialType{
Name: credname.DatabaseCredentials,
Expand Down Expand Up @@ -67,3 +71,17 @@ func DatabaseCredentials() schema.CredentialType {
Importer: nil,
}
}

var argsToProvision = map[string]sdk.FieldName{
"--host": fieldname.Host,
"--port": fieldname.Port,
"--username": fieldname.Username,
"--password": fieldname.Password,
}

var indexToProvisionAt = map[string]uint{
"--host": index,
"--port": index,
"--username": index,
"--password": index,
}
5 changes: 4 additions & 1 deletion plugins/atlas/mongosh.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package atlas
import (
"github.com/1Password/shell-plugins/sdk"
"github.com/1Password/shell-plugins/sdk/needsauth"
"github.com/1Password/shell-plugins/sdk/provision"
"github.com/1Password/shell-plugins/sdk/schema"
"github.com/1Password/shell-plugins/sdk/schema/credname"
)
Expand All @@ -18,7 +19,9 @@ func MongoshCLI() schema.Executable {
),
Uses: []schema.CredentialUsage{
{
Name: credname.DatabaseCredentials,
Name: credname.DatabaseCredentials,
Provisioner: provision.ArgsAtIndex(indexToProvisionAt, argsToProvision),
Importer: nil,
},
},
}
Expand Down
2 changes: 2 additions & 0 deletions plugins/atlas/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ func New() schema.Plugin {
},
Credentials: []schema.CredentialType{
APIKey(),
DatabaseCredentials(),
},
Executables: []schema.Executable{
MongoDBAtlasCLI(),
MongoshCLI(),
},
}
}
5 changes: 5 additions & 0 deletions sdk/schema/executable.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ type CredentialUsage struct {
// from the way the credential is usually provisioned. Mutually exclusive with `SelectFrom`.
Provisioner sdk.Provisioner

// (Optional) The importer to use to import the credential. Overrides the DefaultImporter set in the credential schema,
// so should only be used if the importer deviates from the general the default importer works.
// Mutually exclusive with `SelectFrom`.
Importer sdk.Importer

// (Optional) What this credential will be used for by the executable.
Description string

Expand Down

0 comments on commit 652e62b

Please sign in to comment.