Documentation
¶
Overview ¶
Package sensitive is a choudoufu fork port (#2410, of #2256): sensitive values on OpenTofu's new runtime (internal/engine).
The new runtime's evaluator already marks what is sensitive: a `sensitive = true` variable or output, the sensitive() function, and everything derived from them carry marks.Sensitive through evaluation. What it does not do is carry those marks across the places where a value leaves evaluation, which the old runtime (internal/tofu) does:
- planning hands the provider the configuration unmarked and records the planned change without its marks, so a sensitive argument plans, shows and reaches downstream references as plain text. Planned puts back the configuration's sensitive paths and the schema's sensitive attributes on the planned value, as node_resource_abstract_instance.go plan does, and Prior marks the prior object with the state's sensitive paths and the schema's, as its refresh does. Action turns a NoOp whose sensitivity changed into an Update, as the old runtime does, so the stored sensitive paths follow the configuration.
- applying stored the provider's new object with no sensitive paths. That is fixed outside this port, unconditionally, by internal/engine/applying's storedSensitiveValue: a schema-sensitive attribute reached state and live-mode records unmarked even where this row never refused anything, so the fix cannot be switchable.
- planning writes a root output's value into the plan's prior state still marked, which fails to serialize; OutputValue unmarks it and keeps its sensitivity as the state's flag.
- a root output whose value is sensitive must be declared sensitive. UndeclaredRootOutput is that check, which the old runtime makes in node_output.go.
Only marks.Sensitive is handled. The engine's own marks (pending change, drift, resource instance) are never written by this port, and a state or record never receives one.
Upstream tracks the new runtime's mark gaps as opentofu/opentofu #4360. Every call site is commented "choudoufu fork port (#2410): remove when upstream #4360 lands". Removing the port is deleting this package, those call sites, the "sensitive" row's fork_port and switch in internal/live/newruntime/gaps.json, and the port tag on that row's detector in internal/live/newruntime/checks.go.
It is registered in internal/engine/forkport as Name. Switched off (forkport.Enabled), every function returns its input unchanged and the gap table's preflight refuses sensitive variables, outputs and the sensitive() function again, under its "sensitive" row.
Index ¶
- Constants
- func Action(action plans.Action, before, after cty.Value) plans.Action
- func Enabled() bool
- func OutputValue(v cty.Value) (cty.Value, bool)
- func Planned(planned, config, prior cty.Value, ignore []cty.Path, ...) cty.Value
- func Prior(prior cty.Value, statePaths []cty.Path, schema *configschema.Block) cty.Value
- func UndeclaredRootOutput(root, declaredSensitive bool, v cty.Value, subject *hcl.Range) *hcl.Diagnostic
Constants ¶
const Name = "sensitive"
Name is the port's name in the internal/engine/forkport registry.
Variables ¶
This section is empty.
Functions ¶
func Action ¶
Action returns action, except that a NoOp whose planned value is sensitive at different paths than the prior object is an Update, so that applying it stores the new sensitive paths.
func OutputValue ¶
OutputValue returns a root output value ready to store in a state: with no marks, and sensitive when any part of it was. With the port off it returns v as it is and false.
func Planned ¶
func Planned(planned, config, prior cty.Value, ignore []cty.Path, schema *configschema.Block) cty.Value
Planned returns planned marked sensitive wherever config is, and wherever schema declares an attribute sensitive. config is the evaluated configuration value, with its marks; planned is the provider's planned object, which the engine planned from the unmarked configuration. Under an ignore_changes path the configuration was replaced by the prior object, so there prior's sensitive marks count instead of config's, as on the old runtime; prior is the marked prior object (Prior), null or cty.NilVal when there is none, and an empty path in ignore is ignore_changes = all.
func Prior ¶
Prior returns prior, a prior object decoded from state without marks, marked sensitive at the state's sensitive paths and wherever schema declares an attribute sensitive.
func UndeclaredRootOutput ¶
func UndeclaredRootOutput(root, declaredSensitive bool, v cty.Value, subject *hcl.Range) *hcl.Diagnostic
UndeclaredRootOutput is the old runtime's error for a root module output whose value is sensitive but that is not declared sensitive. It returns nil when the output is in a child module, is declared sensitive, or its value is not sensitive, and with the port off.
Types ¶
This section is empty.