Add Plugin Framework conventions doc #33
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "docs/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
docs/conventions.mdcapturing audit findings from comparing our provider against HashiCorp's scaffolding provider, terraform-plugin-framework source, and OpenTofu internalsChanges
docs/conventions.md(new) — comprehensive Plugin Framework best practices referenceREADME.md— added Conventions entry to Documentation tableTest Plan
Review Checklist
Related Notes
PR #33 Review
DOMAIN REVIEW
Tech stack: Go / Terraform Plugin Framework documentation. Applied domain checks for Go syntax correctness, Plugin Framework API accuracy, and consistency with the existing codebase.
1. Provider Factory Example -- Incorrect Invocation in Test Code (docs/conventions.md, line 130)
The conventions doc defines
New()as returning a factory:But the acceptance test provider factory example calls
New("test")()(with double invocation):providerserver.NewProtocol6WithErrorexpects afunc() provider.Provider, not aprovider.Provider. SinceNew("test")already returnsfunc() provider.Provider, the correct call is:The trailing
()unwraps the factory prematurely, passing a bareprovider.Provider-- this would not compile. This is a real bug in the documentation example.2. Factory Pattern vs Current Code -- Prescriptive Gap is Fine but Should Be Explicit
Current
provider.gohasNew() provider.Provider(returns provider directly). The conventions doc prescribesNew(version string) func() provider.Provider(factory pattern with version injection). This is clearly an intentional improvement target, not a mismatch -- the doc is a conventions reference, not a mirror of current state. However, a brief note like "NOTE: current code uses a simpler signature; migrate to this pattern per #31" would prevent confusion about whether the doc is descriptive or prescriptive.3. All Other Code Examples -- Verified Correct
errors.Aspattern matches the actualgodaddy.APIErrorstruct inclient.go(pointer receiver,StatusCodeandMessagefields)godaddy.NewClient(key, secret)2-arg call is valid against actual variadic signatureNewClient(apiKey, apiSecret string, opts ...Option)client.GetRecords(ctx, domain, type, name)matches actual signature indns.goMarkdownDescriptionrecommendation is consistent -- current code usesDescriptionon provider schema attributes, confirming this is a forward-looking conventionresp.State.RemoveResource(ctx)drift detection pattern is standard Plugin Frameworkvar _ provider.Provider = (*godaddyProvider)(nil)inprovider.go4.
ConfigStateChecksvsCheckin Test ExampleThe test example uses
ConfigStateCheckswithstatecheck.StateCheck-- this is the newer Plugin Framework testing API (v1.7+). This is correct and forward-looking. The older pattern usesCheck: resource.ComposeAggregateTestCheckFunc(...). Good choice to document the modern approach.BLOCKERS
Provider factory test example has a compile error (finding #1 above).
New("test")()passesprovider.Providerto a function expectingfunc() provider.Provider. Fix: remove the trailing(). This is a docs-only PR, so this is not a production code bug, but shipping incorrect Go code examples in a conventions reference undermines the doc's purpose as an authoritative guide. This should be fixed before merge.NITS
Prescriptive vs descriptive clarity: Consider adding a brief note at the top of
docs/conventions.mdstating whether examples reflect current code or target conventions. Something like: "Examples show target patterns. Where current code differs, convention gap issues track the migration." This prevents developers from assuming the doc mirrors current state.GODADDY_TEST_DOMAINenv var: The test isolation section mentionsGODADDY_TEST_DOMAINbut thetestAccPreCheckexample only checksGODADDY_API_KEYandGODADDY_API_SECRET. Consider adding the domain check to the precheck example for consistency.go-retryablehttpmention: The HTTP Client section recommendshashicorp/go-retryablehttpbut does not show an example of wiring it. A 2-line snippet showingretryablehttp.NewClient()wrapped with the existingWithHTTPClientoption would make this actionable.Description field in provider schema: Current
provider.gousesDescriptionon schema attributes (lines 46, 50). The conventions doc recommendsMarkdownDescription. Might be worth noting this as a gap to fix in #31.SOP COMPLIANCE
PROCESS OBSERVATIONS
VERDICT: NOT APPROVED
One blocker: the provider factory test example contains a Go compilation error (
New("test")()should beNew("test")). Fix the trailing()and this is ready to merge. Everything else is solid.PR #33 Re-Review
DOMAIN REVIEW
Stack: Documentation (Go/Terraform Plugin Framework conventions)
Re-review after fix for the blocker found in initial review.
Previous blocker (RESOLVED): The provider factory example previously had
New("test")()-- a double invocation that would pass aprovider.Providerinstance whereNewProtocol6WithErrorexpects afunc() provider.Providerfactory. This has been corrected toNew("test"), which correctly passes the factory function. Fix verified.Full doc audit (231 lines):
ConfigStateCheckswithstatecheck.ExpectKnownValue/tfjsonpathreflects the modern testing API (v1.6+), not the deprecatedCheckfielderrors.Asusage is correct Go idiom for wrapped error handlingRemoveResourcedrift detection pattern is correctBLOCKERS
None. Previous blocker resolved.
NITS
None.
SOP COMPLIANCE
PROCESS OBSERVATIONS
Clean docs-only PR. The conventions doc provides a solid reference for implementation tickets (#31, #13). No deployment risk.
VERDICT: APPROVED