Visitar URL original
do: fix `--dry-run` for delete by tgummerer · Pull Request #23809 · pulumi/pulumi · GitHub
Skip to content

do: fix --dry-run for delete - #23809

Merged
tgummerer merged 2 commits into
masterfrom
tg/do-delete-dry-run
Jul 8, 2026
Merged

tgummerer merged 2 commits into
masterfrom
tg/do-delete-dry-run

Conversation

@tgummerer

Copy link
Copy Markdown
Collaborator

--dry-run is a global flag for pulumi do. However there's no
provider support for this in read, list and most importantly for
delete. In the case of delete, the user can currently pass a
--dry-run flag, which then rather than --dry-run is effectively
interpreted as --yes, deleting the resource directly.

Just reject the flag when it is passed to one of those three commands.

@tgummerer
tgummerer requested a review from a team as a code owner July 7, 2026 12:42
@tgummerer tgummerer added the impact/no-changelog-required This issue doesn't require a CHANGELOG update label Jul 7, 2026
@Frassle

Frassle commented Jul 7, 2026

Copy link
Copy Markdown
Member

For read and list I think we can just ignore --dry-run rather than returning an error.
For invokes there is a dryRun property passed to the invoke, so that matters.
For deletes could we just print "would delete resource X" and skip the actual Delete call?

@tgummerer
tgummerer force-pushed the tg/do-delete-dry-run branch from cf96ea6 to 71065fa Compare July 7, 2026 13:25
@tgummerer

Copy link
Copy Markdown
Collaborator Author

For read and list I think we can just ignore --dry-run rather than returning an error.

Sounds good.

For invokes there is a dryRun property passed to the invoke, so that matters.

Yup, that's already what happens.

For deletes could we just print "would delete resource X" and skip the actual Delete call?

Happy to do that, changed now.

@tgummerer tgummerer changed the title do: reject --dry-run for commands that don't support it do: fix --dry-run for delete Jul 8, 2026

@Frassle Frassle left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine, better than it was. I do wonder if we should skip the confirms for create/update/delete when doing a dry-run though? Nothing can actually happen, feels ok to just let the command run, and interrupts the user less.

@tgummerer

Copy link
Copy Markdown
Collaborator Author

I do wonder if we should skip the confirms for create/update/delete when doing a dry-run though? Nothing can actually happen, feels ok to just let the command run, and interrupts the user less.

We already do that, e.g.

$ pulumi do random:RandomPassword create --stateless --length 1 --dry-run
This will create random:index/randomPassword:RandomPassword with the following inputs:
{
  "length": 1
}
{
  "bcryptHash": "[unknown]",
  "id": "[unknown]",
  "length": 1,
  "lower": true,
  "minLower": 0,
  "minNumeric": 0,
  "minSpecial": 0,
  "minUpper": 0,
  "number": true,
  "numeric": true,
  "result": "[unknown]",
  "special": true,
  "upper": true
}

Doesn't require any confirmation. Same for delete and read.

tgummerer added 2 commits July 8, 2026 11:02
`--dry-run` is a global flag for `pulumi do`.  However there's no
provider support for this in `read`, `list` and most importantly for
`delete`.  In the case of `delete`, the user can currently pass a
`--dry-run` flag, which then rather than `--dry-run` is effectively
interpreted as `--yes`, deleting the resource directly.

Just reject the flag when it is passed to one of those three commands.
@tgummerer
tgummerer force-pushed the tg/do-delete-dry-run branch from 71065fa to da84ee2 Compare July 8, 2026 09:04
@tgummerer
tgummerer enabled auto-merge July 8, 2026 09:04
@Frassle

Frassle commented Jul 8, 2026

Copy link
Copy Markdown
Member

Ah right because confirm itself checks it and early returns. All good then.

@tgummerer
tgummerer added this pull request to the merge queue Jul 8, 2026
Merged via the queue into master with commit aff0ffa Jul 8, 2026
123 checks passed
@tgummerer
tgummerer deleted the tg/do-delete-dry-run branch July 8, 2026 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

impact/no-changelog-required This issue doesn't require a CHANGELOG update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants