Skip to content

Commit

Permalink
Merge #11461
Browse files Browse the repository at this point in the history
11461: Fix the aws-eks programgen example r=iwahbe a=iwahbe

Fix TS list iteration. This involves fixing `lambda` generation when exporting an object, as well as fixing the argument order when mapping over arrays.

Fixes #8067 

Co-authored-by: Ian Wahbe <ian@wahbe.com>
  • Loading branch information
bors[bot] and iwahbe committed Nov 24, 2022
2 parents 449307d + d62390e commit 35f8427
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
5 changes: 3 additions & 2 deletions pkg/codegen/nodejs/gen_program_expressions.go
Expand Up @@ -373,11 +373,12 @@ func (g *generator) GenFunctionCallExpression(w io.Writer, expr *model.FunctionC
g.genRange(w, call, true)
return
}
g.Fgenf(w, "%.20v.map((k, v)", expr.Args[0])
// Mapping over a list with a tuple receiver accepts (value, index).
g.Fgenf(w, "%.20v.map((v, k)", expr.Args[0])
case *model.MapType, *model.ObjectType:
g.Fgenf(w, "Object.entries(%.v).map(([k, v])", expr.Args[0])
}
g.Fgenf(w, " => {key: k, value: v})")
g.Fgenf(w, " => ({key: k, value: v}))")
case "fileArchive":
g.Fgenf(w, "new pulumi.asset.FileArchive(%.v)", expr.Args[0])
case "remoteArchive":
Expand Down
2 changes: 0 additions & 2 deletions pkg/codegen/testing/test/program_driver.go
Expand Up @@ -77,8 +77,6 @@ var PulumiPulumiProgramTests = []ProgramTest{
{
Directory: "aws-eks",
Description: "AWS EKS",
SkipCompile: codegen.NewStringSet("nodejs"),
// Blocked on nodejs: TODO[pulumi/pulumi#8067]
},
{
Directory: "aws-fargate",
Expand Down
Expand Up @@ -31,7 +31,7 @@ export = async () => {
// Subnets, one for each AZ in a region
const zones = await aws.getAvailabilityZones({});
const vpcSubnet: aws.ec2.Subnet[] = [];
for (const range of zones.names.map((k, v) => {key: k, value: v})) {
for (const range of zones.names.map((v, k) => ({key: k, value: v}))) {
vpcSubnet.push(new aws.ec2.Subnet(`vpcSubnet-${range.key}`, {
assignIpv6AddressOnCreation: false,
vpcId: eksVpc.id,
Expand All @@ -44,7 +44,7 @@ export = async () => {
}));
}
const rta: aws.ec2.RouteTableAssociation[] = [];
for (const range of zones.names.map((k, v) => {key: k, value: v})) {
for (const range of zones.names.map((v, k) => ({key: k, value: v}))) {
rta.push(new aws.ec2.RouteTableAssociation(`rta-${range.key}`, {
routeTableId: eksRouteTable.id,
subnetId: vpcSubnet[range.key].id,
Expand Down
Expand Up @@ -9,7 +9,7 @@ const siteBucket = new aws.s3.Bucket("siteBucket", {website: {
const siteDir = "www";
// For each file in the directory, create an S3 object stored in `siteBucket`
const files: aws.s3.BucketObject[] = [];
for (const range of fs.readDirSync(siteDir).map((k, v) => {key: k, value: v})) {
for (const range of fs.readDirSync(siteDir).map((v, k) => ({key: k, value: v}))) {
files.push(new aws.s3.BucketObject(`files-${range.key}`, {
bucket: siteBucket.id,
key: range.value,
Expand Down

0 comments on commit 35f8427

Please sign in to comment.