Write a plain environment scope in the gitlab_project_variable state upgrade
What does this MR do and why?
The schema version 0 upgrader of gitlab_project_variable builds the new ID with fmt.Sprintf("%s:%s:%s", project, key, environmentScope), where environmentScope is a types.String, which %s prints in Go quotes (#L334-341). A two-part 123:MY_KEY with the default scope becomes 123:MY_KEY:"*", Read filters on "*", gets a 404 and removes the variable from the state (#L168-194), so the plan wants to create it and the apply fails with (MY_KEY) has already been taken.
This MR builds the ID from ValueString(). Only a version 0 state with a two-part ID goes through this code: 16.0.0 and earlier wrote version 0, and a two-part ID was created by a release before 3.0.0 or left by an import by <project>:<key> with 15.11.x or earlier. A three-part ID is left as it is, and the schema doesn't change.
TestAccGitlabProjectVariable_schemaMigrationV0toV1 creates the variable with 16.0.0, the last release at schema version 0, then plans and applies the same configuration with this provider. The plan must be empty, the ID must end in the plain scope, and an import must match the upgraded state. 16.0.0 writes a three-part ID, which the upgrader keeps, so this test passes on main too.
16.0.0 is added to .gitlab/ci/external-providers.txt, as 15.11.0 was in !3344 (merged). This rebuilds the acceptance CI image, which the community fork can't do, so the acceptance jobs need a pipeline in the parent project.
Closes #6918 (closed)
How to verify
make testacc-up
make testacc RUN=TestAccGitlabProjectVariable_schemaMigrationV0toV1What I ran (Go 1.26.10, Terraform 1.4.0, GitLab CE 19.5.0)
go test --tags acceptance -v ./internal/provider/ -run 'TestAccGitlabProjectVariable_' against a GitLab CE 19.5.0 container started from this repository's scripts/gitlab.rb and scripts/healthcheck-and-setup.sh. Terraform installed 16.0.0 and 17.8.0 from a mirror built the way .gitlab/ci/Dockerfile builds it, through this branch's terraformrc with only its path changed. On this branch all seven TestAccGitlabProjectVariable_ tests pass, and so do all twelve with this branch merged into the current main. TestAccGitlabProjectVariable_schemaMigrationV0toV1 also passes on main without the fix.
With the Terraform CLI against a GitLab CE 19.5.0, on a state that 15.11.0 wrote by importing 28:MY_KEY: provider 19.5.0 refreshed it as 28:MY_KEY:"*", planned to create it, and the apply failed with (MY_KEY) has already been taken. A build of this branch planned no changes, and terraform apply -refresh-only left it at schema version 1 with id = "28:MY_KEY:*".
make test, make lint-golangci (0 issues), lint-tfprovider, lint-custom, gofmt -s, go vet -tags acceptance and TestExternalProvidersAreMirrored pass, on this branch and merged into main.