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.

  • NameRegex is no longer deprecated in ContainerExpirationPolicy and ContainerExpirationPolicyAttributes.
  • NameRegexDelete is now deprecated in both structs, with a note that the API ignores it on write and never returns it on read.
  • CreateProject, CreateProjectForUser and EditProject used to always overwrite NameRegex with NameRegexDelete. Because of that, setting only NameRegex (what the new annotation recommends) was silently dropped. NameRegexDelete is now only used as a fallback when NameRegex is unset, so existing callers that set NameRegexDelete still get name_regex sent.
  • The two fields swap places inside each struct, so NameRegex sits in API docs order and NameRegexDelete moves 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: NameRegex only, NameRegexDelete only (fallback) and both set (NameRegex wins). Checks the request body and that name_regex from the response ends up in NameRegex.
  • New CreateProject test that checks NameRegex alone is sent as name_regex.
  • make reviewable (setup, generate, fmt, lint, test) passes locally. golangci-lint reports 0 issues.

Open questions for reviewers

  • Wording of the NameRegexDelete annotation. 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_delete on 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) and BuildCoverageRegex (gone from GitLab), plus access_level_description on 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.

Merge request reports

Loading
Loading