Skip to content

Commit

Permalink
[sdk/program-gen] Include explicit dependencies of invokes in their r…
Browse files Browse the repository at this point in the history
…esulting output (#1591)

Built on top of #1586

Fixes the SDK in invokes where explicit dependencies of output invokes
should be included in the resulting Output instance

Unskips `l2-invoke-options-depends-on` conformance test that asserts the
behaviour
  • Loading branch information
Zaid-Ajaj authored Jan 15, 2025
1 parent a3a2508 commit c74ed23
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
- Fix generation of untyped maps and array literals
- Implement `InvokeOptionsBuilder` and `InvokeOutputOptionsBuilder`
- Emit invoke options and invoke output options in generated programs
- Include explicit dependencies of invokes in their resulting output

### Bug Fixes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name: l2-invoke-options-depends-on
runtime: java
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.pulumi</groupId>
<artifactId>l2-invoke-options-depends-on</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<encoding>UTF-8</encoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.release>11</maven.compiler.release>
<mainClass>generated_program.App</mainClass>
<mainArgs/>
</properties>

<repositories>
<repository>
<id>repository-0</id>
<url>REPOSITORY</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>com.pulumi</groupId>
<artifactId>pulumi</artifactId>
<version>CORE.VERSION</version>
</dependency>
<dependency>
<groupId>com.pulumi</groupId>
<artifactId>simple-invoke</artifactId>
<version>10.0.0</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>${mainClass}</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>${mainClass}</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-my-jar-with-dependencies</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<mainClass>${mainClass}</mainClass>
<commandlineArgs>${mainArgs}</commandlineArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-wrapper-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<mavenVersion>3.8.5</mavenVersion>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.simpleinvoke.Provider;
import com.pulumi.simpleinvoke.StringResource;
import com.pulumi.simpleinvoke.StringResourceArgs;
import com.pulumi.simpleinvoke.SimpleinvokeFunctions;
import com.pulumi.simpleinvoke.inputs.MyInvokeArgs;
import com.pulumi.deployment.InvokeOutputOptions;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}

public static void stack(Context ctx) {
var explicitProvider = new Provider("explicitProvider");

var first = new StringResource("first", StringResourceArgs.builder()
.text("first hello")
.build());

final var data = SimpleinvokeFunctions.myInvoke(MyInvokeArgs.builder()
.value("hello")
.build(), (new InvokeOutputOptions.Builder())
.dependsOn(first)
.build());

var second = new StringResource("second", StringResourceArgs.builder()
.text(data.applyValue(_data -> _data.result()))
.build());

ctx.export("hello", data.applyValue(_data -> _data.result()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ public <T> Output<T> invoke(String token, TypeShape<T> targetType, InvokeArgs ar
} else {
return packageRefFuture
.thenCompose(packageRefString -> this.invokeRawAsync(token, serializedArgs, options, packageRefString))
.thenApply(result -> parseInvokeResponse(token, targetType, result));
.thenApply(result -> parseInvokeResponse(token, targetType, result).withDependencies(options.getDependsOn()));
}
});
}));
Expand Down

0 comments on commit c74ed23

Please sign in to comment.