fix: make scopes work with multiple scope-names by klorenz · Pull Request #1360 · python-gitlab/python-gitlab
Repository navigation
fix: make scopes work with multiple scope-names - #1360
Closed
klorenz wants to merge 12 commits into python-gitlab:main from klorenz:fix_impersonation_token
Closed
fix: make scopes work with multiple scope-names #1360 klorenz wants to merge 12 commits into python-gitlab:main from klorenz:fix_impersonation_token
Conversation
klorenz commented Mar 6, 2021
Copy link Copy Markdown
Contributor
I have found out, that it was not possible to use multiple comma-separated scopes from command line as documented. These changes fixes that issue.
klorenz added 2 commits March 6, 2021 11:44
fix: make scopes work with multiple scope-names
912f622
Merge branch 'master' into fix_impersonation_token
426b9b5
klorenz
force-pushed
the
fix_impersonation_token
branch
from
2ee4155 to
426b9b5
Compare
March 6, 2021 10:52
chore: make lint happy
02012ef
JohnVillalovos commented Mar 6, 2021 · edited Loading
Copy link Copy Markdown
Member
|
When I look at "Files changed" only one file is changed. Was that the intent? The second commit is a Merge commit which doesn't seem correct. It seems like this patch was started before gitlab/v4/objects/ init .py was split up into multiple files. |
View reviewed changes
nejch left a comment
Copy link Copy Markdown
Member
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more .
Thanks a lot for this @klorenz I think some people have asked for this already and will be happy to see it fixed! I'll try to find related issues so we can close them if it fixes them.
When I look at "Files changed" only one file is changed. Was that the intent? The second commit is a Merge commit which doesn't seem correct.
It seems like this patch was started before gitlab/v4/objects/ init .py was split up into multiple files.
I agree with @JohnVillalovos , looks like with your merge you lost the custom _types attributes. Could you re-add them in the split objects/ files? Also looks like you had an unrelated change in the initial commit, please submit that as a separate PR if you add it back ;)
Apart from John's comment see also my note on only overriding the right method.
And finally since I see from the other PR that you're comfortable with unit tests here could you add one to prove it fixes the issue? ;)
klorenz commented Mar 7, 2021 via email
Copy link Copy Markdown
Contributor
Author
| Hi, i struggled a bit with the linting checks you do and had to redo the commits. I check today if everything is in there. Sorry for the trouble. Regards, Kiwi Nejc Habjan <notifications@github.com> schrieb am Sa., 6. März 2021, 18:43: ... ***@***.**** requested changes on this pull request. Thanks a lot for this @klorenz <https://github.com/klorenz > I think some people have asked for this already and will be happy to see it fixed! I'll try to find related issues so we can close them if it fixes them. When I look at "Files changed" only one file is changed. Was that the intent? The second commit is a Merge commit which doesn't seem correct. It seems like this patch was started before gitlab/v4/objects/*init*.py was split up into multiple files. I agree with @JohnVillalovos <https://github.com/JohnVillalovos >, looks like with your merge you lost the custom _types attributes. Could you re-add them in the split objects/ files? Also looks like you had an unrelated change in the initial commit, please submit that as a separate PR if you add it back ;) Apart from John's comment see also my note on only overriding the right method. And finally since I see from the other PR that you're comfortable with unit tests here could you add one to prove it fixes the issue? ;) ------------------------------ In gitlab/types.py <#1360 (comment) > : > +class ScopesListAttribute(ListAttribute): + def set_from_cli(self, cli_value): + if not cli_value.strip(): + self._value = [] + else: + self._value = [item.strip() for item in cli_value.split(",")] + + def get_for_api(self): + # Do not comma-split single value passed as string + if isinstance(self._value, str): + return [self._value] + + return self._value + + Since you are inheriting from ListAttribute you don't need to duplicate methods. Just override the one you need to and maybe instead of copying the previous comment, add one (or a docstring) about why it needs to be different from the inherited class. Unless I missed a small difference in set_from_cli then please correct me 😁 -- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#1360 (review) >, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAE2WZAXOJ5D6YDNTFHHZDTTCJSVVANCNFSM4YWTNIWQ > . |
fix: not re-implement inherited functions in ScopesListAttribute, add...
85757d8
... _types to objects
codecov-io commented Mar 7, 2021 · edited Loading
Copy link Copy Markdown
Codecov Report
@@ Coverage Diff @@ ## master #1360 +/- ## ========================================== - Coverage 80.21% 80.03% -0.19% ========================================== Files 73 73 Lines 3801 4022 +221 ========================================== + Hits 3049 3219 +170 - Misses 752 803 +51
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov .
|
chore: add test for token scopes
f14f91b
chore: make lint happy
9350067
chore: make lint happy
d1de30b
chore: make lint happy
7443cd8
fix: token scopes tests
fe6aef3
fix: token scopes tests
9c49cc8
chore: make lint happy
0d1dca5
fix: expected scopes in deploy_token test
3826ea8
nejch
requested changes
Apr 18, 2021
View reviewed changes
nejch left a comment
Copy link Copy Markdown
Member
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more .
Thanks for the added tests, looks good! I just left one small note.
Comment thread tools/functional/cli/test_cli_v4.py|
|
||
|
|
||
| def test_create_project_deploy_token (gitlab_cli, project): | ||
| def do_test_create_project_deploy_token (gitlab_cli, project , scopes, expected_scopes ): |
nejch commented May 15, 2021
Copy link Copy Markdown
Member
|
Hi @klorenz , coming back to this, I realized we've solved the same/similar problem in a more generic way in #1420 for all objects that need special list filters. I just ran your functional tests on the current master branch and they're passing, so I just wanted to check what your original issue was so that we can see if this is still needed for any objects. Could you let me know what CLI commands you were trying before that did not work properly? It seems like creating deploy tokens with scopes as a comma-delimited string ( |
JohnVillalovos commented Nov 20, 2021
Copy link Copy Markdown
Member
|
Related PR which also fixes other issues we have with array variables passed to the GitLab API |
github-actions
Bot
commented
Feb 19, 2022
Copy link Copy Markdown
|
This Pull Request (PR) was marked stale because it has been open 90 days with no activity. Please remove the stale label or comment on this PR. Otherwise, it will be closed in 15 days. |
Bot
added the stale label Feb 19, 2022
github-actions
Bot
commented
Mar 6, 2022
Copy link Copy Markdown
|
This PR was closed because it has been marked stale for 15 days with no activity. If this PR is still valid, please re-open. |
Bot
closed this Mar 6, 2022 Sign up for free to join this conversation on GitHub . Already have an account? Sign in to comment