MinioAdmin: allow specifying policies as dict besides file
It would be nice to be able to add/update IAM/service account policies through Python dict objects as well as what's currently available through JSON files.
This PR tries to accomplish this.
Feedback/questions welcome.
Depends on https://github.com/minio/minio-py/pull/1483
i wonder if it makes sense to refactor out something like
def _load_policy(policy_file, policy):
if policy and policy_file:
raise ValueError(
"only one of policy or policy_file may be specified")
if not policy or not policy_file:
raise ValueError("either policy or policy_file must be specified")
body = ''
if policy:
body = json.dumps(policy)
elif policy_file:
with open(policy_file, encoding='utf-8') as file:
body = file.read()
return body
given in how many places we basically have the same code now.
Sounds fairly sensible actually. I'll wait for feedback from a member and see what they think.
@balamurugana please review
I'd love to hear some feedback on the current state.
I'd love to hear some feedback on the current state.
Please fix the CI tests
Fixed. Moved the .open() for Path to its own line so I can put the mypy comment on the same line while keeping it within 80 characters to keep autopep8 happy.
I think that's it? I still see "1 requested change" but I don't see where or what it is.
Do you want me to squash my commits?
@balamurugana can you take a look? 🙂
Apologies, that was a dumb error I introduced and insufficiently tested. Tested properly now and passing all tests.
Squashed commits, should be all clean now. Can you please take a look?
If needed, I still have the original commits in a separate branch locally.