-
Notifications
You must be signed in to change notification settings - Fork 25
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
[sdk] Implement reflection-based RegisterOutputs for component resources #200
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Zaid-Ajaj
force-pushed
the
zaid/reflection-based-register-outputs
branch
from
October 31, 2023 15:38
0070dfb
to
6f78792
Compare
Really? Can't you test this in a mock stack? |
Frassle
reviewed
Oct 31, 2023
Frassle
added
the
impact/no-changelog-required
This issue doesn't require a CHANGELOG update
label
Oct 31, 2023
no-changlog-required because changelog bot doesn't understand changie yet. |
Frassle
reviewed
Nov 1, 2023
Frassle
approved these changes
Nov 1, 2023
jkerken
pushed a commit
to algompluecker/pulumi-dotnet
that referenced
this pull request
Jul 24, 2024
…ces (pulumi#200) * Implement reflection-based RegisterOutputs() for component resources * Extend IMocks with RegisterResourceOutputs to allow unit testing registered outputs * Outputs in MockRegisterResourceOutputsRequest are now typed as Output<object?>
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
kind/enhancement
Improvements or new features
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.
When writing component resources, at the very end of the constructor logic, developers have to make a call to
RegisterOutputs(...)
and provide a bag of outputs from the instance properties declared with[Output]
property.This PR makes it such that developers can use
RegisterOutputs()
without providing anything and it will use reflection to deduce the keys and values of the outputs from the properties of the component resource. It works as follows:Any property of typeOutput<T>
is considered an output with the key equal to the name of the property[Output]
is considered an output the key equal to the name of the property[Output(name: "<overriddenPropertyName>")]
is considered an output the key equal to<overriddenPropertyName>
Since we don't have a good way to testRegisterOutputs
, I moved the logic to an internal, static function calledCollectOutputProperties
which is unit testable on its own. Then in a test stack, made it return the stack outputs from the collected output properties of a test component (BasicComponent
) so we can assert the resulting keys and valuesThe PR extends
IMocks
with support forRegisterResourceOutputs
such that we can unit test the registered outputs by component resources or stacks