Fix gitlab_release without ref and when deleted outside of Terraform
What does this MR do and why?
Two fixes in gitlab_release:
- The releases API never returns
ref, and the provider never set it, so a release created or updated withoutref(for a tag that already exists) failed the apply withProvider returned invalid result object after apply, after GitLab had created the release.refstays computed and is now set from the plan: a configuredrefis kept as before, and one that isn't configured is stored as an empty string. Readreturned the 404 of a release deleted outside of Terraform as an error, so every plan failed withUnable to get a release: 404 Not Found. It now removes the release from the state, so the plan creates it again.Deletetreats a release that is already gone as deleted, as !3334 (merged) did for three integrations. GitLab answers the deletion of a missing release with 403 rather than 404, since it authorizes against the release before looking for it, soDeletetakes a 403 as gone only when reading the release answers 404.
Closes #6919 (closed)
How to verify
Against a local make testacc-up instance:
unset GITLAB_TOKEN && make testacc RUN=TestAcc_GitlabRelease_On main, the four new tests fail: TestAcc_GitlabRelease_existingTagWithoutRef with the unknown ref, TestAcc_GitlabRelease_deletedOutsideTerraform with the 404 in Read, and TestAcc_GitlabRelease_destroyDeletedRelease and TestAcc_GitlabRelease_destroyAfterProjectDeleted, whose destroys run without a refresh, with the 403 and the 404 in Delete. With the branch the seven tests pass.
What I ran (GitLab CE 19.5.0, Go 1.26.10, Terraform 1.4.0, golangci-lint 2.15.0)
The acceptance tests ran against a GitLab CE 19.5.0 container set up as make testacc-up sets it up, with Puma held to 4 workers to fit the host's memory.
--- PASS: TestAcc_GitlabRelease_destroyAfterProjectDeleted (2.75s)
--- PASS: TestAcc_GitlabRelease_deletedOutsideTerraform (3.31s)
--- PASS: TestAcc_GitlabRelease_destroyDeletedRelease (3.68s)
--- PASS: TestAcc_GitlabRelease_existingTagWithoutRef (4.05s)
--- PASS: TestAcc_GitlabRelease_releasedAt (4.34s)
--- PASS: TestAcc_GitlabRelease_milestones (3.35s)
--- PASS: TestAcc_GitlabRelease_basic (6.38s)
PASSWith main's resource_gitlab_release.go the four new tests fail and the three older ones pass. Without the line that sets ref, TestAcc_GitlabRelease_existingTagWithoutRef fails with the unknown ref. With the branch merged into main, the seven tests pass.
On the head, go mod tidy and tfplugindocs generate change no file, gofmt -s and go vet -tags acceptance ./internal/provider/... are clean, make lint-golangci reports 0 issues, the lint-tfprovider, lint-examples-sh, lint-examples-tf and lint-custom checks pass, and make test passes.
This work comes from maintaining gitlab-mcp-server, whose upstream-bugs.md records everything done on its dependencies and sibling projects.