Documentation
¶
Overview ¶
Package planmodifiers provides shared Terraform Plugin Framework plan modifiers for use across all resource packages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanonicalEmptySet ¶
func CanonicalEmptySet() planmodifier.Set
CanonicalEmptySet returns a plan modifier for Optional+Computed Set<String> attributes that makes an empty set the canonical "no members" value: a null config (attribute omitted) plans as an empty set `[]`, the same value an explicit `[]` config and the read path both produce. This lets practitioners write `attr = []` as the natural "remove everything" gesture — and equally omit the attribute — without tripping an "inconsistent result after apply" error.
Why null config must plan as `[]` rather than the reverse: Terraform requires the planned value of an Optional+Computed attribute to equal the config value whenever the config is known and non-null, and `[]` is non-null — so a `[]` config must plan (and apply) as `[]`. The read path therefore canonicalises an empty wire result to `[]` (not null), and this modifier brings the null config into line so omission still clears (planning `[]` → the build path omits the empty wrapper → the server clears the category) and stays stable across plans (no perpetual "known after apply"). The attribute must be Computed for the modifier to set a value when the config is null.
A non-empty config flows through unchanged; an unknown config (interpolated from another resource) is left to resolve at apply.
func DecideResetForUnchangedString ¶
DecideResetForUnchangedString centralises the override decision for the String plan modifier so it can be unit-tested without constructing a full tfsdk.Plan / State. The surrounding plumbing in PlanModifyString (Raw null guards, config-value precedence, path reads) is covered by the acceptance suite.
Returns (value, true) when the caller should overwrite resp.PlanValue, or (zero, false) to leave it untouched (default Unknown).
- sourceEqual=false → (_, false): leave Unknown; apply writes the fresh server value.
- sourceEqual=true + state known + state non-null → (state, true): carry forward.
- state null or unknown → (_, false).
func ResetIfSourceChangedString ¶
func ResetIfSourceChangedString(sourcePaths ...path.Expression) planmodifier.String
ResetIfSourceChangedString returns a plan modifier for Optional+Computed string attributes whose server-derived value depends on the bytes of a *_file_source upload input. When any watched source attribute differs between state and plan, the attribute's plan value is left Unknown so the server can populate a fresh value during apply. When all sources are unchanged, the prior state value carries forward (UseStateForUnknown semantics) so trivial metadata updates do not churn the diff.
Types ¶
This section is empty.