Skip to content

Commit e18d163

Browse files
musa-cfclaude
authored andcommitted
feat: add cloudflare_healthcheck v4 to v5 migration
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 <noreply@anthropic.com>
1 parent 914f7a8 commit e18d163

File tree

9 files changed

+3922
-0
lines changed

9 files changed

+3922
-0
lines changed

cmd/tf-migrate/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ import (
1818
"github.com/cloudflare/tf-migrate/internal/pipeline"
1919
"github.com/cloudflare/tf-migrate/internal/registry"
2020
"github.com/cloudflare/tf-migrate/internal/transform"
21+
22+
// Import resource migrators so their init() functions run
23+
_ "github.com/cloudflare/tf-migrate/internal/resources/healthcheck"
2124
)
2225

2326
type config struct {

0 commit comments

Comments
 (0)