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

[WIP] helper/schema: implement ComputedWhen #4846

Closed
wants to merge 1 commit into from

Conversation

phinze
Copy link
Contributor

@phinze phinze commented Jan 27, 2016

ComputedWhen is a long TODOd schema feature that allows any field to
be marked as computed when some target field changes.

Right now Terraform has no way of invalidating a field until it sees
that field changes, but there are plenty of examples of scenarios
where one field changing implies that another field is going to be
assigned a new value.

I'd like to do a bit more testing and refactoring before this is fully ready. But I wanted to push what I had for now since it seems to be working for the cases I've tried it.

This should improve the experience of using consul_keys and atlas_artifacts (for scenarios where two plan/apply cycles would be required for a change to propagate), as well as any other resources where we find similar scenarios that we'd like to use ComputedWhen.

// finished the diff.
// TODO
for k, schema := range m {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here be dragons. Lots of looping logic below. Would love to come up with a more elegant way to do this. Considered attempting to thread ComputedWhen knowledge/context into the original diff generation rather than this post-hoc munging, but initial spikes felt even more messy than this.

@radeksimko radeksimko added the wip label Jan 30, 2016
@phinze phinze removed the wip label Feb 9, 2016
ComputedWhen is a long `TODO`d schema feature that allows any field to
be marked as computed when some terget field changes.

Right now Terraform has no way of invalidating a field until it sees
_that_ field changes, but there are plenty of examples of scenarios
where one field changing implies that another field is going to be
assigned a new value.
@phinze
Copy link
Contributor Author

phinze commented Mar 27, 2017

ComputedWhen is still a good idea to implement, as it has the potential to trigger richer plan-time output, but this is an old PR and I have no plans to pick it up in the foreseeable future. /cc @jbardin to put this on your "someday" radar 💌

@phinze phinze closed this Mar 27, 2017
@grubernaut grubernaut deleted the phinze/computed-when branch April 25, 2017 21:42
@jbardin jbardin self-assigned this May 16, 2017
@mavogel
Copy link

mavogel commented Dec 14, 2017

@jbardin: is there any update on this issue of the implementation of ComputedWhen? If not what is missing in phinze's approach? Or is a complete redesign an option due to the nested for-loops?

@jbardin
Copy link
Member

jbardin commented Dec 15, 2017

Hi @mavogel,

I think this use case is now more generally covered by the new CustomizeDiff field in schema.Resource.

@ghost
Copy link

ghost commented Apr 5, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants