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

fix: make scopes work with multiple scope-names#1360

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

Closed

Conversation

klorenz
Copy link
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.

@klorenzklorenzforce-pushed thefix_impersonation_token branch from2ee4155 to426b9b5CompareMarch 6, 2021 10:52
@JohnVillalovos
Copy link
Member

JohnVillalovos commentedMar 6, 2021
edited
Loading

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.

Copy link
Member

@nejchnejch left a comment

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
Copy link
ContributorAuthor

klorenz commentedMar 7, 2021 via email

Hi, i struggled a bit with the linting checks you do and had to redo thecommits. I check today if everything is in there. Sorry for the trouble.Regards, KiwiNejc 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> .

@codecov-io
Copy link

codecov-io commentedMar 7, 2021
edited
Loading

Codecov Report

Merging#1360 (7443cd8) intomaster (aa13214) willdecrease coverage by0.18%.
The diff coverage is91.66%.

Impacted file tree graph

@@            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
FlagCoverage Δ
unit80.03% <91.66%> (-0.19%)⬇️

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

Impacted FilesCoverage Δ
gitlab/types.py90.62% <80.00%> (-1.97%)⬇️
gitlab/v4/objects/applications.py100.00% <100.00%> (ø)
gitlab/v4/objects/deploy_tokens.py100.00% <100.00%> (ø)
gitlab/v4/objects/users.py90.69% <100.00%> (+0.10%)⬆️
gitlab/client.py79.12% <0.00%> (-1.56%)⬇️
gitlab/mixins.py78.60% <0.00%> (-0.26%)⬇️
gitlab/base.py84.66% <0.00%> (+0.42%)⬆️

Continue to review full report at Codecov.

Legend -Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered byCodecov. Last updateaa13214...7443cd8. Read thecomment docs.

Copy link
Member

@nejchnejch 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 added tests, looks good! I just left one small note.

@@ -561,11 +561,10 @@ def test_create_project_with_values_from_file(gitlab_cli, tmpdir):
assert description in ret.stdout


deftest_create_project_deploy_token(gitlab_cli, project):
defdo_test_create_project_deploy_token(gitlab_cli, project, scopes, expected_scopes):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

hint: you could keep a single test function here and parametrize the input/expected output with pytest:

@pytest.mark.parametrize("scopes,expected_scopes",    [        ("read_registry","['read_registry']"),        ("read_registry,read_repository","['read_repository', 'read_registry']"),    ],)deftest_create_project_deploy_token(gitlab_cli,project,scopes,expected_scopes):    ...

Then you don't need a custom helper function at all and it will be easy to add more edge cases later. See very similar example here:

@pytest.mark.parametrize(
"config_string,expected_agent",
[
(valid_config,USER_AGENT),
(custom_user_agent_config,custom_user_agent),
],
)
deftest_config_user_agent(m_open,path_exists,config_string,expected_agent):
fd=io.StringIO(config_string)
fd.close=mock.Mock(return_value=None)
m_open.return_value=fd
cp=config.GitlabConfigParser()
assertcp.user_agent==expected_agent

@nejch
Copy link
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 (--scopes "read_registry,read_repository" works well with the current master branch.

@JohnVillalovos
Copy link
Member

Related PR which also fixes other issues we have with array variables passed to the GitLab API

#1699

@github-actions
Copy link

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.

@github-actions
Copy link

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.

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

@nejchnejchnejch requested changes

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@klorenz@JohnVillalovos@codecov-io@nejch

[8]ページ先頭

©2009-2025 Movatter.jp