From 3550a783f28d59060aa22f189599cd1223d592b9 Mon Sep 17 00:00:00 2001 From: IaroslavTitov Date: Fri, 12 Apr 2024 13:30:12 -0600 Subject: [PATCH] Adding delete after destroy into deployment settings --- CHANGELOG_PENDING.md | 2 + .../pulumi-resource-pulumiservice/schema.json | 4 ++ .../internal/pulumiapi/deployment_settings.go | 1 + provider/pkg/provider/deployment_settings.go | 7 ++++ .../Inputs/OperationContextOptionsArgs.cs | 6 +++ sdk/go/pulumiservice/pulumiTypes.go | 19 ++++++++++ .../inputs/OperationContextOptionsArgs.java | 37 +++++++++++++++++++ sdk/nodejs/types/input.ts | 4 ++ sdk/python/pulumi_pulumiservice/_inputs.py | 16 ++++++++ 9 files changed, 96 insertions(+) diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index 5e78e668..daf2f3a6 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -1,5 +1,7 @@ ### Improvements +- Support `deleteAfterDestroy` option for the `DeploymentSettings` resource. [#207](https://github.com/pulumi/pulumi-pulumiservice/issues/229) + ### Bug Fixes ### Miscellaneous diff --git a/provider/cmd/pulumi-resource-pulumiservice/schema.json b/provider/cmd/pulumi-resource-pulumiservice/schema.json index bfe86099..bbb368e5 100644 --- a/provider/cmd/pulumi-resource-pulumiservice/schema.json +++ b/provider/cmd/pulumi-resource-pulumiservice/schema.json @@ -329,6 +329,10 @@ "shell": { "type": "string", "description": "The shell to use to run commands during the deployment. Defaults to 'bash'." + }, + "deleteAfterDestroy": { + "type": "boolean", + "description": "Whether the stack should be deleted after it is destroyed." } } }, diff --git a/provider/pkg/internal/pulumiapi/deployment_settings.go b/provider/pkg/internal/pulumiapi/deployment_settings.go index cedca8b0..e2e35927 100644 --- a/provider/pkg/internal/pulumiapi/deployment_settings.go +++ b/provider/pkg/internal/pulumiapi/deployment_settings.go @@ -62,6 +62,7 @@ type OperationContextOptions struct { SkipInstallDependencies bool `json:"skipInstallDependencies,omitempty"` SkipIntermediateDeployments bool `json:"skipIntermediateDeployments,omitempty"` Shell string `json:"shell,omitempty"` + DeleteAfterDestroy bool `json:"deleteAfterDestroy,omitempty"` } type GitHubConfiguration struct { diff --git a/provider/pkg/provider/deployment_settings.go b/provider/pkg/provider/deployment_settings.go index d8558d28..b8ebe9e0 100644 --- a/provider/pkg/provider/deployment_settings.go +++ b/provider/pkg/provider/deployment_settings.go @@ -100,6 +100,9 @@ func (ds *PulumiServiceDeploymentSettingsInput) ToPropertyMap() resource.Propert if ds.OperationContext.Options.SkipIntermediateDeployments { optionsMap["skipIntermediateDeployments"] = resource.NewPropertyValue(true) } + if ds.OperationContext.Options.DeleteAfterDestroy { + optionsMap["deleteAfterDestroy"] = resource.NewPropertyValue(true) + } ocMap["options"] = resource.PropertyValue{V: optionsMap} } if ds.OperationContext.OIDC != nil { @@ -385,6 +388,10 @@ func toOperationContext(inputMap resource.PropertyMap) *pulumiapi.OperationConte o.Shell = oInput["Shell"].StringValue() } + if oInput["deleteAfterDestroy"].HasValue() && oInput["deleteAfterDestroy"].IsBool() { + o.DeleteAfterDestroy = oInput["deleteAfterDestroy"].BoolValue() + } + oc.Options = &o } diff --git a/sdk/dotnet/Inputs/OperationContextOptionsArgs.cs b/sdk/dotnet/Inputs/OperationContextOptionsArgs.cs index 5bf17a47..73da0473 100644 --- a/sdk/dotnet/Inputs/OperationContextOptionsArgs.cs +++ b/sdk/dotnet/Inputs/OperationContextOptionsArgs.cs @@ -12,6 +12,12 @@ namespace Pulumi.PulumiService.Inputs public sealed class OperationContextOptionsArgs : global::Pulumi.ResourceArgs { + /// + /// Whether the stack should be deleted after it is destroyed. + /// + [Input("deleteAfterDestroy")] + public Input? DeleteAfterDestroy { get; set; } + /// /// The shell to use to run commands during the deployment. Defaults to 'bash'. /// diff --git a/sdk/go/pulumiservice/pulumiTypes.go b/sdk/go/pulumiservice/pulumiTypes.go index 048bab39..ba3b0589 100644 --- a/sdk/go/pulumiservice/pulumiTypes.go +++ b/sdk/go/pulumiservice/pulumiTypes.go @@ -2129,6 +2129,8 @@ func (o OperationContextOIDCPtrOutput) Gcp() GCPOIDCConfigurationPtrOutput { } type OperationContextOptions struct { + // Whether the stack should be deleted after it is destroyed. + DeleteAfterDestroy *bool `pulumi:"deleteAfterDestroy"` // The shell to use to run commands during the deployment. Defaults to 'bash'. Shell *string `pulumi:"shell"` // Skip the default dependency installation step - use this to customize the dependency installation (e.g. if using yarn or poetry) @@ -2149,6 +2151,8 @@ type OperationContextOptionsInput interface { } type OperationContextOptionsArgs struct { + // Whether the stack should be deleted after it is destroyed. + DeleteAfterDestroy pulumi.BoolPtrInput `pulumi:"deleteAfterDestroy"` // The shell to use to run commands during the deployment. Defaults to 'bash'. Shell pulumi.StringPtrInput `pulumi:"shell"` // Skip the default dependency installation step - use this to customize the dependency installation (e.g. if using yarn or poetry) @@ -2234,6 +2238,11 @@ func (o OperationContextOptionsOutput) ToOperationContextOptionsPtrOutputWithCon }).(OperationContextOptionsPtrOutput) } +// Whether the stack should be deleted after it is destroyed. +func (o OperationContextOptionsOutput) DeleteAfterDestroy() pulumi.BoolPtrOutput { + return o.ApplyT(func(v OperationContextOptions) *bool { return v.DeleteAfterDestroy }).(pulumi.BoolPtrOutput) +} + // The shell to use to run commands during the deployment. Defaults to 'bash'. func (o OperationContextOptionsOutput) Shell() pulumi.StringPtrOutput { return o.ApplyT(func(v OperationContextOptions) *string { return v.Shell }).(pulumi.StringPtrOutput) @@ -2273,6 +2282,16 @@ func (o OperationContextOptionsPtrOutput) Elem() OperationContextOptionsOutput { }).(OperationContextOptionsOutput) } +// Whether the stack should be deleted after it is destroyed. +func (o OperationContextOptionsPtrOutput) DeleteAfterDestroy() pulumi.BoolPtrOutput { + return o.ApplyT(func(v *OperationContextOptions) *bool { + if v == nil { + return nil + } + return v.DeleteAfterDestroy + }).(pulumi.BoolPtrOutput) +} + // The shell to use to run commands during the deployment. Defaults to 'bash'. func (o OperationContextOptionsPtrOutput) Shell() pulumi.StringPtrOutput { return o.ApplyT(func(v *OperationContextOptions) *string { diff --git a/sdk/java/src/main/java/com/pulumi/pulumiservice/inputs/OperationContextOptionsArgs.java b/sdk/java/src/main/java/com/pulumi/pulumiservice/inputs/OperationContextOptionsArgs.java index 03055ea4..9adfbf5f 100644 --- a/sdk/java/src/main/java/com/pulumi/pulumiservice/inputs/OperationContextOptionsArgs.java +++ b/sdk/java/src/main/java/com/pulumi/pulumiservice/inputs/OperationContextOptionsArgs.java @@ -16,6 +16,21 @@ public final class OperationContextOptionsArgs extends com.pulumi.resources.Reso public static final OperationContextOptionsArgs Empty = new OperationContextOptionsArgs(); + /** + * Whether the stack should be deleted after it is destroyed. + * + */ + @Import(name="deleteAfterDestroy") + private @Nullable Output deleteAfterDestroy; + + /** + * @return Whether the stack should be deleted after it is destroyed. + * + */ + public Optional> deleteAfterDestroy() { + return Optional.ofNullable(this.deleteAfterDestroy); + } + /** * The shell to use to run commands during the deployment. Defaults to 'bash'. * @@ -64,6 +79,7 @@ public Optional> skipIntermediateDeployments() { private OperationContextOptionsArgs() {} private OperationContextOptionsArgs(OperationContextOptionsArgs $) { + this.deleteAfterDestroy = $.deleteAfterDestroy; this.shell = $.shell; this.skipInstallDependencies = $.skipInstallDependencies; this.skipIntermediateDeployments = $.skipIntermediateDeployments; @@ -87,6 +103,27 @@ public Builder(OperationContextOptionsArgs defaults) { $ = new OperationContextOptionsArgs(Objects.requireNonNull(defaults)); } + /** + * @param deleteAfterDestroy Whether the stack should be deleted after it is destroyed. + * + * @return builder + * + */ + public Builder deleteAfterDestroy(@Nullable Output deleteAfterDestroy) { + $.deleteAfterDestroy = deleteAfterDestroy; + return this; + } + + /** + * @param deleteAfterDestroy Whether the stack should be deleted after it is destroyed. + * + * @return builder + * + */ + public Builder deleteAfterDestroy(Boolean deleteAfterDestroy) { + return deleteAfterDestroy(Output.of(deleteAfterDestroy)); + } + /** * @param shell The shell to use to run commands during the deployment. Defaults to 'bash'. * diff --git a/sdk/nodejs/types/input.ts b/sdk/nodejs/types/input.ts index 40c5879e..50f47bb2 100644 --- a/sdk/nodejs/types/input.ts +++ b/sdk/nodejs/types/input.ts @@ -232,6 +232,10 @@ export interface OperationContextOIDCArgs { } export interface OperationContextOptionsArgs { + /** + * Whether the stack should be deleted after it is destroyed. + */ + deleteAfterDestroy?: pulumi.Input; /** * The shell to use to run commands during the deployment. Defaults to 'bash'. */ diff --git a/sdk/python/pulumi_pulumiservice/_inputs.py b/sdk/python/pulumi_pulumiservice/_inputs.py index 63563317..52e1f1bf 100644 --- a/sdk/python/pulumi_pulumiservice/_inputs.py +++ b/sdk/python/pulumi_pulumiservice/_inputs.py @@ -722,14 +722,18 @@ def gcp(self, value: Optional[pulumi.Input['GCPOIDCConfigurationArgs']]): @pulumi.input_type class OperationContextOptionsArgs: def __init__(__self__, *, + delete_after_destroy: Optional[pulumi.Input[bool]] = None, shell: Optional[pulumi.Input[str]] = None, skip_install_dependencies: Optional[pulumi.Input[bool]] = None, skip_intermediate_deployments: Optional[pulumi.Input[bool]] = None): """ + :param pulumi.Input[bool] delete_after_destroy: Whether the stack should be deleted after it is destroyed. :param pulumi.Input[str] shell: The shell to use to run commands during the deployment. Defaults to 'bash'. :param pulumi.Input[bool] skip_install_dependencies: Skip the default dependency installation step - use this to customize the dependency installation (e.g. if using yarn or poetry) :param pulumi.Input[bool] skip_intermediate_deployments: Skip intermediate deployments (Consolidate multiple deployments of the same type into one deployment) """ + if delete_after_destroy is not None: + pulumi.set(__self__, "delete_after_destroy", delete_after_destroy) if shell is not None: pulumi.set(__self__, "shell", shell) if skip_install_dependencies is not None: @@ -737,6 +741,18 @@ def __init__(__self__, *, if skip_intermediate_deployments is not None: pulumi.set(__self__, "skip_intermediate_deployments", skip_intermediate_deployments) + @property + @pulumi.getter(name="deleteAfterDestroy") + def delete_after_destroy(self) -> Optional[pulumi.Input[bool]]: + """ + Whether the stack should be deleted after it is destroyed. + """ + return pulumi.get(self, "delete_after_destroy") + + @delete_after_destroy.setter + def delete_after_destroy(self, value: Optional[pulumi.Input[bool]]): + pulumi.set(self, "delete_after_destroy", value) + @property @pulumi.getter def shell(self) -> Optional[pulumi.Input[str]]: