mirror of
https://github.com/opentffoundation/opentf.git
synced 2026-02-21 20:00:43 -05:00
core: Report reason for deferring data read until apply
We have two different reasons why a data resource might be read only during apply, rather than during planning as usual: the configuration contains unknown values, or the data resource as a whole depends on a managed resource which itself has a change pending. However, we didn't previously distinguish these two in a way that allowed the UI to describe the difference, and so we confusingly reported both as "config refers to values not yet known", which in turn led to a number of reasonable questions about why Terraform was claiming that but then immediately below showing the configuration entirely known. Now we'll use our existing "ActionReason" mechanism to tell the UI layer which of the two reasons applies to a particular data resource instance. The "dependency pending" situation tends to happen in conjunction with "config unknown", so we'll prefer to refer that the configuration is unknown if both are true.
This commit is contained in:
@@ -71,7 +71,13 @@ func ResourceChange(
|
||||
case plans.Create:
|
||||
buf.WriteString(fmt.Sprintf(color.Color("[bold] # %s[reset] will be created"), dispAddr))
|
||||
case plans.Read:
|
||||
buf.WriteString(fmt.Sprintf(color.Color("[bold] # %s[reset] will be read during apply\n # (config refers to values not yet known)"), dispAddr))
|
||||
buf.WriteString(fmt.Sprintf(color.Color("[bold] # %s[reset] will be read during apply"), dispAddr))
|
||||
switch change.ActionReason {
|
||||
case plans.ResourceInstanceReadBecauseConfigUnknown:
|
||||
buf.WriteString("\n # (config refers to values not yet known)")
|
||||
case plans.ResourceInstanceReadBecauseDependencyPending:
|
||||
buf.WriteString("\n # (depends on a resource or a module with changes pending)")
|
||||
}
|
||||
case plans.Update:
|
||||
switch language {
|
||||
case DiffLanguageProposedChange:
|
||||
@@ -166,7 +172,7 @@ func ResourceChange(
|
||||
))
|
||||
case addrs.DataResourceMode:
|
||||
buf.WriteString(fmt.Sprintf(
|
||||
"data %q %q ",
|
||||
"data %q %q",
|
||||
addr.Resource.Resource.Type,
|
||||
addr.Resource.Resource.Name,
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user