Skip to content

Conversation

@musa-cf
Copy link
Collaborator

@musa-cf musa-cf commented Nov 26, 2025

Implements complete migration for cloudflare_healthcheck resource from v4 to v5.

Major Changes:

  • Pattern 0 migration: Flat structure → Nested attributes (http_config/tcp_config)
  • HTTP/HTTPS fields moved into http_config nested attribute
  • TCP fields moved into tcp_config nested attribute
  • Headers transformed from Set to Map structure
  • Numeric fields converted from Int to Float64

Implementation:

  1. Helper Functions (internal/transform/hcl/attributes.go):

    • CreateNestedAttributeFromFields(): Creates nested attributes from field maps
    • MoveAttributesToNestedObject(): Moves multiple attributes into nested objects
  2. Migration Logic (internal/resources/healthcheck/v4_to_v5.go):

    • TransformConfig(): Handles HCL configuration transformations
    • TransformState(): Handles JSON state transformations
    • transformToHTTPConfig(): Creates http_config for HTTP/HTTPS types
    • transformToTCPConfig(): Creates tcp_config for TCP type
    • buildHeaderMapTokens(): Converts header blocks to map format
  3. Tests (internal/resources/healthcheck/):

    • v4_to_v5_test.go: 19 unit tests (70.3% coverage)
    • integration_state_test.go: 3 integration tests (30 instances)
  4. Integration Test Data (integration/v4_to_v5/testdata/healthcheck/):

    • input/: 28 v4 resource configurations (525 lines)
    • expected/: Generated v5 output for validation
  5. CLI Registration (cmd/tf-migrate/main.go):

    • Import healthcheck migrator for automatic registration

Test Results:

  • ✅ All 19 unit tests passing
  • ✅ All 30 integration instances transforming successfully
  • ✅ CLI tool successfully migrates both config and state files
  • ✅ 100% success rate on test data

Validation:

  • State transformation: Production ready
  • Config transformation: Complete and working
  • Complex transformations: Headers, nested attributes, type conversions all working

@ssicard ssicard force-pushed the feat/healthcheck-v4-to-v5-migration branch from ba2fb86 to e18d163 Compare December 3, 2025 15:06
@ssicard ssicard marked this pull request as ready for review December 4, 2025 15:34
musa-cf and others added 3 commits December 4, 2025 11:14
Implements complete migration for cloudflare_healthcheck resource from v4 to v5.

**Major Changes:**
- Pattern 0 migration: Flat structure → Nested attributes (http_config/tcp_config)
- HTTP/HTTPS fields moved into http_config nested attribute
- TCP fields moved into tcp_config nested attribute
- Headers transformed from Set to Map structure
- Numeric fields converted from Int to Float64

**Implementation:**

1. **Helper Functions** (internal/transform/hcl/attributes.go):
   - CreateNestedAttributeFromFields(): Creates nested attributes from field maps
   - MoveAttributesToNestedObject(): Moves multiple attributes into nested objects

2. **Migration Logic** (internal/resources/healthcheck/v4_to_v5.go):
   - TransformConfig(): Handles HCL configuration transformations
   - TransformState(): Handles JSON state transformations
   - transformToHTTPConfig(): Creates http_config for HTTP/HTTPS types
   - transformToTCPConfig(): Creates tcp_config for TCP type
   - buildHeaderMapTokens(): Converts header blocks to map format

3. **Tests** (internal/resources/healthcheck/):
   - v4_to_v5_test.go: 19 unit tests (70.3% coverage)
   - integration_state_test.go: 3 integration tests (30 instances)

4. **Integration Test Data** (integration/v4_to_v5/testdata/healthcheck/):
   - input/: 28 v4 resource configurations (525 lines)
   - expected/: Generated v5 output for validation

5. **CLI Registration** (cmd/tf-migrate/main.go):
   - Import healthcheck migrator for automatic registration

**Test Results:**
- ✅ All 19 unit tests passing
- ✅ All 30 integration instances transforming successfully
- ✅ CLI tool successfully migrates both config and state files
- ✅ 100% success rate on test data

**Validation:**
- State transformation: Production ready
- Config transformation: Complete and working
- Complex transformations: Headers, nested attributes, type conversions all working

Co-Authored-By: Claude <[email protected]>
@ssicard ssicard force-pushed the feat/healthcheck-v4-to-v5-migration branch from b58a910 to f231be1 Compare December 4, 2025 17:14
@ssicard ssicard marked this pull request as draft December 4, 2025 17:17
@ssicard ssicard marked this pull request as ready for review December 4, 2025 22:50
@ssicard ssicard merged commit 6c64cd3 into main Dec 5, 2025
10 checks passed
@ssicard ssicard deleted the feat/healthcheck-v4-to-v5-migration branch December 5, 2025 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants