diff --git a/plugins/atlas/database_credentials.go b/plugins/atlas/database_credentials.go new file mode 100644 index 000000000..17b4adbf1 --- /dev/null +++ b/plugins/atlas/database_credentials.go @@ -0,0 +1,69 @@ +package atlas + +import ( + "github.com/1Password/shell-plugins/sdk" + "github.com/1Password/shell-plugins/sdk/schema" + "github.com/1Password/shell-plugins/sdk/schema/credname" + "github.com/1Password/shell-plugins/sdk/schema/fieldname" +) + +func DatabaseCredentials() schema.CredentialType { + return schema.CredentialType{ + Name: credname.DatabaseCredentials, + DocsURL: sdk.URL("https://www.mongodb.com/docs/mongodb-shell/connect/"), + Fields: []schema.CredentialField{ + { + Name: fieldname.Host, + MarkdownDescription: "Host address for the MongoDB database.", + Secret: false, + Optional: true, + Composition: &schema.ValueComposition{ + Charset: schema.Charset{ + Lowercase: true, + Digits: true, + Specific: []rune{'.', '-'}, + }, + }, + }, + { + Name: fieldname.Port, + MarkdownDescription: "Port for the MongoDB database.", + Secret: false, + Optional: true, + Composition: &schema.ValueComposition{ + Charset: schema.Charset{ + Digits: true, + }, + }, + }, + { + Name: fieldname.Username, + MarkdownDescription: "Username for authenticating to the MongoDB database.", + Secret: false, + Optional: true, + Composition: &schema.ValueComposition{ + Charset: schema.Charset{ + Lowercase: true, + Digits: true, + Specific: []rune{'-', '_'}, + }, + }, + }, + { + Name: fieldname.Password, + MarkdownDescription: "Password for authenticating to the MongoDB database.", + Secret: true, + Optional: true, + Composition: &schema.ValueComposition{ + Charset: schema.Charset{ + Lowercase: true, + Uppercase: true, + Digits: true, + }, + }, + }, + }, + DefaultProvisioner: nil, + Importer: nil, + } +} diff --git a/plugins/atlas/mongosh.go b/plugins/atlas/mongosh.go new file mode 100644 index 000000000..f376f4a5a --- /dev/null +++ b/plugins/atlas/mongosh.go @@ -0,0 +1,25 @@ +package atlas + +import ( + "github.com/1Password/shell-plugins/sdk" + "github.com/1Password/shell-plugins/sdk/needsauth" + "github.com/1Password/shell-plugins/sdk/schema" + "github.com/1Password/shell-plugins/sdk/schema/credname" +) + +func MongoshCLI() schema.Executable { + return schema.Executable{ + Name: "MongoDB Shell", + Runs: []string{"mongosh"}, + DocsURL: sdk.URL("https://www.mongodb.com/docs/mongodb-shell/"), + NeedsAuth: needsauth.IfAll( + needsauth.NotForHelpOrVersion(), + needsauth.NotWithoutArgs(), + ), + Uses: []schema.CredentialUsage{ + { + Name: credname.DatabaseCredentials, + }, + }, + } +}