SolarArbiter / solarforecastarbiter-api

HTTP API and database schema for the Solar Forecast Arbiter
https://api.solarforecastarbiter.org
MIT License
10 stars 6 forks source link

Admin cli #156

Closed lboeman closed 5 years ago

lboeman commented 5 years ago

Adds a basic admin cli using the built in flask cli so we can use the storage interface. Still somewhat rough, needs some refactoring, ideally a way to repeat command arguments/options. Will require #155, needs to be rebased after that's merged. Running requires installing the API and setting the FLASK_APP environment variable to sfa_api.admincli and the MYSQL_* variables appropriately. Then the cli can be run with flask admin <command>. Testing would require setting the SFA_CLI_CONFIG env var to AdminTestConfig, or setting the environment variables individually. closes #150

lboeman commented 5 years ago

I think this is in a decent place. Code coverage is missing spots where I've reraised an error after catching a specific mysql errno. The only issue I have with it's current iteration is that add_user_to_org checks if the user is in the Unaffiliated organization before allowing them to be added, and as a result the error returned when a user does not exist is 'Cannot add affiliated user to organization'. I think this is ready for review, but perhaps after being rebased upon #155

lboeman commented 5 years ago

Added username and password as options to this as per comments from @alorenzo175 in the openshift deployment repo. Can be passed as using --password <password> or the user will be prompted.

alorenzo175 commented 5 years ago

Oh, I need to set FLASK_APP=sfa_api.admincli for this to work? Didn't read that and I'll forget that everytime. Can we add the admin group as another command under sfa-api using https://flask.palletsprojects.com/en/1.1.x/cli/#custom-scripts?