-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new(mongosh): Support mongosh executable for connecting to a MongoDB database #283
base: main
Are you sure you want to change the base?
Conversation
442bbbf
to
652e62b
Compare
This PR is ready to review as well, but a quick couple of notes:
|
I'll mark this in progress while I branch out |
I think this is ready for a review now. A couple of more fleshed out notes for reviewers below. Testing with MongoDB Atlas-hosted MongoDB databaseIn this case, you wouldn't have a host and port, rather a "Connection String". To test, you can run Overall, Connection String is a replacement to Host and Port together. The provisioned command line would be of the format below and will put you on a MongoDB shell where you can run queries. ["mongosh" "--password" "value" "--username" "value" "mongodb+srv://cluster0.redacted.mongodb.net"] Testing with a MongoDB host that offers the host and port valuesAWS DocumentDB is a great example, but doesn't offer a straightforward way to test. There's no way to connect to that database from the internet, besides setting up SSH tunneling or SSH port forwarding. So, if you find a different MongoDB host that offers host and port values, you can store those, and the username and password as a 1Password item. And then, you can run just ["mongosh" "--password" "value" "--username" "value" "--port" "value" "--host" "value"] A quicker option is to run a MongoDB database locally on your computer and connect to it. Default host is Take care to start the MongoDB service after installing with Hombrew: |
Provisioner test case is failing at the moment though and I can fix that once I get some guidance on how to navigate that on the redis work. |
…t stitches together multiple provisioners
… and rename atlas plugin to mongodbatlas, in line with the other one being named mongodbshell
…se it allows for more control over the order in which the arguments are provisioned
…guments but it's not working just yet due to slice range issues
…s: arguments provisioner and chained provisioner
…ory because the default setup of MongoDB is password-less, but the bulk of MongoDB deployments have a password set. And, having a password required helps prevent field-less 1Password item creation, thus offering a better onboarding UX
…mplementation, it does not differ from the Default Importer, which is nil
…username or password
…, use that instead of host and port fields
…rors, but this is not necessarily a concern in mongosh because we always provision at index 1 and mongosh is the minimum required command
…. When we resume Terraform compatibility work in the future, we'd update the default provisioner to match the environment variables used in the majority of the mongodb Terraform providers
…h 1Password-stored secrets to provision
…tion string is not present in the 1Password item
cca6994
to
08e27c6
Compare
Been a while since I last worked on this. Some progress notes and testing instructions below! New changes:
Existing changes retained:
Testing instructions:
Reason for manually creating the 1Password item: Covered earlier on this PR, but as a reminder: mongoDB CLI does not support an environment variable for the password to source from, or a config file, so, there's no proper importer flow for this shell plugin. |
Overview
This PR introduces support for the
mongosh
executable within theatlas
shell plugin. It facilitates connecting to a MongoDB database by fetching secrets from a 1Password item.Type of change
Related Issue(s)
How To Test
username
,password
,host
,port
(at this time this is manual becausemongosh
doesn't seem to source from a configuration file or envvars, which we could import from)op plugin init mongosh
mongosh
, and you should be connected to the MongoDB Shell. If you don't have a host or port, like in the case of MongoDB Atlas, rather a Connection String, you can runmongosh ConnectionString
(example:mongosh "mongodb+srv://cluster0.ygauyzj.mongodb.net"
)Couple of notes
op plugin init mongosh
kind of fails, that there's no importer configured. I am not sure how to handle this, besides asking the user to create the 1Password item manually. Is there a fallback importer flow that accepts the credential fields one by one? 🤔nil
for now.Changelog
Support for mongosh executable, allowing secure connection to a MongoDB Shell for a MongoDB database.