fix(projects): correct deprecated field annotations
What does this MR do?
Fixes the misleading Deprecated: annotations on project options reported in #2303 (closed). They cause staticcheck SA1019 warnings that push users towards a field the API doesn't support.
Container expiration policy: NameRegex vs NameRegexDelete
The GitLab REST API never renamed name_regex to name_regex_delete (gitlab-org/gitlab!30108 (closed) was closed without merging, and gitlab-org/gitlab#371404 is still in the backlog). name_regex is the only field the API accepts and returns.
NameRegexis no longer deprecated inContainerExpirationPolicyandContainerExpirationPolicyAttributes.NameRegexDeleteis now deprecated in both structs, with a note that the API ignores it on write and never returns it on read.CreateProject,CreateProjectForUserandEditProjectused to always overwriteNameRegexwithNameRegexDelete. Because of that, setting onlyNameRegex(what the new annotation recommends) was silently dropped.NameRegexDeleteis now only used as a fallback whenNameRegexis unset, so existing callers that setNameRegexDeletestill getname_regexsent.- The two fields swap places inside each struct, so
NameRegexsits in API docs order andNameRegexDeletemoves to the deprecated block at the end. Both fields have the same type, so this is source compatible. No exported names were removed.
CreateProjectOptions: wrongly deprecated fields
CIForwardDeploymentEnabled, IssuesTemplate, MergeRequestsTemplate and ServiceDeskEnabled were annotated "No longer supported in recent versions". The API still declares and documents all four, and the matching EditProjectOptions fields aren't deprecated, so I removed those annotations. The only other change in that struct is gofumpt alignment.
Closes #2303 (closed)
How was this tested?
- New table-driven test for
EditProject:NameRegexonly,NameRegexDeleteonly (fallback) and both set (NameRegexwins). Checks the request body and thatname_regexfrom the response ends up inNameRegex. - New
CreateProjecttest that checksNameRegexalone is sent asname_regex. make reviewable(setup, generate, fmt, lint, test) passes locally. golangci-lint reports 0 issues.
Open questions for reviewers
- Wording of the
NameRegexDeleteannotation. I went with "The GitLab API does not support name_regex_delete and ignores it. Use NameRegex instead." Happy to change it if you'd like it to match the existing "will be removed in v5" style. - Keep or drop
name_regex_deleteon the wire? It's still sent when set. That's harmless because the API ignores it, and it keeps the change minimal. I can stop sending it if you'd prefer. - Out of scope here: a comment on the issue also points out
OperationsAccessLevel(removed from the API in 16.0) andBuildCoverageRegex(gone from GitLab), plusaccess_level_descriptionon the environment approval rule options. These have no annotations today. I'd rather handle them in a follow-up MR so this one stays focused.