Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nejch merged 1 commit intopython-gitlab:mainfromcalve:protected-environments
Jun 22, 2022

Conversation

@calve
Copy link
Contributor

no write operation are implemented yet as I have no use case right now
and am not sure how it should be done

@calve
Copy link
ContributorAuthor

more specically, I guess all crud operation are inherited from the CRUD mixin but we should ideally implementstop(),protect() andunprotect() methods ?

@codecov-commenter
Copy link

codecov-commenter commentedJun 21, 2022
edited
Loading

Codecov Report

Merging#2084 (169375f) intomain (8342f53) willincrease coverage by9.02%.
The diff coverage is92.85%.

@@            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
FlagCoverage Δ
cli_func_v482.43% <92.85%> (?)
py_func_v481.01% <92.85%> (?)
unit85.63% <92.85%> (+0.01%)⬆️

Flags with carried forward coverage won't be shown.Click here to find out more.

Impacted FilesCoverage Δ
gitlab/v4/objects/environments.py97.14% <91.66%> (+5.83%)⬆️
gitlab/v4/objects/projects.py89.96% <100.00%> (+8.42%)⬆️
gitlab/config.py100.00% <0.00%> (+1.14%)⬆️
gitlab/v4/objects/members.py94.82% <0.00%> (+1.72%)⬆️
gitlab/types.py98.07% <0.00%> (+1.92%)⬆️
gitlab/v4/objects/export_import.py94.73% <0.00%> (+2.63%)⬆️
gitlab/v4/objects/wikis.py96.55% <0.00%> (+3.44%)⬆️
gitlab/v4/objects/notes.py94.28% <0.00%> (+3.80%)⬆️
gitlab/v4/objects/groups.py88.73% <0.00%> (+4.22%)⬆️
gitlab/v4/objects/jobs.py77.27% <0.00%> (+4.54%)⬆️
... and31 more

Copy link
Member

@JohnVillalovosJohnVillalovos left a 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.

@calvecalveforce-pushed theprotected-environments branch 2 times, most recently from5ca5390 to28a689cCompareJune 22, 2022 09:29
@nejch
Copy link
Member

nejch commentedJun 22, 2022
edited
Loading

more specically, I guess all crud operation are inherited from the CRUD mixin but we should ideally implementstop(),protect() andunprotect() methods ?

To answer your question:stop() is already implemented on the/environments endpoint, so we're ok - seems like/protected_environments does not have a separate stop endpoint for that.

We would need to add protect/unprotect, yes. If you'd like to add this, you can take a look at the (since deprecated) branch protect methods:9656a16, although that's quite old, you'd probably have a simpler-looking method for that without the custom argument handling.

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 thatcreate()protects anddelete()unprotects the protected environment. This is actually consistent with our protected branches approach to avoid custom code:https://python-gitlab.readthedocs.io/en/stable/gl_objects/protected_branches.html.

I'll also add a note in the docs for our protected branches/tags that create/delete does protect/unprotect.

@nejch
Copy link
Member

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 :)

@calve
Copy link
ContributorAuthor

Thanks both of you for the quick review.

BTW: There is also a group-level protected environments endpoint:https://docs.gitlab.com/ee/api/group_protected_environments.html

I'm inclined to let the implementation to a future reader ?

I'm not sure about UpdateMixin - does the API allow PUT on existing protected environments? Even protected branches don't support editing, so I'd think that no.

I'll also add a note in the docs for our protected branches/tags that create/delete does protect/unprotect.

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.

@nejch
Copy link
Member

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 :)

@calvecalveforce-pushed theprotected-environments branch from28a689c to8eb44eaCompareJune 22, 2022 11:30
@calve
Copy link
ContributorAuthor

I amended the commit to

  • remove the UpdateMixin, and the associated.update() method
  • set_create_attrs and_list_filters to what seems to be the actual spec
  • document thatcreate() anddelete() actually protect/unprotected existing environments
  • manually (and successfully) test a full CRUD cycle on my gitlab-ee instance

please let me know for any other changes or information :)

@calvecalveforce-pushed theprotected-environments branch 3 times, most recently fromaa19c34 to01abc64CompareJune 22, 2022 11:47
@calvecalve changed the titlefeat: Add support to list Protected Environmentsfeat: Add support for Protected EnvironmentsJun 22, 2022
@nejch
Copy link
Member

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.

calve reacted with thumbs up emoji

@calvecalveforce-pushed theprotected-environments branch from01abc64 to9bb51cfCompareJune 22, 2022 13:16
@calve
Copy link
ContributorAuthor

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]:<ProjectProtectedEnvironmentname: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())NoneIn [16]:print(p.protected_environments.get("testenv"))

-https://docs.gitlab.com/ee/api/protected_environments.html-python-gitlab#1130no write operation are implemented yet as I have no use case right nowand am not sure how it should be done
@calvecalveforce-pushed theprotected-environments branch from9bb51cf to1dc9d0fCompareJune 22, 2022 13:17
@nejch
Copy link
Member

Thanks for the super quick reactions@calve. LGTM now, this should make it into the next scheduled release on the 28th.

@nejchnejch merged commit1feabc0 intopython-gitlab:mainJun 22, 2022
@calve
Copy link
ContributorAuthor

Thanks for your time, the super review and velocity 🤝

nejch reacted with heart emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@JohnVillalovosJohnVillalovosJohnVillalovos requested changes

@nejchnejchnejch approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@calve@codecov-commenter@nejch@JohnVillalovos

[8]ページ先頭

©2009-2025 Movatter.jp