Skip to content

Commit

Permalink
regen examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Zaid-Ajaj committed Jan 11, 2025
1 parent b634a0b commit fcfa371
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions pkg/codegen/java/gen_program.go
Original file line number Diff line number Diff line change
Expand Up @@ -1274,9 +1274,9 @@ func (g *generator) genLocalVariable(w io.Writer, localVariable *pcl.LocalVariab
g.genIndent(w)
if isInvokeCall {
g.functionInvokes[variableName] = functionSchema
// TODO: lowerExpression isn't what we expect: function call should extract outputs into .apply(...) calls
// functionDefinitionWithApplies := g.lowerExpression(functionDefinition, localVariable.Definition.Value.Type())
g.Fgenf(w, "final var %s = %v;\n", variableName, localVariable.Definition.Value)
invokeCall := localVariable.Definition.Value.(*model.FunctionCallExpression)
functionDefinitionWithApplies := g.lowerExpression(invokeCall, invokeCall.Signature.ReturnType)
g.Fgenf(w, "final var %s = %v;\n", variableName, functionDefinitionWithApplies)
} else {
variable := localVariable.Definition.Value
g.Fgenf(w, "final var %s = %v;\n", variableName, g.lowerExpression(variable, variable.Type()))
Expand Down
2 changes: 1 addition & 1 deletion pkg/codegen/java/gen_program_expressions.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (g *generator) GenAnonymousFunctionExpression(w io.Writer, expr *model.Anon
return x, nil
}

_, diags := model.VisitExpression(expr.Body, modifier, nil)
_, diags := model.VisitExpression(expr.Body, model.IdentityVisitor, modifier)
contract.Assertf(len(diags) == 0, "unexpected diagnostics when rewriting parameter name")
g.Fgenf(w, "%s", modifiedParamName)
g.Fgenf(w, " -> %v", expr.Body)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ public static void stack(Context ctx) {
.build());

final var subnets = Ec2Functions.getSubnetIds(GetSubnetIdsArgs.builder()
.vpcId(vpc.applyValue(getVpcResult -> getVpcResult.id()))
.vpcId(vpc.id())
.build());

// Create a security group that permits HTTP ingress and unrestricted egress.
var webSecurityGroup = new SecurityGroup("webSecurityGroup", SecurityGroupArgs.builder()
.vpcId(vpc.applyValue(getVpcResult -> getVpcResult.id()))
.vpcId(vpc.id())
.egress(SecurityGroupEgressArgs.builder()
.protocol("-1")
.fromPort(0)
Expand Down Expand Up @@ -95,15 +95,15 @@ public static void stack(Context ctx) {

// Create a load balancer to listen for HTTP traffic on port 80.
var webLoadBalancer = new LoadBalancer("webLoadBalancer", LoadBalancerArgs.builder()
.subnets(subnets.applyValue(getSubnetIdsResult -> getSubnetIdsResult.ids()))
.subnets(subnets.ids())
.securityGroups(webSecurityGroup.id())
.build());

var webTargetGroup = new TargetGroup("webTargetGroup", TargetGroupArgs.builder()
.port(80)
.protocol("HTTP")
.targetType("ip")
.vpcId(vpc.applyValue(getVpcResult -> getVpcResult.id()))
.vpcId(vpc.id())
.build());

var webListener = new Listener("webListener", ListenerArgs.builder()
Expand Down Expand Up @@ -142,7 +142,7 @@ public static void stack(Context ctx) {
.taskDefinition(appTask.arn())
.networkConfiguration(ServiceNetworkConfigurationArgs.builder()
.assignPublicIp(true)
.subnets(subnets.applyValue(getSubnetIdsResult -> getSubnetIdsResult.ids()))
.subnets(subnets.ids())
.securityGroups(webSecurityGroup.id())
.build())
.loadBalancers(ServiceLoadBalancerArgs.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import com.pulumi.aws.s3.BucketObjectArgs;
import com.pulumi.aws.s3.BucketPolicy;
import com.pulumi.aws.s3.BucketPolicyArgs;
import com.pulumi.asset.FileArchive;
import static com.pulumi.codegen.internal.Files.readDir;
import static com.pulumi.codegen.internal.Serialization.*;
import com.pulumi.codegen.internal.KeyedValue;
import static com.pulumi.codegen.internal.Files.readDir;
import com.pulumi.asset.FileAsset;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
Expand Down Expand Up @@ -50,14 +50,14 @@ public static void stack(Context ctx) {
// Set the access policy for the bucket so all objects are readable
var bucketPolicy = new BucketPolicy("bucketPolicy", BucketPolicyArgs.builder()
.bucket(siteBucket.id())
.policy(siteBucket.id().applyValue(id -> serializeJson(
.policy(siteBucket.id().applyValue(_id -> serializeJson(
jsonObject(
jsonProperty("Version", "2012-10-17"),
jsonProperty("Statement", jsonArray(jsonObject(
jsonProperty("Effect", "Allow"),
jsonProperty("Principal", "*"),
jsonProperty("Action", jsonArray("s3:GetObject")),
jsonProperty("Resource", jsonArray(String.format("arn:aws:s3:::%s/*", id)))
jsonProperty("Resource", jsonArray(String.format("arn:aws:s3:::%s/*", _id)))
)))
))))
.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ public static void stack(Context ctx) {
.source(Files.readString(Paths.get("./index.html")))
.build());

ctx.export("targetBucket", bucket.loggings().applyValue(loggings -> loggings[0].targetBucket()));
ctx.export("targetBucket", bucket.loggings().applyValue(_loggings -> _loggings[0].targetBucket()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static void stack(Context ctx) {
.tags(Map.of("Name", "web-server-www"))
.instanceType("t2.micro")
.securityGroups(securityGroup.name())
.ami(ami.applyValue(getAmiResult -> getAmiResult.id()))
.ami(ami.id())
.userData("""
#!/bin/bash
echo "Hello, World!" > index.html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static void stack(Context ctx) {
.name(resourceGroupNameParam)
.build());

final var locationParam = config.get("locationParam").orElse(resourceGroupVar.applyValue(getResourceGroupResult -> getResourceGroupResult.location()));
final var locationParam = config.get("locationParam").orElse(resourceGroupVar.location());
final var storageAccountTierParam = config.get("storageAccountTierParam").orElse("Standard");
final var storageAccountTypeReplicationParam = config.get("storageAccountTypeReplicationParam").orElse("LRS");
var storageAccountResource = new Account("storageAccountResource", AccountArgs.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static void stack(Context ctx) {
.egress(false)
.protocol("tcp")
.ruleAction("allow")
.cidrBlock(privateS3PrefixList.applyValue(getPrefixListResult -> getPrefixListResult).applyValue(privateS3PrefixList -> privateS3PrefixList.applyValue(getPrefixListResult -> getPrefixListResult.cidrBlocks()[0])))
.cidrBlock(privateS3PrefixList.applyValue(_privateS3PrefixList -> _privateS3PrefixList.cidrBlocks()[0]))
.fromPort(443)
.toPort(443)
.build());
Expand Down

0 comments on commit fcfa371

Please sign in to comment.