Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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. --> 11581: Fix PCL binding of options.range = number r=Frassle a=Frassle <!--- 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 <!--- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. --> Fixes the binding issue with `options { range = number }`. ## Checklist <!--- Please provide details if the checkbox below is to be left unchecked. --> - [x] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [ ] 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. --> Co-authored-by: Zaid Ajaj <zaid.naom@gmail.com> Co-authored-by: Fraser Waters <fraser@pulumi.com>
- Loading branch information
Showing
13 changed files
with
139 additions
and
36 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
...ding/20221206--sdk-dotnet-nodejs--add-inokesingle-variants-to-dotnet-and-nodejs-sdks.yaml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
changes: | ||
- type: feat | ||
scope: sdk/dotnet,nodejs | ||
description: Add InvokeSingle variants to dotnet and nodejs SDKs |
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
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
20 changes: 12 additions & 8 deletions
20
pkg/codegen/testing/test/testdata/simple-range-pp/dotnet/simple-range.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,24 @@ | ||
using System.Collections.Generic; | ||
using Pulumi; | ||
using Aws = Pulumi.Aws; | ||
using Random = Pulumi.Random; | ||
|
||
return await Deployment.RunAsync(() => | ||
{ | ||
var bucket = new List<Aws.S3.Bucket>(); | ||
for (var rangeIndex = 0; rangeIndex < 10; rangeIndex++) | ||
var numbers = new List<Random.RandomInteger>(); | ||
for (var rangeIndex = 0; rangeIndex < 2; rangeIndex++) | ||
{ | ||
var range = new { Value = rangeIndex }; | ||
bucket.Add(new Aws.S3.Bucket($"bucket-{range.Value}", new() | ||
numbers.Add(new Random.RandomInteger($"numbers-{range.Value}", new() | ||
{ | ||
Website = new Aws.S3.Inputs.BucketWebsiteArgs | ||
{ | ||
IndexDocument = $"index-{range.Value}.html", | ||
}, | ||
Min = 1, | ||
Max = range.Value, | ||
Seed = $"seed{range.Value}", | ||
})); | ||
} | ||
return new Dictionary<string, object?> | ||
{ | ||
["first"] = numbers[0].Id, | ||
["second"] = numbers[1].Id, | ||
}; | ||
}); | ||
|
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
16 changes: 10 additions & 6 deletions
16
pkg/codegen/testing/test/testdata/simple-range-pp/nodejs/simple-range.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
import * as pulumi from "@pulumi/pulumi"; | ||
import * as aws from "@pulumi/aws"; | ||
import * as random from "@pulumi/random"; | ||
|
||
const bucket: aws.s3.Bucket[] = []; | ||
for (const range = {value: 0}; range.value < 10; range.value++) { | ||
bucket.push(new aws.s3.Bucket(`bucket-${range.value}`, {website: { | ||
indexDocument: `index-${range.value}.html`, | ||
}})); | ||
const numbers: random.RandomInteger[] = []; | ||
for (const range = {value: 0}; range.value < 2; range.value++) { | ||
numbers.push(new random.RandomInteger(`numbers-${range.value}`, { | ||
min: 1, | ||
max: range.value, | ||
seed: `seed${range.value}`, | ||
})); | ||
} | ||
export const first = numbers[0].id; | ||
export const second = numbers[1].id; |
15 changes: 9 additions & 6 deletions
15
pkg/codegen/testing/test/testdata/simple-range-pp/python/simple-range.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
import pulumi | ||
import pulumi_aws as aws | ||
import pulumi_random as random | ||
|
||
bucket = [] | ||
for range in [{"value": i} for i in range(0, 10)]: | ||
bucket.append(aws.s3.Bucket(f"bucket-{range['value']}", website=aws.s3.BucketWebsiteArgs( | ||
index_document=f"index-{range['value']}.html", | ||
))) | ||
numbers = [] | ||
for range in [{"value": i} for i in range(0, 2)]: | ||
numbers.append(random.RandomInteger(f"numbers-{range['value']}", | ||
min=1, | ||
max=range["value"], | ||
seed=f"seed{range['value']}")) | ||
pulumi.export("first", numbers[0].id) | ||
pulumi.export("second", numbers[1].id) |
16 changes: 10 additions & 6 deletions
16
pkg/codegen/testing/test/testdata/simple-range-pp/simple-range.pp
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
resource bucket "aws:s3:Bucket" { | ||
resource numbers "random:index/randomInteger:RandomInteger" { | ||
options { | ||
range = 10 | ||
range = 2 | ||
} | ||
website = { | ||
indexDocument = "index-${range.value}.html" | ||
} | ||
} | ||
|
||
min = 1 | ||
max = range.value | ||
seed = "seed${range.value}" | ||
} | ||
|
||
output first { value = numbers[0].id } | ||
output second { value = numbers[1].id } |
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
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
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
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
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