Skip to content

Commit

Permalink
Initial setup with DatabaseCredentials credential and mongosh executable
Browse files Browse the repository at this point in the history
  • Loading branch information
arunsathiya committed Jun 9, 2023
1 parent d07cd77 commit 0e1ac78
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
69 changes: 69 additions & 0 deletions plugins/atlas/database_credentials.go
Original file line number Diff line number Diff line change
@@ -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,
}
}
25 changes: 25 additions & 0 deletions plugins/atlas/mongosh.go
Original file line number Diff line number Diff line change
@@ -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,
},
},
}
}

0 comments on commit 0e1ac78

Please sign in to comment.