From 652e62b1802c8be7eec09fa7a95e800f9a327c8f Mon Sep 17 00:00:00 2001 From: Arun Date: Thu, 8 Jun 2023 19:10:59 -0400 Subject: [PATCH] Configure arguments to provision and index to provision at --- plugins/atlas/database_credentials.go | 18 ++++++++++++++++++ plugins/atlas/mongosh.go | 5 ++++- plugins/atlas/plugin.go | 2 ++ sdk/schema/executable.go | 5 +++++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/plugins/atlas/database_credentials.go b/plugins/atlas/database_credentials.go index 17b4adbf1..d6719b5f5 100644 --- a/plugins/atlas/database_credentials.go +++ b/plugins/atlas/database_credentials.go @@ -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, @@ -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, +} diff --git a/plugins/atlas/mongosh.go b/plugins/atlas/mongosh.go index f376f4a5a..8a892035f 100644 --- a/plugins/atlas/mongosh.go +++ b/plugins/atlas/mongosh.go @@ -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" ) @@ -18,7 +19,9 @@ func MongoshCLI() schema.Executable { ), Uses: []schema.CredentialUsage{ { - Name: credname.DatabaseCredentials, + Name: credname.DatabaseCredentials, + Provisioner: provision.ArgsAtIndex(indexToProvisionAt, argsToProvision), + Importer: nil, }, }, } diff --git a/plugins/atlas/plugin.go b/plugins/atlas/plugin.go index b1927198a..61d60064b 100644 --- a/plugins/atlas/plugin.go +++ b/plugins/atlas/plugin.go @@ -14,9 +14,11 @@ func New() schema.Plugin { }, Credentials: []schema.CredentialType{ APIKey(), + DatabaseCredentials(), }, Executables: []schema.Executable{ MongoDBAtlasCLI(), + MongoshCLI(), }, } } diff --git a/sdk/schema/executable.go b/sdk/schema/executable.go index eaf0964ab..d75570174 100644 --- a/sdk/schema/executable.go +++ b/sdk/schema/executable.go @@ -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