refactor: migrate gitlab_project_milestone to Framework
Relates to issue #6713 (closed)
Changes
This MR migrates the gitlab_project_milestone resource from Terraform Plugin SDK to Terraform Plugin Framework.
New Files Created
-
internal/provider/resource_gitlab_project_milestone.go- Framework resource implementation- Complete CRUD operations (Create, Read, Update, Delete)
- State upgrade function (V0 to V1) for ID format migration from
<milestone_id>to<project>:<milestone_id> - Import support with passthrough ID
- Proper schema with all attributes matching SDK version
- State management via
state_eventAPI field - Date parsing using
gitlab.ParseISOTime()
-
internal/provider/resource_gitlab_project_milestone_test.go- Comprehensive test suite-
TestAccGitlabProjectMilestone_StateUpgradeV0- Unit test for state upgrade -
TestAccGitlabProjectMilestone_basic- Full CRUD acceptance test -
TestAccGitlabProjectMilestone_migrateFromSDKToFramework- Migration test from SDK v16.6
-
-
examples/resources/gitlab_project_milestone/resource.tf- Enhanced examples- Basic example with required fields
- Comprehensive example showing all optional fields
Key Implementation Details
Schema (Version 1):
-
project(Required, ForceNew) - Project ID or path -
title(Required, LengthAtLeast(1)) - Milestone title -
description,due_date,start_date,state(Optional, Computed) - Computed fields:
iid,milestone_id,project_id,created_at,updated_at,web_url,expired
ID Format Migration:
- V0 (SDK):
<milestone_id>(single part) - V1 (Framework):
<project>:<milestone_id>(two parts) - Automatic state upgrade for seamless migration
Special Behaviors Preserved:
- State managed via
state_eventAPI field ("activate" or "close") - State set after creation via separate Update call
- Date parsing uses
gitlab.ParseISOTime()for YYYY-MM-DD format - All computed fields use
UseStateForUnknown()plan modifiers
Testing
The implementation includes:
-
✅ Unit test for state upgrade validation -
✅ Full CRUD lifecycle acceptance test with import verification -
✅ Migration test validating upgrade from SDK v18.8 to Framework -
✅ Compatibility with existinggitlab_project_milestonedatasource
Next Steps
To verify the migration:
make build
make test RUN=TestAccGitlabProjectMilestone_StateUpgradeV0
make testacc-up
make testacc RUN=TestAccGitlabProjectMilestone
make reviewable
make testacc-down
The SDK resource files remain in internal/provider/sdk/ for backward compatibility during the transition period.
Edited by Heidi Berry