When displaying the progress of a Pulumi operation to the user, we want
the operation being displayed to reflect what is actually happening at
that moment in time. Most of the time, this means "just display the
operation in question" -- if a `create` is being executed, show
"creating", if a `delete` just completed, show "deleted", and so on.
However, there are cases where we can do better than just displaying the
"raw" operation. Specifically, our "replacement-like" operations
comprise a _series_ of steps that must execute for the operation as a
whole to make sense. For create-before-replace, we have:
* `create replacement` resource
* `replace` the old resource
* `delete original` resource
Other sequences, such as delete-before-replace, are similar (in the case
of delete-before-replace, the `delete original` step comes first).
While it might make sense to display the underlying steps as the
operation progresses, when the series of steps has _completed_, it's
(arguably) much clearer to simply render the string `replaced` so that
the user knows what has gone on. Similarly, during a preview, it (again
arguably) makes more sense for us to state that the intention is to
`replace`, rather than any one of `create replacement`/`replace`/`delete
original` and so on.
Alas, there is a case where this is potentially misleading and thus
undesirable behaviour. If an _error_ occurs during execution, the
operation will terminate at the next opportunity. In doing so, it will
enter a "done" state. At this point, we _do not_ want to rewrite the
step that was actually happening before the error interrupted it (e.g.
`create replacement`) with the "end" state (e.g. `replaced`), since the
error may mean we never reached that desired state. We want the display
to be as true to the raw series of steps as possible. This PR implements
this change, so that programs which terminate due to errors do not
rewrite their steps.
This PR addresses some of the confusion in #16270, in which we
incorrectly reported that a delete-before-replace resource had been
`replaced` when in fact we had only completed the deletion before being
interrupted by an error elsewhere.
Fix mangled diffs of strings containing url-encoded chars
Currently, modifying a stack output that contains url-encoded characters
can lead to it showing the value as `"!(NOVERB)"` or `"!(MISSING)"`.
For example, changing a stack output `path` from `"%2F"` to `"%2f"`
shows the diff as:
```
Outputs:
~ path: "%!(NOVERB)F" => "%!(NOVERB)f"
```
The expected diff output should be:
```
Outputs:
~ path: "%2F" => "%2f"
```
This is happening because the code that emits parts of the diff is
expecting a format string. Go is trying to parse the `%` in the value as
a format string and is having problems parsing it.
The fix is to emit the parts of the diff verbatim, so it isn't treated
as a format string.
Fixes#16123
Note: I've done an audit of the other calls to `write` in
`object_diff.go` and all the other call sites are passing actual format
strings or constants. This was the only case where we were passing user
input as a format string.
<!---
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->
# Description
<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->
Fixes https://github.com/pulumi/pulumi/issues/15944.
## Checklist
- [x] I have run `make tidy` to update any new dependencies
- [x] I have run `make lint` to verify my code passes the lint check
- [ ] I have formatted my code using `gofumpt`
<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!---
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
---------
Co-authored-by: Thomas Gummerer <t.gummerer@gmail.com>
This PR implements the new policy transforms feature, which allows
policy packs to not only issue warnings and errors in response to policy
violations, but actually fix them by rewriting resource property state.
This can be used, for instance, to auto-tag resources, remove Internet
access on the fly, or apply encryption to storage, among other use
cases.
Fixes https://github.com/pulumi/pulumi/issues/10312
When attempting to decode a string property value as JSON or YAML the
decoder would return a partial parse as valid. This resulted in strings
like "{} stuff" being reported as an empty JSON object, rather than the
literal string "{} stuff".
This also fixes the decoder to ignore whitespace around the value so for
example " [1, 2] " is now treated as a JSON array, not a string
literal.
Fixes https://github.com/pulumi/pulumi/issues/11990
There were a few places we were passing an already formatted string in
as the format argument for printf. This replaces those calls with
non-formatting print calls.
Switch this to "View in Browser" per discussion
which is closer to the old "View Live" message.
sdk/go/auto doesn't need an update because the regex there
is still using "View in Browser".
Add support for using Ctrl+O to open the current update in the browser
for backends that support permalinks.
The keybinding is advertised in the interactive display as part of the
message that displays the permalink:
```
Previewing update (dev)
View in Browser (Ctrl+O): https://<some-url>
Type Name Plan
+ pulumi:pulumi:Stack vpc-dev create
+ ├─ aws:ec2:Vpc vpc create
+ ├─ aws:ec2:SecurityGroup secgroup create
+ ├─ aws:ec2:SecurityGroupRule rule-2 create
+ ├─ aws:ec2:SecurityGroupRule rule-0 create
+ ├─ aws:ec2:SecurityGroupRule rule-1 create
+ └─ aws:ec2:SecurityGroupRule rule-3 create
```
In order to maintain backwards compatibility with older versions of the
Automation API, the message is not changed for non-interactive
scenarios.
- If the display is scrolled to the bottom, autoscroll it as new lines are
added to the output.
- Add support for scrolling the interactive display using page-down and
page-up. These keys scroll the display N lines at a time, where N is the
height of the terminal.
The number of Unicode code points in a string is not the same as the
number of user-visible characters (graphemes). When measuring colorized
strings, we want the latter rather than the former. Notably, these
changes fix some issues where the interactive display cut off before the
right edge of the terminal.
Replace direct interaction with the terminal with an abstraction. This
abstraction is tightly constrained to the capabilities needed for the
CLI's display. Using this abstraction allows for straightforward testing
of the interactive renderers.