refactor: migrate gitlab_project_tag to Framework
Relates to issue #6694 (closed)
Changes
This MR migrates the gitlab_project_tag resource from Terraform Plugin SDK to Terraform Plugin Framework.
New Files Created:
-
internal/provider/resource_gitlab_project_tag.go- Framework-based resource implementation- Implements
resource.Resource,resource.ResourceWithConfigure, andresource.ResourceWithImportStateinterfaces - Complete CRUD operations (Create, Read, Update, Delete)
- Proper schema definition with all attributes: id, name, project, ref, message, protected, target, release, commit
- Nested objects for Release and Commit using SetNestedAttribute
- Two-part ID format:
<project>:<tag_name> - Helper function
modelToStateModel()for state management
- Implements
-
internal/provider/resource_gitlab_project_tag_test.go- Framework-based acceptance tests-
TestAccGitlabProjectTag_basictest covering create, import, and update scenarios - Helper functions for destroy checks, existence verification, and attribute validation
- Proper test isolation using
testutil.CreateProjectandtestutil.CreateBranches
-
Files Modified:
-
internal/provider/sdk/resource_gitlab_project_tag.go- Replaced with migration notice comment -
internal/provider/sdk/resource_gitlab_project_tag_test.go- Replaced with migration notice comment -
internal/provider/sdk/schema_gitlab_project_tag.go- Replaced with migration notice comment
Key Implementation Details:
-
Immutable Tags: No Update function needed - all attributes use
RequiresReplaceplan modifier since tags are immutable in GitLab API -
Two-Part ID Format: Resource ID is
<project>:<tag_name>usingutils.BuildTwoPartIDandutils.ParseTwoPartID - Ref Attribute: Only set during Create, not available after import (consistent with branch resource pattern)
- Nested Objects: Release and Commit are SetNestedAttribute objects that may be null
-
Time Formatting: Commit dates use
time.RFC3339format - Error Handling: 404 errors in Read function remove resource from state
-
Auto-Registration: Uses
init()function withregisterResource()to auto-register with provider
Testing:
The migration follows patterns established in similar resources like resource_gitlab_branch.go and maintains backward compatibility for users upgrading from the SDK version.
Edited by Duo Developer