-
Notifications
You must be signed in to change notification settings - Fork 671
feat: Add support for Protected Environments #2084
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
Conversation
more specically, I guess all crud operation are inherited from the CRUD mixin but we should ideally implement |
Codecov Report
@@ Coverage Diff @@
## main #2084 +/- ##
==========================================
+ Coverage 85.62% 94.64% +9.02%
==========================================
Files 78 78
Lines 5007 5020 +13
==========================================
+ Hits 4287 4751 +464
+ Misses 720 269 -451
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
Overall looks good. In addition to the one thing I mentioned, would also be good to create a unit test for this.
5ca5390
to
28a689c
Compare
To answer your question:
BTW: There is also a group-level protected environments endpoint: https://docs.gitlab.com/ee/api/group_protected_environments.html Edit: ah, looking at your PR now, we're actually fine - create/delete from CRUDMixin already cover protecting and unprotecting the environment. But we should maybe document that I'll also add a note in the docs for our protected branches/tags that create/delete does protect/unprotect. |
Thanks for the great PR and quick rework @calve. It'd be cool if you could add a tiny bit of docs for this (see protected branches) if you have the time & energy as well :) |
Thanks both of you for the quick review.
I'm inclined to let the implementation to a future reader ?
And globally on the create/delete/protect/unprotect behavior, I have to say I did not have those usages right now and so haven't actually tested anything related to other operation than list/get. I just realised the documentation isn't autogenerated as I initially thought, I'm going to amend the commit to add a specific pages. |
Thanks for the quick reply @calve. We auto-generate the API reference but add some prose docs with examples usually, as some people find that easier to grok. Sounds good, the rest can be a follow-up :) |
28a689c
to
8eb44ea
Compare
I amended the commit to
please let me know for any other changes or information :) |
aa19c34
to
01abc64
Compare
Thanks! Just a few more typos/nitpicks from me, then we should be good to go. Our handling of IDs is a bit different from how GitLab documents them, because we create objects to manipulate, so I've added some comments. |
01abc64
to
9bb51cf
Compare
Updated with your suggestions, thanks for the review. for reference here are my manual tests In [12]: p.protected_environments.create({"name": "testenv", "deploy_access_levels": [{"access_level": 40}]})
Out[12]: <ProjectProtectedEnvironment name:testenv>
In [13]: print(p.protected_environments.get("testenv"))
<class 'gitlab.v4.objects.environments.ProjectProtectedEnvironment'> => {'name': 'testenv', 'deploy_access_levels': [{'access_level': 40, 'access_level_description': 'Maintainers', 'user_id': None, 'group_id': None, 'group_inheritance_type': 0}], 'required_approval_count': 0, 'approval_rules': []}
In [14]: print(p.protected_environments.list()[0])
<class 'gitlab.v4.objects.environments.ProjectProtectedEnvironment'> => {'name': 'testenv', 'deploy_access_levels': [{'access_level': 40, 'access_level_description': 'Maintainers', 'user_id': None, 'group_id': None, 'group_inheritance_type': 0}], 'required_approval_count': 0, 'approval_rules': []}
In [15]: print(p.protected_environments.list()[0].delete())
None
In [16]: print(p.protected_environments.get("testenv")) |
- https://docs.gitlab.com/ee/api/protected_environments.html - python-gitlab#1130 no write operation are implemented yet as I have no use case right now and am not sure how it should be done
9bb51cf
to
1dc9d0f
Compare
Thanks for the super quick reactions @calve. LGTM now, this should make it into the next scheduled release on the 28th. |
Thanks for your time, the super review and velocity 🤝 |
no write operation are implemented yet as I have no use case right now
and am not sure how it should be done