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, and resource.ResourceWithImportState interfaces
    • 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
  • internal/provider/resource_gitlab_project_tag_test.go - Framework-based acceptance tests

    • TestAccGitlabProjectTag_basic test covering create, import, and update scenarios
    • Helper functions for destroy checks, existence verification, and attribute validation
    • Proper test isolation using testutil.CreateProject and testutil.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 RequiresReplace plan modifier since tags are immutable in GitLab API
  • Two-Part ID Format: Resource ID is <project>:<tag_name> using utils.BuildTwoPartID and utils.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.RFC3339 format
  • Error Handling: 404 errors in Read function remove resource from state
  • Auto-Registration: Uses init() function with registerResource() 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

Merge request reports

Loading