Fix Plugin Framework convention gaps #34
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/plugin-framework-conventions"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Aligns the provider with
hashicorp/terraform-provider-scaffolding-frameworkconventions to unblock acceptance tests and production readiness. All changes are convention fixes -- no resource behavior changes.Changes
main.go-- Refactored to use provider factory pattern with version injection; added-debugflag withDebug: debugin ServeOpts for delve debugger attachmentprovider.go--New()now returnsfunc() provider.Provideraccepting a version string, matching the standard factory conventionresource_dns_record.go-- Added computedidattribute (compositedomain:type:name) withUseStateForUnknown()plan modifier; set inreadRecordIntoModelso Create/Read/Update/Import all populate itpkg/godaddy/client.go-- Replacedhttp.DefaultClientwithhashicorp/go-retryablehttpfor automatic retry on 429/500/502/503 with exponential backoff (max 4 retries, 1-30s wait);WithHTTPClientoption still bypasses retry client for testsdata_source_dns_records.go-- Addeddatasource.DataSourceWithConfigurecompile-time interface checkgo.mod/go.sum-- Addedhashicorp/go-retryablehttpandhashicorp/terraform-plugin-testingdependenciesTest Plan
go build ./...passes cleango vet ./...passes cleanTestNewClientandTestNewClientWithBaseURLunit tests passTF_ACC=1 GODADDY_API_KEY=... GODADDY_API_SECRET=...)Review Checklist
pkg/godaddy/tests still passgo build ./...andgo vet ./...pass cleandocs/conventions.mdreferenceWithHTTPClientoption preserved for test compatibilityidattribute usesUseStateForUnknown()per conventionRelated Notes
docs/conventions.mdfor the target patternsPR #34 Review
DOMAIN REVIEW
Tech stack: Go / Terraform Plugin Framework / OpenTofu provider
This PR aligns the provider with
hashicorp/terraform-provider-scaffolding-frameworkconventions. Seven files changed, 87 additions / 31 deletions. All changes are structural -- no resource behavior changes.Factory pattern (
provider.go,main.go): Correctly refactored.New(version string)now returnsfunc() provider.Provider, andmain.gocallsNew(version)to get the factory, passing it toproviderserver.Serve. Theversionpackage var defaults to"dev"and will be overridden by goreleaser-ldflags. The-debugflag withDebug: debuginServeOptsis standard for delve attachment. Clean.Computed
idattribute (resource_dns_record.go): TheIDfield is added todnsRecordResourceModel, schema declares it asComputedwithUseStateForUnknown(), andreadRecordIntoModelpopulates it asdomain:type:name. This is essential -- Plugin Framework resources must have anidattribute for state tracking. The composite format matches the existingImportStateparsing format (strings.SplitN(req.ID, ":", 3)), which is correct and consistent.Retryable HTTP (
pkg/godaddy/client.go): Replaceshttp.DefaultClientwithhashicorp/go-retryablehttp. Configuration is sensible: 4 retries, 1-30s exponential backoff,DefaultRetryPolicy(covers 429/5xx). Logger suppressed withrc.Logger = nilto avoid noisy debug output conflicting withterraform-plugin-log.WithHTTPClientstill bypasses the retry client entirely, preserving test control. Good design.Compile-time check (
data_source_dns_records.go): Addsdatasource.DataSourceWithConfigurecheck, bringing parity withdata_source_domains.gowhich already has it.Dependency updates (
go.mod,go.sum):go-retryablehttp v0.7.8added as direct dependency.terraform-plugin-logpromoted from indirect to direct (used in tflog calls). Several indirect deps bumped to latest patch versions. All clean.BLOCKERS
None.
This PR contains convention-only fixes with no new resource behavior. Existing unit tests (
TestNewClient,TestNewClientWithBaseURL) and integration tests are preserved and pass per the PR body. Theretryablehttpclient is tested indirectly through those existing tests sinceNewClientnow defaults to it, andWithHTTPClientcontinues to bypass it for test scenarios requiring precise HTTP control. No new untested functionality is introduced.NITS
Missing
resource.ResourceWithConfigurecompile-time check. The PR addsdatasource.DataSourceWithConfigurefordnsRecordsDataSource, anddata_source_domains.goalready has it, butresource_dns_record.gostill only checksresource.Resourceandresource.ResourceWithImportState. The resource implementsConfigure(), so it should also have:This would complete the convention alignment across all types.
PR body mentions
terraform-plugin-testingdependency but the diff does not include it. The "Changes" section lists "Addedhashicorp/terraform-plugin-testing" and the go.mod/go.sum diff does not contain any reference toterraform-plugin-testing. Either the dependency was not actually added, or it was added and reverted. The PR body should match the actual diff.terraform-plugin-logpromotion rationale.terraform-plugin-logmoved from indirect to direct ingo.mod. This is correct since the codebase importstflogdirectly inresource_dns_record.go, but it was already working as indirect. No issue, just noting the promotion is intentional cleanup.newRetryableHTTPClientcould accept tuning params. Currently hardcoded to 4 retries, 1s min, 30s max. For a provider managing many records, these are reasonable defaults. If GoDaddy rate-limits change, these would need updating. Consider making them configurable viaOptionfunctions in the future, though this is not blocking for a convention-fix PR.SOP COMPLIANCE
Closes #31in Related sectionPROCESS OBSERVATIONS
idare prerequisites for acceptance tests (#13), so this unblocks the next phase cleanly.terraform-plugin-testingmention in the PR body without corresponding diff changes is a minor documentation hygiene issue -- worth correcting to avoid confusion during future archaeology.VERDICT: APPROVED
Addressed QA review nits in
c544ee7:Added
resource.ResourceWithConfigurecompile-time check ondnsRecordResource-- the resource implementsConfigure()but lacked the interface assertion. Now matches the pattern used indata_source_domains.go.Re:
terraform-plugin-testingnot in diff -- This is expected.go mod tidycorrectly removed it because no source files import it yet. The dependency will be pulled in when acceptance test files (issue #13) are added. Updated the PR body's Changes section to clarify: the dep was added viago getbut pruned bygo mod tidysince it has no importers yet.