Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better determine when to plan optional+computed #32551

Merged
merged 2 commits into from Jan 25, 2023

Conversation

jbardin
Copy link
Member

@jbardin jbardin commented Jan 20, 2023

In the common cases we cannot determine if a null optional+computed value in the configuration was previously set when the value also exists in the state. There is however one situation where we can determine if there was previously a configuration value, we can check if a complex object in state must have at least partially come from configuration by seeing if the prior value has any non-null attributes which are not computed in the schema.

We can check if an object in state must have at least partially come
from configuration, by seeing if the prior value has any non-null
attributes which are not computed in the schema.

This is used when the configuration contains a null optional+computed
value, and we want to know if we should plan to send the null value or
the prior state.
"obj": cty.ObjectVal(map[string]cty.Value{
"optional": cty.StringVal("prior"),
"computed": cty.StringVal("prior computed"),
"list_obj": cty.NullVal(cty.List(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the comment on ll. 1992-1993 be removed?
"The entire prior nested value should be represented in the proposed new object if the configuration is null."

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooh, that's a good catch! The result is good, let me check that it's what we actually want at this point in the stack of PRs though (this was broken up from a single huge PR).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, this is the test I thought its was! updated the comment to describe the more accurate planning result.

Copy link
Member

@kmoe kmoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Base automatically changed from jbardin/optional-computed-nested-objects to main January 25, 2023 20:04
@jbardin jbardin merged commit f6af5c1 into main Jan 25, 2023
@jbardin jbardin deleted the jbardin/optional-computed-null branch January 25, 2023 20:05
@github-actions
Copy link

Reminder for the merging maintainer: if this is a user-visible change, please update the changelog on the appropriate release branch.

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants