Skip to content
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

Add support to protect tags with group_id or user_id #1540

Merged
merged 3 commits into from Oct 29, 2022

Conversation

weirdian2k3
Copy link
Contributor

This resolves #1511

@weirdian2k3
Copy link
Contributor Author

@svanharmelen would you be able to review this? I'm hoping get this updated so that I can get a downstream issue resolved

@@ -46,6 +46,8 @@ type ProtectedTag struct {
type TagAccessDescription struct {
AccessLevel AccessLevelValue `json:"access_level"`
AccessLevelDescription string `json:"access_level_description"`
UserID *int `url:"user_id,omitempty" json:"user_id,omitempty"`
GroupID *int `url:"group_id,omitempty" json:"group_id,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

I cannot see in the docs that these fields need to be here. Can you point me to somewhere (in the code) that shows these fields exist in this struct?

Additionally in a response struct like this we don't use pointers for build-in types and URL tags.

//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/protected_tags.html#protect-repository-tags
type ProtectRepositoryTagsPermissionOptions struct {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe make this just a little shorter, like TagsPermissionOptions or something?

CreateAccessLevel *AccessLevelValue `url:"create_access_level,omitempty" json:"create_access_level,omitempty"`
Name *string `url:"name" json:"name"`
CreateAccessLevel *AccessLevelValue `url:"create_access_level,omitempty" json:"create_access_level,omitempty"`
AllowedToCreate *[]ProtectRepositoryTagsPermissionOptions `url:"allowed_to_create,omitempty" json:"allowed_to_create,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
AllowedToCreate *[]ProtectRepositoryTagsPermissionOptions `url:"allowed_to_create,omitempty" json:"allowed_to_create,omitempty"`
AllowedToCreate *[]*ProtectRepositoryTagsPermissionOptions `url:"allowed_to_create,omitempty" json:"allowed_to_create,omitempty"`

Copy link
Member

@svanharmelen svanharmelen left a comment

Choose a reason for hiding this comment

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

I'm still not sure if these (user_id and group_id) fields exist in the TagAccessDescription response, but I fixed up the PR and went ahead to merge it...

@svanharmelen svanharmelen merged commit 4ec1dc6 into xanzy:master Oct 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for allowed_to_create in tag protection
2 participants