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

Simplify findFunctionSchema #11575

Merged
merged 1 commit into from Dec 7, 2022
Merged

Conversation

iwahbe
Copy link
Member

@iwahbe iwahbe commented Dec 7, 2022

Instead of indirecting through .NET function names, just use the schema token to lookup the function.

@iwahbe iwahbe added impact/no-changelog-required This issue doesn't require a CHANGELOG update language/dotnet area/codegen SDK-gen, program-gen, convert labels Dec 7, 2022
@pulumi-bot
Copy link
Contributor

Changelog

[uncommitted] (2022-12-07)

@iwahbe iwahbe force-pushed the iwahbe/cleanup-dotnet-fn-aquisition branch from 6fefb40 to d83bd75 Compare December 7, 2022 10:55
Comment on lines 13 to 16
var subnets = vpc.Apply(vpc => Aws.Ec2.GetSubnetIds.Invoke(new()
{
VpcId = vpc.Apply(getVpcResult => getVpcResult.Id),
});
VpcId = vpc.Id,
}));
Copy link
Contributor

Choose a reason for hiding this comment

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

This diff doesn't look right. Although it compiles AFAIK, it makes for an ugly result with the outer apply. I think this is because an invoke bound to variable vpc was no longer tracked in generater.functionInvokes which caused this diff along with the other program diffs in the 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.

It compiles, but I agree that it looks bad. I don't understand why we see any of the diffs that we see. I assumed that this change would be more or less diff free.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, we are missing on tokens like azure:core:getResourceGroup, which should be azure:core/getResources:getResources. I'll add a lowering step here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Instead of lowering, I exposed the token -> schema.Function mechanism that PCL uses during binding.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

Update test output

Expose a token lookup method in PCL, and then use it instead of
`schema.PackageReference.Functions().Get`.
@iwahbe iwahbe force-pushed the iwahbe/cleanup-dotnet-fn-aquisition branch from d83bd75 to 6d4b3d6 Compare December 7, 2022 14:06
@iwahbe iwahbe requested a review from Zaid-Ajaj December 7, 2022 14:22
@iwahbe iwahbe self-assigned this Dec 7, 2022
@iwahbe iwahbe added this to the 0.82 milestone Dec 7, 2022
@iwahbe
Copy link
Member Author

iwahbe commented Dec 7, 2022

bors r+

bors bot added a commit that referenced this pull request Dec 7, 2022
11564: [sdk/dotnet/nodejs] Add InvokeSingle variants to dotnet and nodejs SDKs r=Zaid-Ajaj a=Zaid-Ajaj

<!--- 
Thanks so much for your contribution! If this is your first time contributing, please ensure that you have read the [CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md) documentation.
-->

# Description

Needed for #11418 where we have invoke calls that return a simple type (such as `number`) but the runtime and engine _require_ the outputs to be a struct (as per the RPC definition) so here we are adding variants of `invoke` that unwraps the returned object and gets the first value from that object.

For example, a provider with a schema `outputs: { type: "number" }` will have an invoke implementation that returns `{ __result: 42.0 }`, in these case (non-object return types) we use `InvokeSingle` instead of `Invoke`

> It doesn't matter what the name of the key is, we always get the first value by first key.

## Checklist

<!--- Please provide details if the checkbox below is to be left unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the Pulumi Service,
then the service should honor older versions of the CLI where this change would not exist.
You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Service API version
  <!-- `@Pulumi` employees: If yes, you must submit corresponding changes in the service repo. -->


11575: Simplify `findFunctionSchema` r=iwahbe a=iwahbe

Instead of indirecting through .NET function names, just use the schema token to lookup the function.

Co-authored-by: Zaid Ajaj <zaid.naom@gmail.com>
Co-authored-by: Ian Wahbe <ian@wahbe.com>
@bors
Copy link
Contributor

bors bot commented Dec 7, 2022

Build failed (retrying...):

@bors
Copy link
Contributor

bors bot commented Dec 7, 2022

Build succeeded:

@bors bors bot merged commit 1ae56cc into master Dec 7, 2022
@bors bors bot deleted the iwahbe/cleanup-dotnet-fn-aquisition branch December 7, 2022 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/codegen SDK-gen, program-gen, convert impact/no-changelog-required This issue doesn't require a CHANGELOG update language/dotnet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants