diff --git a/provider/cmd/pulumi-resource-command/schema.json b/provider/cmd/pulumi-resource-command/schema.json index 264f1f4c..263c8534 100644 --- a/provider/cmd/pulumi-resource-command/schema.json +++ b/provider/cmd/pulumi-resource-command/schema.json @@ -368,6 +368,11 @@ "command:remote:Command": { "description": "A command to run on a remote host.\nThe connection is established via ssh.", "properties": { + "addPreviousOutputInEnv": { + "type": "boolean", + "description": "If the previous command's stdout and stderr (as generated by the prior create/update) is\ninjected into the environment of the next run as PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR.\nDefaults to true.", + "default": true + }, "connection": { "$ref": "#/types/command:remote:Connection", "description": "The parameters with which to connect to the remote host.", @@ -424,6 +429,11 @@ "stdout" ], "inputProperties": { + "addPreviousOutputInEnv": { + "type": "boolean", + "description": "If the previous command's stdout and stderr (as generated by the prior create/update) is\ninjected into the environment of the next run as PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR.\nDefaults to true.", + "default": true + }, "connection": { "$ref": "#/types/command:remote:Connection", "description": "The parameters with which to connect to the remote host.", diff --git a/provider/pkg/provider/remote/command.go b/provider/pkg/provider/remote/command.go index c162a510..833136e8 100644 --- a/provider/pkg/provider/remote/command.go +++ b/provider/pkg/provider/remote/command.go @@ -37,10 +37,11 @@ type CommandInputs struct { // pulumi:"optional" specifies that a field is optional. This must be a pointer. // provider:"replaceOnChanges" specifies that the resource will be replaced if the field changes. // provider:"secret" specifies that a field should be marked secret. - Stdin *string `pulumi:"stdin,optional"` - Logging *Logging `pulumi:"logging,optional"` - Connection *Connection `pulumi:"connection" provider:"secret"` - Environment map[string]string `pulumi:"environment,optional"` + Stdin *string `pulumi:"stdin,optional"` + Logging *Logging `pulumi:"logging,optional"` + Connection *Connection `pulumi:"connection" provider:"secret"` + Environment map[string]string `pulumi:"environment,optional"` + AddPreviousOutputInEnv *bool `pulumi:"addPreviousOutputInEnv,optional"` } // Implementing Annotate lets you provide descriptions and default values for arguments and they will @@ -55,6 +56,11 @@ outputs as secret via 'additionalSecretOutputs'. Defaults to logging both stdout Note that this only works if the SSH server is configured to accept these variables via AcceptEnv. Alternatively, if a Bash-like shell runs the command on the remote host, you could prefix the command itself with the variables in the form 'VAR=value command'.`) + a.Describe(&c.AddPreviousOutputInEnv, + `If the previous command's stdout and stderr (as generated by the prior create/update) is +injected into the environment of the next run as PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR. +Defaults to true.`) + a.SetDefault(&c.AddPreviousOutputInEnv, true) } // The properties for a remote Command resource. diff --git a/provider/pkg/provider/remote/commandOutputs.go b/provider/pkg/provider/remote/commandOutputs.go index 0c8723a7..445846e3 100644 --- a/provider/pkg/provider/remote/commandOutputs.go +++ b/provider/pkg/provider/remote/commandOutputs.go @@ -48,23 +48,25 @@ func (c *CommandOutputs) run(ctx context.Context, cmd string, logging *Logging) } } - // Set remote Stdout and Stderr environment variables optimistically, but log and continue if they fail. - if c.Stdout != "" { - err := session.Setenv(util.PULUMI_COMMAND_STDOUT, c.Stdout) - if err != nil { - // Set remote Stdout var optimistically, but warn and continue on failure. - // - //nolint:errcheck - logAndWrapSetenvErr(diag.Warning, util.PULUMI_COMMAND_STDOUT, ctx, err) + if c.AddPreviousOutputInEnv == nil || *c.AddPreviousOutputInEnv { + // Set remote Stdout and Stderr environment variables optimistically, but log and continue if they fail. + if c.Stdout != "" { + err := session.Setenv(util.PULUMI_COMMAND_STDOUT, c.Stdout) + if err != nil { + // Set remote Stdout var optimistically, but warn and continue on failure. + // + //nolint:errcheck + logAndWrapSetenvErr(diag.Warning, util.PULUMI_COMMAND_STDOUT, ctx, err) + } } - } - if c.Stderr != "" { - err := session.Setenv(util.PULUMI_COMMAND_STDERR, c.Stderr) - if err != nil { - // Set remote STDERR var optimistically, but warn and continue on failure. - // - //nolint:errcheck - logAndWrapSetenvErr(diag.Warning, util.PULUMI_COMMAND_STDERR, ctx, err) + if c.Stderr != "" { + err := session.Setenv(util.PULUMI_COMMAND_STDERR, c.Stderr) + if err != nil { + // Set remote STDERR var optimistically, but warn and continue on failure. + // + //nolint:errcheck + logAndWrapSetenvErr(diag.Warning, util.PULUMI_COMMAND_STDERR, ctx, err) + } } } diff --git a/provider/pkg/provider/util/testutil/test_ssh_server.go b/provider/pkg/provider/util/testutil/test_ssh_server.go new file mode 100644 index 00000000..99c04462 --- /dev/null +++ b/provider/pkg/provider/util/testutil/test_ssh_server.go @@ -0,0 +1,44 @@ +package testutil + +import ( + "fmt" + "net" + "strconv" + "strings" + "testing" + + "github.com/gliderlabs/ssh" + "github.com/stretchr/testify/require" +) + +type TestSshServer struct { + Host string + Port int64 +} + +// NewTestSshServer creates a new in-process SSH server with the specified handler. +// The server is bound to an arbitrary free port, and automatically closed +// during test cleanup. +func NewTestSshServer(t *testing.T, handler ssh.Handler) TestSshServer { + const host = "127.0.0.1" + + listener, err := net.Listen("tcp", fmt.Sprintf("%s:%d", host, 0)) + require.NoErrorf(t, err, "net.Listen()") + + port, err := strconv.ParseInt(strings.Split(listener.Addr().String(), ":")[1], 10, 64) + require.NoErrorf(t, err, "parse address %s allocated port number as int", listener.Addr()) + + server := ssh.Server{Handler: handler} + go func() { + // "Serve always returns a non-nil error." + _ = server.Serve(listener) + }() + t.Cleanup(func() { + _ = server.Close() + }) + + return TestSshServer{ + Host: host, + Port: port, + } +} diff --git a/provider/tests/go.mod b/provider/tests/go.mod index 410c92e2..2de447f0 100644 --- a/provider/tests/go.mod +++ b/provider/tests/go.mod @@ -6,6 +6,7 @@ replace github.com/pulumi/pulumi-command/provider => ../ require ( github.com/blang/semver v3.5.1+incompatible + github.com/gliderlabs/ssh v0.3.7 github.com/pulumi/pulumi-command/provider v0.0.0-00010101000000-000000000000 github.com/pulumi/pulumi-go-provider v0.17.0 github.com/pulumi/pulumi/sdk/v3 v3.117.0 @@ -18,6 +19,7 @@ require ( github.com/ProtonMail/go-crypto v1.0.0 // indirect github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect github.com/agext/levenshtein v1.2.3 // indirect + github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect github.com/atotto/clipboard v0.1.4 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect diff --git a/provider/tests/provider_test.go b/provider/tests/provider_test.go index 2f02c298..add27368 100644 --- a/provider/tests/provider_test.go +++ b/provider/tests/provider_test.go @@ -2,6 +2,8 @@ package tests import ( "fmt" + "github.com/gliderlabs/ssh" + "strings" "testing" "github.com/blang/semver" @@ -13,6 +15,7 @@ import ( "github.com/stretchr/testify/require" command "github.com/pulumi/pulumi-command/provider/pkg/provider" + "github.com/pulumi/pulumi-command/provider/pkg/provider/util/testutil" "github.com/pulumi/pulumi-command/provider/pkg/version" ) @@ -223,6 +226,104 @@ func TestRemoteCommand(t *testing.T) { }) } +func TestRemoteCommandStdoutStderrFlag(t *testing.T) { + // Start a local SSH server that writes the PULUMI_COMMAND_STDOUT environment variable + // on the format "PULUMI_COMMAND_STDOUT=" to the client using stdout. + const ( + createCommand = "arbitrary create command" + ) + + sshServer := testutil.NewTestSshServer(t, func(session ssh.Session) { + // Find the PULUMI_COMMAND_STDOUT environment variable + var envVar string + for _, v := range session.Environ() { + if strings.HasPrefix(v, "PULUMI_COMMAND_STDOUT=") { + envVar = v + break + } + } + + response := fmt.Sprintf("Response{%s}", envVar) + _, err := session.Write([]byte(response)) + require.NoErrorf(t, err, "session.Write(%s)", response) + }) + + cmd := provider() + urn := urn("remote", "Command", "dial") + + // Run a create against an in-memory provider, assert it succeeded, and return the created property map. + connection := resource.NewObjectProperty(resource.PropertyMap{ + "host": resource.NewStringProperty(sshServer.Host), + "port": resource.NewNumberProperty(float64(sshServer.Port)), + "user": resource.NewStringProperty("arbitrary-user"), // unused but prevents nil panic + "perDialTimeout": resource.NewNumberProperty(1), // unused but prevents nil panic + }) + + // The state that we expect a non-preview create to return. + // + // We use this as the final expect for create and the old state during update. + initialState := resource.PropertyMap{ + "connection": connection, + "create": resource.PropertyValue{V: createCommand}, + "stderr": resource.PropertyValue{V: ""}, + "stdout": resource.PropertyValue{V: "Response{}"}, + "addPreviousOutputInEnv": resource.NewBoolProperty(true), + } + + t.Run("create", func(t *testing.T) { + createResponse, err := cmd.Create(p.CreateRequest{ + Urn: urn, + Properties: resource.PropertyMap{ + "connection": connection, + "create": resource.NewStringProperty(createCommand), + "addPreviousOutputInEnv": resource.NewBoolProperty(true), + }, + }) + require.NoError(t, err) + require.Equal(t, initialState, createResponse.Properties) + }) + + // Run an update against an in-memory provider, assert it succeeded, and return + // the new property map. + update := func(addPreviousOutputInEnv bool) resource.PropertyMap { + resp, err := cmd.Update(p.UpdateRequest{ + ID: "echo1234", + Urn: urn, + Olds: initialState.Copy(), + News: resource.PropertyMap{ + "connection": connection, + "create": resource.NewStringProperty(createCommand), + "addPreviousOutputInEnv": resource.NewBoolProperty(addPreviousOutputInEnv), + }, + }) + require.NoError(t, err) + return resp.Properties + } + + t.Run("update-actual-with-std", func(t *testing.T) { + assert.Equal(t, resource.PropertyMap{ + "connection": connection, + "create": resource.PropertyValue{V: createCommand}, + "stderr": resource.PropertyValue{V: ""}, + // Running with addPreviousOutputInEnv=true sets the environment variable: + "stdout": resource.PropertyValue{V: "Response{PULUMI_COMMAND_STDOUT=Response{}}"}, + "addPreviousOutputInEnv": resource.PropertyValue{V: true}, + }, update(true)) + }) + + t.Run("update-actual-without-std", func(t *testing.T) { + assert.Equal(t, resource.PropertyMap{ + "connection": connection, + "create": resource.PropertyValue{V: createCommand}, + "stderr": resource.PropertyValue{V: ""}, + // Running without addPreviousOutputInEnv does not set the environment variable: + "stdout": resource.PropertyValue{V: "Response{}"}, + "addPreviousOutputInEnv": resource.PropertyValue{V: false}, + }, update(false)) + }) + +} + // Ensure that we correctly apply defaults to `connection.port`. // // User issue is https://github.com/pulumi/pulumi-command/issues/248. @@ -251,6 +352,7 @@ func TestRegress248(t *testing.T) { "dialErrorLimit": pNumber(10), "perDialTimeout": pNumber(15), }), + "addPreviousOutputInEnv": resource.NewBoolProperty(true), }, resp.Inputs) } diff --git a/sdk/dotnet/Remote/Command.cs b/sdk/dotnet/Remote/Command.cs index 8d01769e..fb0dc7b6 100644 --- a/sdk/dotnet/Remote/Command.cs +++ b/sdk/dotnet/Remote/Command.cs @@ -16,6 +16,14 @@ namespace Pulumi.Command.Remote [CommandResourceType("command:remote:Command")] public partial class Command : global::Pulumi.CustomResource { + /// + /// If the previous command's stdout and stderr (as generated by the prior create/update) is + /// injected into the environment of the next run as PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR. + /// Defaults to true. + /// + [Output("addPreviousOutputInEnv")] + public Output AddPreviousOutputInEnv { get; private set; } = null!; + /// /// The parameters with which to connect to the remote host. /// @@ -139,6 +147,14 @@ public static Command Get(string name, Input id, CustomResourceOptions? public sealed class CommandArgs : global::Pulumi.ResourceArgs { + /// + /// If the previous command's stdout and stderr (as generated by the prior create/update) is + /// injected into the environment of the next run as PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR. + /// Defaults to true. + /// + [Input("addPreviousOutputInEnv")] + public Input? AddPreviousOutputInEnv { get; set; } + [Input("connection", required: true)] private Input? _connection; @@ -221,6 +237,7 @@ public InputList Triggers public CommandArgs() { + AddPreviousOutputInEnv = true; } public static new CommandArgs Empty => new CommandArgs(); } diff --git a/sdk/go/command/remote/command.go b/sdk/go/command/remote/command.go index 19160d2e..435e9d4b 100644 --- a/sdk/go/command/remote/command.go +++ b/sdk/go/command/remote/command.go @@ -17,6 +17,10 @@ import ( type Command struct { pulumi.CustomResourceState + // If the previous command's stdout and stderr (as generated by the prior create/update) is + // injected into the environment of the next run as PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR. + // Defaults to true. + AddPreviousOutputInEnv pulumi.BoolPtrOutput `pulumi:"addPreviousOutputInEnv"` // The parameters with which to connect to the remote host. Connection ConnectionOutput `pulumi:"connection"` // The command to run on create. @@ -59,6 +63,9 @@ func NewCommand(ctx *pulumi.Context, if args.Connection == nil { return nil, errors.New("invalid value for required argument 'Connection'") } + if args.AddPreviousOutputInEnv == nil { + args.AddPreviousOutputInEnv = pulumi.BoolPtr(true) + } args.Connection = args.Connection.ToConnectionOutput().ApplyT(func(v Connection) Connection { return *v.Defaults() }).(ConnectionOutput) if args.Connection != nil { args.Connection = pulumi.ToSecret(args.Connection).(ConnectionInput) @@ -104,6 +111,10 @@ func (CommandState) ElementType() reflect.Type { } type commandArgs struct { + // If the previous command's stdout and stderr (as generated by the prior create/update) is + // injected into the environment of the next run as PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR. + // Defaults to true. + AddPreviousOutputInEnv *bool `pulumi:"addPreviousOutputInEnv"` // The parameters with which to connect to the remote host. Connection Connection `pulumi:"connection"` // The command to run on create. @@ -134,6 +145,10 @@ type commandArgs struct { // The set of arguments for constructing a Command resource. type CommandArgs struct { + // If the previous command's stdout and stderr (as generated by the prior create/update) is + // injected into the environment of the next run as PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR. + // Defaults to true. + AddPreviousOutputInEnv pulumi.BoolPtrInput // The parameters with which to connect to the remote host. Connection ConnectionInput // The command to run on create. @@ -249,6 +264,13 @@ func (o CommandOutput) ToCommandOutputWithContext(ctx context.Context) CommandOu return o } +// If the previous command's stdout and stderr (as generated by the prior create/update) is +// injected into the environment of the next run as PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR. +// Defaults to true. +func (o CommandOutput) AddPreviousOutputInEnv() pulumi.BoolPtrOutput { + return o.ApplyT(func(v *Command) pulumi.BoolPtrOutput { return v.AddPreviousOutputInEnv }).(pulumi.BoolPtrOutput) +} + // The parameters with which to connect to the remote host. func (o CommandOutput) Connection() ConnectionOutput { return o.ApplyT(func(v *Command) ConnectionOutput { return v.Connection }).(ConnectionOutput) diff --git a/sdk/java/src/main/java/com/pulumi/command/remote/Command.java b/sdk/java/src/main/java/com/pulumi/command/remote/Command.java index a8b0366c..1799da63 100644 --- a/sdk/java/src/main/java/com/pulumi/command/remote/Command.java +++ b/sdk/java/src/main/java/com/pulumi/command/remote/Command.java @@ -11,6 +11,7 @@ import com.pulumi.core.annotations.Export; import com.pulumi.core.annotations.ResourceType; import com.pulumi.core.internal.Codegen; +import java.lang.Boolean; import java.lang.Object; import java.lang.String; import java.util.List; @@ -25,6 +26,24 @@ */ @ResourceType(type="command:remote:Command") public class Command extends com.pulumi.resources.CustomResource { + /** + * If the previous command's stdout and stderr (as generated by the prior create/update) is + * injected into the environment of the next run as PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR. + * Defaults to true. + * + */ + @Export(name="addPreviousOutputInEnv", refs={Boolean.class}, tree="[0]") + private Output addPreviousOutputInEnv; + + /** + * @return If the previous command's stdout and stderr (as generated by the prior create/update) is + * injected into the environment of the next run as PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR. + * Defaults to true. + * + */ + public Output> addPreviousOutputInEnv() { + return Codegen.optional(this.addPreviousOutputInEnv); + } /** * The parameters with which to connect to the remote host. * diff --git a/sdk/java/src/main/java/com/pulumi/command/remote/CommandArgs.java b/sdk/java/src/main/java/com/pulumi/command/remote/CommandArgs.java index 7ec6b04f..08036ab3 100644 --- a/sdk/java/src/main/java/com/pulumi/command/remote/CommandArgs.java +++ b/sdk/java/src/main/java/com/pulumi/command/remote/CommandArgs.java @@ -7,7 +7,9 @@ import com.pulumi.command.remote.inputs.ConnectionArgs; import com.pulumi.core.Output; import com.pulumi.core.annotations.Import; +import com.pulumi.core.internal.Codegen; import com.pulumi.exceptions.MissingRequiredPropertyException; +import java.lang.Boolean; import java.lang.Object; import java.lang.String; import java.util.List; @@ -21,6 +23,25 @@ public final class CommandArgs extends com.pulumi.resources.ResourceArgs { public static final CommandArgs Empty = new CommandArgs(); + /** + * If the previous command's stdout and stderr (as generated by the prior create/update) is + * injected into the environment of the next run as PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR. + * Defaults to true. + * + */ + @Import(name="addPreviousOutputInEnv") + private @Nullable Output addPreviousOutputInEnv; + + /** + * @return If the previous command's stdout and stderr (as generated by the prior create/update) is + * injected into the environment of the next run as PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR. + * Defaults to true. + * + */ + public Optional> addPreviousOutputInEnv() { + return Optional.ofNullable(this.addPreviousOutputInEnv); + } + /** * The parameters with which to connect to the remote host. * @@ -164,6 +185,7 @@ public Optional> update() { private CommandArgs() {} private CommandArgs(CommandArgs $) { + this.addPreviousOutputInEnv = $.addPreviousOutputInEnv; this.connection = $.connection; this.create = $.create; this.delete = $.delete; @@ -192,6 +214,31 @@ public Builder(CommandArgs defaults) { $ = new CommandArgs(Objects.requireNonNull(defaults)); } + /** + * @param addPreviousOutputInEnv If the previous command's stdout and stderr (as generated by the prior create/update) is + * injected into the environment of the next run as PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR. + * Defaults to true. + * + * @return builder + * + */ + public Builder addPreviousOutputInEnv(@Nullable Output addPreviousOutputInEnv) { + $.addPreviousOutputInEnv = addPreviousOutputInEnv; + return this; + } + + /** + * @param addPreviousOutputInEnv If the previous command's stdout and stderr (as generated by the prior create/update) is + * injected into the environment of the next run as PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR. + * Defaults to true. + * + * @return builder + * + */ + public Builder addPreviousOutputInEnv(Boolean addPreviousOutputInEnv) { + return addPreviousOutputInEnv(Output.of(addPreviousOutputInEnv)); + } + /** * @param connection The parameters with which to connect to the remote host. * @@ -391,6 +438,7 @@ public Builder update(String update) { } public CommandArgs build() { + $.addPreviousOutputInEnv = Codegen.booleanProp("addPreviousOutputInEnv").output().arg($.addPreviousOutputInEnv).def(true).getNullable(); if ($.connection == null) { throw new MissingRequiredPropertyException("CommandArgs", "connection"); } diff --git a/sdk/nodejs/remote/command.ts b/sdk/nodejs/remote/command.ts index 7310d618..193da79f 100644 --- a/sdk/nodejs/remote/command.ts +++ b/sdk/nodejs/remote/command.ts @@ -38,6 +38,12 @@ export class Command extends pulumi.CustomResource { return obj['__pulumiType'] === Command.__pulumiType; } + /** + * If the previous command's stdout and stderr (as generated by the prior create/update) is + * injected into the environment of the next run as PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR. + * Defaults to true. + */ + public readonly addPreviousOutputInEnv!: pulumi.Output; /** * The parameters with which to connect to the remote host. */ @@ -103,6 +109,7 @@ export class Command extends pulumi.CustomResource { if ((!args || args.connection === undefined) && !opts.urn) { throw new Error("Missing required property 'connection'"); } + resourceInputs["addPreviousOutputInEnv"] = (args ? args.addPreviousOutputInEnv : undefined) ?? true; resourceInputs["connection"] = args?.connection ? pulumi.secret((args.connection ? pulumi.output(args.connection).apply(inputs.remote.connectionArgsProvideDefaults) : undefined)) : undefined; resourceInputs["create"] = args ? args.create : undefined; resourceInputs["delete"] = args ? args.delete : undefined; @@ -114,6 +121,7 @@ export class Command extends pulumi.CustomResource { resourceInputs["stderr"] = undefined /*out*/; resourceInputs["stdout"] = undefined /*out*/; } else { + resourceInputs["addPreviousOutputInEnv"] = undefined /*out*/; resourceInputs["connection"] = undefined /*out*/; resourceInputs["create"] = undefined /*out*/; resourceInputs["delete"] = undefined /*out*/; @@ -138,6 +146,12 @@ export class Command extends pulumi.CustomResource { * The set of arguments for constructing a Command resource. */ export interface CommandArgs { + /** + * If the previous command's stdout and stderr (as generated by the prior create/update) is + * injected into the environment of the next run as PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR. + * Defaults to true. + */ + addPreviousOutputInEnv?: pulumi.Input; /** * The parameters with which to connect to the remote host. */ diff --git a/sdk/python/pulumi_command/remote/command.py b/sdk/python/pulumi_command/remote/command.py index d43571f4..5a33d156 100644 --- a/sdk/python/pulumi_command/remote/command.py +++ b/sdk/python/pulumi_command/remote/command.py @@ -18,6 +18,7 @@ class CommandArgs: def __init__(__self__, *, connection: pulumi.Input['ConnectionArgs'], + add_previous_output_in_env: Optional[pulumi.Input[bool]] = None, create: Optional[pulumi.Input[str]] = None, delete: Optional[pulumi.Input[str]] = None, environment: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None, @@ -28,6 +29,9 @@ def __init__(__self__, *, """ The set of arguments for constructing a Command resource. :param pulumi.Input['ConnectionArgs'] connection: The parameters with which to connect to the remote host. + :param pulumi.Input[bool] add_previous_output_in_env: If the previous command's stdout and stderr (as generated by the prior create/update) is + injected into the environment of the next run as PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR. + Defaults to true. :param pulumi.Input[str] create: The command to run on create. :param pulumi.Input[str] delete: The command to run on delete. The environment variables PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR are set to the stdout and stderr properties of the @@ -47,6 +51,10 @@ def __init__(__self__, *, create or update steps. """ pulumi.set(__self__, "connection", connection) + if add_previous_output_in_env is None: + add_previous_output_in_env = True + if add_previous_output_in_env is not None: + pulumi.set(__self__, "add_previous_output_in_env", add_previous_output_in_env) if create is not None: pulumi.set(__self__, "create", create) if delete is not None: @@ -74,6 +82,20 @@ def connection(self) -> pulumi.Input['ConnectionArgs']: def connection(self, value: pulumi.Input['ConnectionArgs']): pulumi.set(self, "connection", value) + @property + @pulumi.getter(name="addPreviousOutputInEnv") + def add_previous_output_in_env(self) -> Optional[pulumi.Input[bool]]: + """ + If the previous command's stdout and stderr (as generated by the prior create/update) is + injected into the environment of the next run as PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR. + Defaults to true. + """ + return pulumi.get(self, "add_previous_output_in_env") + + @add_previous_output_in_env.setter + def add_previous_output_in_env(self, value: Optional[pulumi.Input[bool]]): + pulumi.set(self, "add_previous_output_in_env", value) + @property @pulumi.getter def create(self) -> Optional[pulumi.Input[str]]: @@ -174,6 +196,7 @@ class Command(pulumi.CustomResource): def __init__(__self__, resource_name: str, opts: Optional[pulumi.ResourceOptions] = None, + add_previous_output_in_env: Optional[pulumi.Input[bool]] = None, connection: Optional[pulumi.Input[pulumi.InputType['ConnectionArgs']]] = None, create: Optional[pulumi.Input[str]] = None, delete: Optional[pulumi.Input[str]] = None, @@ -189,6 +212,9 @@ def __init__(__self__, :param str resource_name: The name of the resource. :param pulumi.ResourceOptions opts: Options for the resource. + :param pulumi.Input[bool] add_previous_output_in_env: If the previous command's stdout and stderr (as generated by the prior create/update) is + injected into the environment of the next run as PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR. + Defaults to true. :param pulumi.Input[pulumi.InputType['ConnectionArgs']] connection: The parameters with which to connect to the remote host. :param pulumi.Input[str] create: The command to run on create. :param pulumi.Input[str] delete: The command to run on delete. The environment variables PULUMI_COMMAND_STDOUT @@ -233,6 +259,7 @@ def __init__(__self__, resource_name: str, *args, **kwargs): def _internal_init(__self__, resource_name: str, opts: Optional[pulumi.ResourceOptions] = None, + add_previous_output_in_env: Optional[pulumi.Input[bool]] = None, connection: Optional[pulumi.Input[pulumi.InputType['ConnectionArgs']]] = None, create: Optional[pulumi.Input[str]] = None, delete: Optional[pulumi.Input[str]] = None, @@ -250,6 +277,9 @@ def _internal_init(__self__, raise TypeError('__props__ is only valid when passed in combination with a valid opts.id to get an existing resource') __props__ = CommandArgs.__new__(CommandArgs) + if add_previous_output_in_env is None: + add_previous_output_in_env = True + __props__.__dict__["add_previous_output_in_env"] = add_previous_output_in_env if connection is None and not opts.urn: raise TypeError("Missing required property 'connection'") __props__.__dict__["connection"] = None if connection is None else pulumi.Output.secret(connection) @@ -288,6 +318,7 @@ def get(resource_name: str, __props__ = CommandArgs.__new__(CommandArgs) + __props__.__dict__["add_previous_output_in_env"] = None __props__.__dict__["connection"] = None __props__.__dict__["create"] = None __props__.__dict__["delete"] = None @@ -300,6 +331,16 @@ def get(resource_name: str, __props__.__dict__["update"] = None return Command(resource_name, opts=opts, __props__=__props__) + @property + @pulumi.getter(name="addPreviousOutputInEnv") + def add_previous_output_in_env(self) -> pulumi.Output[Optional[bool]]: + """ + If the previous command's stdout and stderr (as generated by the prior create/update) is + injected into the environment of the next run as PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR. + Defaults to true. + """ + return pulumi.get(self, "add_previous_output_in_env") + @property @pulumi.getter def connection(self) -> pulumi.Output['outputs.Connection']: