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

Application Settings enabled_git_access_protocol cannot be set to null #1571

Open
timofurrer opened this issue Nov 11, 2022 · 3 comments
Open

Comments

@timofurrer
Copy link
Collaborator

The enabled_git_access_protocol field in the settings API supports enabling all protocols by setting the field to null, e.g.:

curl -X PUT --header "PRIVATE-TOKEN: $GITLAB_ACCESS_TOKEN" http://localhost:8080/api/v4/application/settings --header 'Content-Type: application/json' --data  '{"enabled_git_access_protocol": null}'

However, that is currently not possible, because the json tag contains omitempty and there is no special marshaller for it.

There are currently provider users facing this issue.

@theoriginalstove
Copy link
Contributor

I could be wrong here, but I feel like this is fairly simple to change by removing the omitempty tag for this field.
https://github.com/xanzy/go-gitlab/blob/master/settings.go#L521

@svanharmelen
Copy link
Member

If you do that, you will need to actively set the field every time you want to change a setting. Even if you do not want to change the enabled_git_access_protocol but only some other setting. I think that would be very unexpected behavior for users of this lib.

@theoriginalstove
Copy link
Contributor

Hmm that does make this a bit tricky to fix. I can see that being an annoying behavior as well if all of a sudden users need to set ssh or http if it was reverted to nil from removing the omitempty tag, and now their project allows both protocols.

Thoughts on a special marshaller for the UpdateSettings struct and if the value == "nil", then marshal enabled_git_access_protocol into null. Or if you have other ideas on how to fix this, I'd be happy to get it done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants