From fb7879aaf49f4989169112fa7c86b7f00b758009 Mon Sep 17 00:00:00 2001 From: Fraser Waters Date: Fri, 12 Dec 2025 13:00:15 +0000 Subject: [PATCH] Add Stash resource --- .changes/unreleased/Improvements-1957.yaml | 6 ++ pkg/cmd/pulumi-language-java/language_test.go | 1 - .../projects/l1-builtin-stash/0/Pulumi.yaml | 2 + .../projects/l1-builtin-stash/0/pom.xml | 95 +++++++++++++++++++ .../src/main/java/generated_program/App.java | 33 +++++++ .../main/java/com/pulumi/resources/Stash.java | 75 +++++++++++++++ .../java/com/pulumi/resources/StashArgs.java | 74 +++++++++++++++ 7 files changed, 285 insertions(+), 1 deletion(-) create mode 100644 .changes/unreleased/Improvements-1957.yaml create mode 100644 pkg/cmd/pulumi-language-java/testdata/projects/l1-builtin-stash/0/Pulumi.yaml create mode 100644 pkg/cmd/pulumi-language-java/testdata/projects/l1-builtin-stash/0/pom.xml create mode 100644 pkg/cmd/pulumi-language-java/testdata/projects/l1-builtin-stash/0/src/main/java/generated_program/App.java create mode 100644 sdk/java/pulumi/src/main/java/com/pulumi/resources/Stash.java create mode 100644 sdk/java/pulumi/src/main/java/com/pulumi/resources/StashArgs.java diff --git a/.changes/unreleased/Improvements-1957.yaml b/.changes/unreleased/Improvements-1957.yaml new file mode 100644 index 00000000000..3862435451c --- /dev/null +++ b/.changes/unreleased/Improvements-1957.yaml @@ -0,0 +1,6 @@ +component: sdk +kind: Improvements +body: Add support for the builtin Stash resource +time: 2025-12-12T13:24:29.609174Z +custom: + PR: "1957" diff --git a/pkg/cmd/pulumi-language-java/language_test.go b/pkg/cmd/pulumi-language-java/language_test.go index 27c8f2fb9ab..ff2bfc28433 100644 --- a/pkg/cmd/pulumi-language-java/language_test.go +++ b/pkg/cmd/pulumi-language-java/language_test.go @@ -186,7 +186,6 @@ var expectedFailures = map[string]string{ "l2-invoke-scalar": "exception at runtime", "l3-component-simple": "compilation error", "l1-builtin-cwd": "test failing", - "l1-builtin-stash": "test failing", "l1-stack-reference": "test failing", "l2-invoke-options": "test failing", "l1-output-map": "test failing", diff --git a/pkg/cmd/pulumi-language-java/testdata/projects/l1-builtin-stash/0/Pulumi.yaml b/pkg/cmd/pulumi-language-java/testdata/projects/l1-builtin-stash/0/Pulumi.yaml new file mode 100644 index 00000000000..f7540a66b96 --- /dev/null +++ b/pkg/cmd/pulumi-language-java/testdata/projects/l1-builtin-stash/0/Pulumi.yaml @@ -0,0 +1,2 @@ +name: l1-builtin-stash +runtime: java diff --git a/pkg/cmd/pulumi-language-java/testdata/projects/l1-builtin-stash/0/pom.xml b/pkg/cmd/pulumi-language-java/testdata/projects/l1-builtin-stash/0/pom.xml new file mode 100644 index 00000000000..005b4f0124b --- /dev/null +++ b/pkg/cmd/pulumi-language-java/testdata/projects/l1-builtin-stash/0/pom.xml @@ -0,0 +1,95 @@ + + + 4.0.0 + + com.pulumi + l1-builtin-stash + 1.0-SNAPSHOT + + + UTF-8 + 11 + 11 + 11 + generated_program.App + + + + + + repository-0 + REPOSITORY + + + + + + com.pulumi + pulumi + CORE.VERSION + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.2 + + + + true + ${mainClass} + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.4.2 + + + + true + ${mainClass} + + + + jar-with-dependencies + + + + + make-my-jar-with-dependencies + package + + single + + + + + + org.codehaus.mojo + exec-maven-plugin + 3.1.0 + + ${mainClass} + ${mainArgs} + + + + org.apache.maven.plugins + maven-wrapper-plugin + 3.1.1 + + 3.8.5 + + + + + \ No newline at end of file diff --git a/pkg/cmd/pulumi-language-java/testdata/projects/l1-builtin-stash/0/src/main/java/generated_program/App.java b/pkg/cmd/pulumi-language-java/testdata/projects/l1-builtin-stash/0/src/main/java/generated_program/App.java new file mode 100644 index 00000000000..6e8f542035a --- /dev/null +++ b/pkg/cmd/pulumi-language-java/testdata/projects/l1-builtin-stash/0/src/main/java/generated_program/App.java @@ -0,0 +1,33 @@ +package generated_program; + +import com.pulumi.Context; +import com.pulumi.Pulumi; +import com.pulumi.core.Output; +import com.pulumi.pulumi.Stash; +import com.pulumi.pulumi.StashArgs; +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 myStash = new Stash("myStash", StashArgs.builder() + .input(Map.ofEntries( + Map.entry("key", + "value", + "s"), + Map.entry("", false) + )) + .build()); + + ctx.export("stashInput", myStash.input()); + ctx.export("stashOutput", myStash.output()); + } +} diff --git a/sdk/java/pulumi/src/main/java/com/pulumi/resources/Stash.java b/sdk/java/pulumi/src/main/java/com/pulumi/resources/Stash.java new file mode 100644 index 00000000000..a612c632a79 --- /dev/null +++ b/sdk/java/pulumi/src/main/java/com/pulumi/resources/Stash.java @@ -0,0 +1,75 @@ +package com.pulumi.resources; + +import com.google.common.annotations.VisibleForTesting; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.pulumi.core.Output; +import com.pulumi.core.annotations.Export; +import com.pulumi.core.internal.Internal; +import com.pulumi.core.internal.Maps; +import com.pulumi.core.internal.OutputData; +import com.pulumi.core.internal.annotations.InternalUse; +import com.pulumi.exceptions.RunException; + +import javax.annotation.Nullable; +import javax.annotation.ParametersAreNonnullByDefault; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CompletableFuture; + +/** + * Stash stores an arbitrary value in the state. + */ +public class Stash extends CustomResource { + + @Export(name = "output", refs = {Object.class}) + private Output output; + + @Export(name = "input", refs = {Object.class}) + private Output input; + + /** + * Create a {@link Stash} resource with the given unique name, arguments. + * + * @param name The unique name of the stash resource. + * @param args The arguments to use to populate this resource's properties. + * @see Stash#Stash(String, StashArgs, CustomResourceOptions) + */ + public Stash(String name, StashArgs args) { + this(name, args, CustomResourceOptions.Empty); + } + + /** + * Create a {@link Stash} resource with the given unique name, arguments, and options. + * + * @param name The unique name of the stash resource. + * @param args The arguments to use to populate this resource's properties. + * @param options A bag of options that control this resource's behavior. + */ + public Stash(String name, @Nullable StashArgs args, @Nullable CustomResourceOptions options) { + super( + "pulumi:index:Stash", + name, + args, + options + ); + } + + /** + * The value saved in the state for the stash. + * + * @return the output value + */ + public Output output() { + return output; + } + + /** + * The most recent value passed to the stash resource. + * + * @return the input value + */ + public Output input() { + return input; + } +} \ No newline at end of file diff --git a/sdk/java/pulumi/src/main/java/com/pulumi/resources/StashArgs.java b/sdk/java/pulumi/src/main/java/com/pulumi/resources/StashArgs.java new file mode 100644 index 00000000000..df11d57d112 --- /dev/null +++ b/sdk/java/pulumi/src/main/java/com/pulumi/resources/StashArgs.java @@ -0,0 +1,74 @@ +package com.pulumi.resources; + +import com.pulumi.core.Output; +import com.pulumi.core.annotations.Import; + +import javax.annotation.Nullable; + +/** + * The set of arguments for constructing a {@link Stash} resource. + */ +public final class StashArgs extends ResourceArgs { + + /** + * An empty {@link StashArgs} instance. + */ + public static final StashArgs Empty = StashArgs.builder().build(); + + @Import(name = "output", required = true) + @Nullable + private final Output input; + + public StashArgs(@Nullable Output input) { + this.input = input; + } + + /** + * The value to store in the stash resource. + */ + public Output input() { + return input; + } + + /** + * @return a {@link Builder} instance + */ + public static Builder builder() { + return new Builder(); + } + + /** + * The builder for {@link StackReferenceArgs}. + */ + public static final class Builder { + @Nullable + private Output input; + + /** + * @param input the value to store in the stash resource. + * @return the {@link Builder} + * @see StashArgs#input() + */ + public Builder input(@Nullable Output input) { + this.input = input; + return this; + } + + /** + * @param input the value to store in the stash resource. + * @return the {@link Builder} + * @see StashArgs#input() + */ + public Builder input(Object input) { + this.input = Output.of(input); + return this; + } + + /** + * @return a {@link StashArgs} instance created from this {@link Builder} + */ + public StashArgs build() { + return new StashArgs(this.input); + } + } +} \ No newline at end of file