-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement
GetRequiredPackages
for Java
As part of a Pulumi deployment, the Pulumi engine will ask the language host running the program for the set of plugins required to run that program successfully by making a `GetRequiredPlugins` gRPC call. For instance, if one has a TypeScript program whose `index.ts` `import`s `@pulumi/aws`, the NodeJS language host will find the `@pulumi/aws` package and report that the `aws` resource plugin is required. This enables features such as pre-emptively downloading a plugin ahead of time, as opposed to waiting for the first resource registration against that plugin. With the introduction of parameterized providers, `GetRequiredPlugins` falls a little short -- parameterization means that it is no longer necessarily the case that a package named `x` is provided by a plugin of the same name. For instance, with a dynamically bridged Terraform provider X, the provider name will be X, but the plugin name will be e.g. `pulumi-terraform-provider`. In pulumi/pulumi#17894, `GetRequiredPackages` was added to the language host interface to provide the additional context of a plugin's parameterization, and is now used if present instead of `GetRequiredPlugins`. This change implements `GetRequiredPackages` for Java as follows: * Presently, `GetRequiredPlugins` is implemented by running a small Java program (located in the internal `bootstrap` package of the core SDK) that walks its class path looking for `pulumi-plugin.json` files. This code is extended to parse `parameterization` blocks from those JSON files, as we do in other languages using this mechanism. * When we generate SDKs, we generate Gradle build files which generate `pulumi-plugin.json` files as part of the build process. We extend the `build.gradle` template used when generating SDK build files so that it emits `parameterization` blocks appropriately. As part of this, we also clean up the emission of package names and versions. * We now have enough to run and pass the `l2-parameterized-resource` conformance test, which in theory confirms that all of this works, so we include that as part of this work. * We remove the now-deprecated `GetRequiredPlugins` implementation. Fixes #1510
- Loading branch information
Showing
23 changed files
with
888 additions
and
75 deletions.
There are no files selected for viewing
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
2 changes: 2 additions & 0 deletions
2
pkg/cmd/pulumi-language-java/testdata/projects/l2-parameterized-resource/Pulumi.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,2 @@ | ||
name: l2-parameterized-resource | ||
runtime: java |
99 changes: 99 additions & 0 deletions
99
pkg/cmd/pulumi-language-java/testdata/projects/l2-parameterized-resource/pom.xml
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,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-parameterized-resource</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>subpackage</artifactId> | ||
<version>2.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> |
25 changes: 25 additions & 0 deletions
25
...java/testdata/projects/l2-parameterized-resource/src/main/java/generated_program/App.java
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,25 @@ | ||
package generated_program; | ||
|
||
import com.pulumi.Context; | ||
import com.pulumi.Pulumi; | ||
import com.pulumi.core.Output; | ||
import com.pulumi.subpackage.HelloWorld; | ||
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) { | ||
// The resource name is based on the parameter value | ||
var example = new HelloWorld("example"); | ||
|
||
ctx.export("parameterValue", example.parameterValue()); | ||
} | ||
} |
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
1 change: 1 addition & 0 deletions
1
pkg/cmd/pulumi-language-java/testdata/sdks/subpackage-2.0.0/README.md
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 @@ | ||
|
Oops, something went wrong.