unumotors / mongo-hydra

A open source mongo orchestration tool with high hopes
MIT License
10 stars 1 forks source link

Basic user management on the CLI #44

Closed drubin closed 4 years ago

drubin commented 4 years ago

This manages users in the most basic form. It currently supports createUser updateUser but these are isolated and on their own.

This is mostly to get high-level feedback about the configuration setup, because this is the first command that has to use an explicit connection to a db I added it to the config file.

Example config

connection:
  uri: mongodb://localhost:27017/admin
users:
- user: 'david'
  password: 'pass123'
  customData:
    foo: bar

Example Output

Setting up users
{ _: [ 'users' ],
  f: 'hydra.yaml',
  connection: { uri: 'mongodb://localhost:27017/admin' },
  users:
   [ { user: 'david', password: 'pass123', customData: [Object] },
     { user: 'immanuel', password: 'pass123', customData: [Object] } ],
  '$0': 'hydra' }
creating user { user: 'david', password: 'pass123', customData: { foo: 'bar' } }
User exists updating instead
{ ok: 1 }
creating user { user: 'immanuel', password: 'pass123', customData: { foo: 'bar' } }
User exists updating instead
{ ok: 1 }

We need to think about how to wrap this logic into a bit more abstract lib (similar to how we did replication), because obviously this logic doesn't belong in the CLI layer but it was just a quick hack to prove it.

drubin commented 4 years ago

I will rebase the commits before merging, but this is the 2nd iteration of basic user management. I am not going to close the ticket yet because it doesn't yes support edit/removing/adding (maybe we should postpone this till after sharding as its actually complex to get right and there are better tools for this.

pelzerim commented 4 years ago

closes #46

drubin commented 4 years ago

I will fix the issues listwd above but are there any major issues that we would need to fix before merging?

The above things seem pretty minor.

pelzerim commented 4 years ago

I will fix the issues listwd above but are there any major issues that we would need to fix before merging?

The above things seem pretty minor.

I fully agree, that everything is minor but the error handling. But tbh we can patch that in later. approved

drubin commented 4 years ago

I will fix them before merging

drubin commented 4 years ago

We should add a issue to figure out proper error handling before it gets worse.... I think we need a solid pattern before copying it around too much.

drubin commented 4 years ago

I am going to merge this as this has been dragging on too long and all the issues were cosmetic.