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

Fix resource-ref-as-ID marshaling. #6125

Merged
merged 3 commits into from
Jan 16, 2021
Merged

Fix resource-ref-as-ID marshaling. #6125

merged 3 commits into from
Jan 16, 2021

Conversation

pgavlin
Copy link
Member

@pgavlin pgavlin commented Jan 15, 2021

When marshaling a resource reference as its ID (i.e. when
opts.KeepResources is false, as it will be in the case of downlevel SDKs
and resource providers), we must take care to marshal/unmarshal an empty
ID as the unknown property value.

Fixes #5939.

When marshaling a resource reference as its ID (i.e. when
opts.KeepResources is false, as it will be in the case of downlevel SDKs
and resource providers), we must take care to marshal/unmarshal an empty
ID as the unknown property value.

Fixes #5939.
@pgavlin pgavlin added the impact/no-changelog-required This issue doesn't require a CHANGELOG update label Jan 15, 2021
- Bifurcate resource reference creation into two methods: one for
  creating references to custom resources and one for creating
  references to component resources.
- Store the ID in a resource reference as a PropertyValue s.t. it can be
  computed.
- Add a helper method for retrieving the ID as a string + an indicator of
  whether or not the reference has an ID.
Copy link
Member

@lblackstone lblackstone left a comment

Choose a reason for hiding this comment

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

I like the refactor; much easier to understand

func MakeCustomResourceReference(urn URN, id ID, packageVersion string) PropertyValue {
idProp := NewStringProperty(string(id))
if id == "" {
idProp = MakeComputed(NewStringProperty(""))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
idProp = MakeComputed(NewStringProperty(""))
idProp = MakeComputed(idProp)

@pgavlin pgavlin merged commit 2f0dba2 into master Jan 16, 2021
@pulumi-bot pulumi-bot deleted the pgavlin/gh5939 branch January 16, 2021 00:07
@stack72 stack72 mentioned this pull request Jan 19, 2021
lblackstone added a commit that referenced this pull request Jan 21, 2021
PR #6125 introduced a bug by marshaling resource
ids as PropertyValues, but not handling that case on
the unmarshaling side. The previous code assumed
that the id was a simple string value. This bug prevents
any stack update operations (preview, update, destroy,
refresh). Since this change was already
released, we must now handle both cases in the
unmarshaling code.
stack72 added a commit that referenced this pull request Jan 21, 2021
pgavlin added a commit that referenced this pull request Jan 21, 2021
pgavlin pushed a commit that referenced this pull request Jan 21, 2021
PR #6125 introduced a bug by marshaling resource
ids as PropertyValues, but not handling that case on
the unmarshaling side. The previous code assumed
that the id was a simple string value. This bug prevents
any stack update operations (preview, update, destroy,
refresh). Since this change was already
released, we must now handle both cases in the
unmarshaling code.
lblackstone added a commit that referenced this pull request Jan 21, 2021
* Fix resource-ref-as-ID marshaling. (#6125)

This reapplies 2f0dba2.

* Fix malformed resource value bug

PR #6125 introduced a bug by marshaling resource
ids as PropertyValues, but not handling that case on
the unmarshaling side. The previous code assumed
that the id was a simple string value. This bug prevents
any stack update operations (preview, update, destroy,
refresh). Since this change was already
released, we must now handle both cases in the
unmarshaling code.

* Add resource ref unit tests for the Go SDK. (#6142)

This reapplies 3d50591.

Co-authored-by: Pat Gavlin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impact/no-changelog-required This issue doesn't require a CHANGELOG update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Preview fails when resource refs are enabled
3 participants