Fix Access app domain and self_hosted_domains import #4708
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #4659
For some fields,
resourceCloudflareAccessApplicationRead
only sets the value if one is already present on the resource. This was introduced in #3340 to fix a bug becausedomains
andself_hosted_domains
are kind of computed/optional/conflict-with-each-other in an funny way. But doing this breaks imports because it's the special case where the values are not already present but we still want to set them.This PR moves all of its logic into a function called
resourceCloudflareAccessApplicationReadHelper
which has a special mode for importing. The original function is now just a call to the helper, passing in false for "not importing." And when importing, we call the helper directly and pass in true.I'm not the biggest fan of having a special mode like this, but it's the only solution I can think of (unless the behavior we want can be expressed in terms of normal computed/optional/conflicts properties etc.?)
We'll need to add the
|| importing
to the corresponding part in #4661 as a follow-up to this. And possibly the other fields that checkif _, ok := d.GetOk("foo"); ok {