}/plugin.json file inside the package.
*
- * Keep in sync with pulumi/sdk/go/common/resource/plugin/plugin.go:51
- **/
+ * Keep in sync with pulumi/sdk/go/common/resource/plugin/plugin.go's PulumiPluginJSON.
+ */
public final class PulumiPlugin {
public final boolean resource;
@@ -25,20 +26,35 @@ public final class PulumiPlugin {
public final String version;
@Nullable
public final String server;
+ @Nullable
+ public final PulumiPluginParameterization parameterization;
/**
* Represents additional information about a package's associated Pulumi plugin.
*
- * @param resource Indicates whether the package has an associated resource plugin. Set to false indicates no plugin.
- * @param name Optional plugin name. If not set, the plugin name is derived from the package name.
- * @param version Optional plugin version. If not set, the version is derived from the package version (if possible).
- * @param server Optional plugin server. If not set, the default server is used when installing the plugin.
+ * @param resource
+ * Indicates whether the package has an associated resource plugin. Set to false indicates no plugin.
+ * @param name
+ * Optional plugin name. If not set, the plugin name is derived from the package name.
+ * @param version
+ * Optional plugin version. If not set, the version is derived from the package version (if possible).
+ * @param server
+ * Optional plugin server. If not set, the default server is used when installing the plugin.
+ * @param parameterization
+ * Optional parameterization information for the plugin.
*/
- public PulumiPlugin(boolean resource, @Nullable String name, @Nullable String version, @Nullable String server) {
+ public PulumiPlugin(
+ boolean resource,
+ @Nullable String name,
+ @Nullable String version,
+ @Nullable String server,
+ @Nullable PulumiPluginParameterization parameterization
+ ) {
this.resource = resource;
this.name = name;
this.version = version;
this.server = server;
+ this.parameterization = parameterization;
}
public static PulumiPlugin resolve(@Nullable PulumiPlugins.RawResource plugin, @Nullable PulumiPlugins.RawResource rawVersion) {
@@ -70,7 +86,11 @@ public static PulumiPlugin resolve(@Nullable PulumiPlugins.RawResource plugin, @
.flatMap(Map.Entry::getValue)
.map(pulumiPlugin -> pulumiPlugin.server)
.orElse(null);
- return new PulumiPlugin(resource, name, version, server);
+ var parameterization = maybePlugin
+ .flatMap(Map.Entry::getValue)
+ .map(pulumiPlugin -> pulumiPlugin.parameterization)
+ .orElse(null);
+ return new PulumiPlugin(resource, name, version, server, parameterization);
}
@Override
@@ -81,12 +101,13 @@ public boolean equals(Object o) {
return resource == that.resource
&& Objects.equals(name, that.name)
&& Objects.equals(version, that.version)
- && Objects.equals(server, that.server);
+ && Objects.equals(server, that.server)
+ && Objects.equals(parameterization, that.parameterization);
}
@Override
public int hashCode() {
- return Objects.hash(resource, name, version, server);
+ return Objects.hash(resource, name, version, server, parameterization);
}
@Override
@@ -96,6 +117,7 @@ public String toString() {
.add("name='" + name + "'")
.add("version='" + version + "'")
.add("server='" + server + "'")
+ .add("parameterization=" + parameterization)
.toString();
}
@@ -103,6 +125,18 @@ public String toString() {
@VisibleForTesting
static PulumiPlugin fromJson(String json) {
var gson = new Gson();
- return gson.fromJson(json, PulumiPlugin.class);
+
+ var plugin = gson.fromJson(json, PulumiPlugin.class);
+ if (plugin == null) {
+ return plugin;
+ }
+
+ var raw = gson.fromJson(json, JsonObject.class);
+ var parameterization = raw.has("parameterization")
+ ? gson.fromJson(raw.get("parameterization"), PulumiPluginParameterization.class)
+ : null;
+
+ plugin = new PulumiPlugin(plugin.resource, plugin.name, plugin.version, plugin.server, parameterization);
+ return plugin;
}
-}
+}
\ No newline at end of file
diff --git a/sdk/java/pulumi/src/main/java/com/pulumi/bootstrap/internal/PulumiPluginParameterization.java b/sdk/java/pulumi/src/main/java/com/pulumi/bootstrap/internal/PulumiPluginParameterization.java
new file mode 100644
index 00000000000..893c329358d
--- /dev/null
+++ b/sdk/java/pulumi/src/main/java/com/pulumi/bootstrap/internal/PulumiPluginParameterization.java
@@ -0,0 +1,57 @@
+package com.pulumi.bootstrap.internal;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.gson.Gson;
+
+import javax.annotation.Nullable;
+import java.util.Objects;
+import java.util.StringJoiner;
+
+/**
+ * Represents information about a parameterization for a Pulumi plugin.
+ *
+ * Keep in sync with pulumi/sdk/go/common/resource/plugin/plugin.go's PulumiParameterizationJSON.
+ */
+public final class PulumiPluginParameterization {
+
+ public final String name;
+ public final String version;
+ public final String value;
+
+ public PulumiPluginParameterization(String name, String version, String value) {
+ this.name = name;
+ this.version = version;
+ this.value = value;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ PulumiPluginParameterization that = (PulumiPluginParameterization) o;
+ return Objects.equals(name, that.name)
+ && Objects.equals(version, that.version)
+ && Objects.equals(value, that.value);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(name, version, value);
+ }
+
+ @Override
+ public String toString() {
+ return new StringJoiner(", ", PulumiPluginParameterization.class.getSimpleName() + "[", "]")
+ .add("name='" + name + "'")
+ .add("version='" + version + "'")
+ .add("value='" + value + "'")
+ .toString();
+ }
+
+ @Nullable
+ @VisibleForTesting
+ static PulumiPluginParameterization fromJson(String json) {
+ var gson = new Gson();
+ return gson.fromJson(json, PulumiPluginParameterization.class);
+ }
+}
\ No newline at end of file
diff --git a/sdk/java/pulumi/src/test/java/com/pulumi/bootstrap/internal/PulumiPluginTest.java b/sdk/java/pulumi/src/test/java/com/pulumi/bootstrap/internal/PulumiPluginTest.java
index 21e990ec455..bc38367af47 100644
--- a/sdk/java/pulumi/src/test/java/com/pulumi/bootstrap/internal/PulumiPluginTest.java
+++ b/sdk/java/pulumi/src/test/java/com/pulumi/bootstrap/internal/PulumiPluginTest.java
@@ -93,19 +93,19 @@ private static Stream testUnmarshalling() {
arguments("", null, ""),
arguments(
"{}",
- new PulumiPlugin(false, null, null, null),
+ new PulumiPlugin(false, null, null, null, null),
"{\"resource\":false}"),
arguments(
"{\n" +
" \"resource\":true\n" +
"}",
- new PulumiPlugin(true, null, null, null),
+ new PulumiPlugin(true, null, null, null, null),
"{\"resource\":true}"),
arguments("{\n" +
" \"resource\": true,\n" +
" \"name\": \"unittest\"\n" +
"}",
- new PulumiPlugin(true, "unittest", null, null),
+ new PulumiPlugin(true, "unittest", null, null, null),
"{\"resource\":true,\"name\":\"unittest\"}"),
arguments(
"{\n" +
@@ -113,7 +113,7 @@ private static Stream testUnmarshalling() {
" \"name\": \"unittest\",\n" +
" \"version\": \"1.1.1\"\n" +
"}",
- new PulumiPlugin(true, "unittest", "1.1.1", null),
+ new PulumiPlugin(true, "unittest", "1.1.1", null, null),
"{\"resource\":true,\"name\":\"unittest\",\"version\":\"1.1.1\"}"),
arguments(
"{\n" +
@@ -122,8 +122,22 @@ private static Stream testUnmarshalling() {
" \"version\": \"1.1.1\",\n" +
" \"server\": \"https://example.org\"\n" +
"}",
- new PulumiPlugin(true, "unittest", "1.1.1", "https://example.org"),
- "{\"resource\":true,\"name\":\"unittest\",\"version\":\"1.1.1\",\"server\":\"https://example.org\"}")
+ new PulumiPlugin(true, "unittest", "1.1.1", "https://example.org", null),
+ "{\"resource\":true,\"name\":\"unittest\",\"version\":\"1.1.1\",\"server\":\"https://example.org\"}"),
+ arguments(
+ "{\n" +
+ " \"resource\": true,\n" +
+ " \"name\": \"unittest\",\n" +
+ " \"version\": \"1.1.1\",\n" +
+ " \"parameterization\": {\n" +
+ " \"name\": \"parameterized\",\n" +
+ " \"version\": \"2.2.2\",\n" +
+ " \"value\": \"value\"\n" +
+ " }\n" +
+ "}",
+ new PulumiPlugin(true, "unittest", "1.1.1", null,
+ new PulumiPluginParameterization("parameterized", "2.2.2", "value")),
+ "{\"resource\":true,\"name\":\"unittest\",\"version\":\"1.1.1\",\"parameterization\":{\"name\":\"parameterized\",\"version\":\"2.2.2\",\"value\":\"value\"}}")
);
}
diff --git a/sdk/java/pulumi/src/test/java/com/pulumi/bootstrap/internal/PulumiPluginsTest.java b/sdk/java/pulumi/src/test/java/com/pulumi/bootstrap/internal/PulumiPluginsTest.java
index be9cc8c17d8..829959ae211 100644
--- a/sdk/java/pulumi/src/test/java/com/pulumi/bootstrap/internal/PulumiPluginsTest.java
+++ b/sdk/java/pulumi/src/test/java/com/pulumi/bootstrap/internal/PulumiPluginsTest.java
@@ -17,7 +17,7 @@ void testFromClasspath() {
var packages = PulumiPlugins.fromClasspath(PulumiPluginsTest.class);
assertThat(packages).hasSize(1).containsEntry(
// minimal example, it derives both name and version
- "com/pulumi/unittest", new PulumiPlugin(true, "unittest", "1.1.1", null)
+ "com/pulumi/unittest", new PulumiPlugin(true, "unittest", "1.1.1", null, null)
);
}
}
\ No newline at end of file