refactor: migrate github integration to framework

Fixes #6742 (closed)

This merge request updates the GitLab GitHub integration feature in a Terraform provider. The main changes include:

Documentation improvements: Updated field descriptions to be more specific, clarifying that timestamps are in ISO8601 format and explaining what the ID field contains.

New implementation: Added a complete new resource file that handles GitHub integrations for GitLab projects. This includes all the standard operations - creating, reading, updating, and deleting integrations.

Backward compatibility: The code maintains support for the old resource name (gitlab_integration_github) while introducing the new preferred name (gitlab_project_integration_github). The old version is marked as deprecated and will be removed in version 19.0.

Migration support: Added functionality to automatically move existing configurations from the old resource name to the new one, making it easier for users to upgrade.

Better testing: Updated the test file to use newer testing frameworks and added more comprehensive checks to ensure the integration works correctly.

Enhanced validation: Added proper URL validation for the GitHub repository field and improved error handling throughout the code.

The overall goal is to provide a cleaner, more maintainable way to manage GitHub integrations while ensuring existing users can smoothly transition to the new approach.Relates to #6742 (closed)

Changes

This MR completes the migration of gitlab_project_integration_github resource from Terraform SDK to Framework Plugin.

Files Created

  1. internal/provider/resource_gitlab_project_integration_github.go - Framework implementation

    • Two resource constructors: NewGitLabProjectIntegrationGithubResource() and NewGitLabIntegrationGithubResource() (deprecated)
    • Complete CRUD operations with proper 404 error handling
    • Token marked as Sensitive: true
    • HttpUrlValidator for repository_url
    • Proper plan modifiers (RequiresReplace for project, UseStateForUnknown for computed fields)
  2. internal/provider/resource_gitlab_project_integration_github_test.go - Comprehensive acceptance tests

    • TestAccGitlabProjectIntegrationGithub_basic - Full lifecycle test with 6 steps
    • TestAccGitlabProjectIntegrationGithub_basic_deprecated - Test using deprecated resource name
    • TestAccGitlabProjectIntegrationGithub_migrateFromSDKToFramework - Migration test from SDK v18.8.1
    • All tests include testutil.SkipIfCE(t) for Enterprise Edition requirement

Files Modified

  1. internal/provider/sdk/resource_gitlab_project_integration_github.go - Replaced with migration comment
  2. internal/provider/sdk/resource_gitlab_project_integration_github_test.go - Replaced with migration comment

Key Implementation Details

  • Dual Resource Names: Supports both gitlab_project_integration_github (new) and gitlab_integration_github (deprecated, to be removed in v19.0)
  • Enterprise Edition: Requires GitLab EE - all tests call testutil.SkipIfCE(t)
  • Token Security: Token attribute excluded from import verification
  • ID Format: Resource ID is the project ID (simple format)
  • Time Formatting: Uses time.RFC3339 for timestamp formatting
  • Static Context Default: Defaults to true via Computed + Optional with UseStateForUnknown plan modifier

Testing Instructions

# Build and verify code quality
make reviewable

# Start GitLab EE container (requires Gitlab-license.txt in repo root)
unset GITLAB_TOKEN && SERVICE=gitlab-ee make testacc-up

# Run the specific tests
unset GITLAB_TOKEN && make testacc RUN=TestAccGitlabProjectIntegrationGithub

# Stop container when done
unset GITLAB_TOKEN && make testacc-down

The migration follows established patterns from resource_gitlab_project_integration_jenkins.go and resource_gitlab_project_integration_external_wiki.go.

Edited by Heidi Berry

Merge request reports

Loading