Commit Graph

9 Commits

Author SHA1 Message Date
Aaron Friel b0919d4a0d
Refactor and fix bug in progress_test ()
Discovered while refactoring, the `raw` argument supplied to a test
utility in the `progress_test` tests was not used.

Fixes the tests in two commits, both of which pass tests. The first
implements the intended refactoring without changing the test behavior.
The second updates the test to use the `raw` parameter and regenerates
test output.

The refactoring is applied in this pull request as a "friendly
amendment" to improve the code before making larger changes to add more
testing options.
2024-08-28 23:18:24 +00:00
Will Jones 1f6724c737
Clean up display rewinding and wrapping ()
The Pulumi CLI supports rendering operations in a number of ways, such
as interactively to the console, or as streams of JSON events. The tree
renderer is one of Pulumi's interactive options, writing trees of parent
and child resources to the terminal as an operation progresses. This
commit pulls out part of  in order to improve the tree renderer in
two ways:

* When the number of lines rendered decreases between renders, old lines
that should no longer be visible must be overwritten. The previous
implementation was buggy in that it did not take system messages into
account when doing this. This commit does.
* When writing system messages, the previous implementation did not trim
output to the terminal width. This commit does.

With no additional changes, these fixes result in changes to the golden
test outputs we maintain as part of the display tests that are not
ASCII-visible. To rectify this and hopefully make these tests more
understandable, this commit also introduces a `mockTermInfo` terminal
info implementation that explicitly prints otherwise-invisible terminal
codes such as "hide cursor", "move cursor up 2 lines" and so on.
Moreover, this commit has been manually testing with a number of real
Pulumi CLI operations to try and avoid breakage of the display.
2024-08-19 15:30:48 +00:00
Fraser Waters dc12644fe4
Never show property diffs for OpSame ()
<!--- 
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>
2024-05-02 12:28:43 +00:00
Joe Duffy 96a9a77167
Policy remediations feature ()
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.
2023-10-09 18:31:17 +00:00
Abhinav Gupta fff9a8dd5d
display: Switch "Open in Browser" to "View in Browser"
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".
2023-03-10 10:52:43 -07:00
Pat Gavlin 2bad0a85e8 [cli] Add an "open in browser" keybinding
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.
2023-03-09 15:52:13 -08:00
Pat Gavlin 2e84add9da Update test baselines 2022-12-20 10:27:31 -08:00
Pat Gavlin 3aecebe5cb [color] Use graphemes to measure strings.
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.
2022-11-09 08:23:00 -08:00
Pat Gavlin a20ddffde5 [cli] Abstract out terminal interactions
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.
2022-11-08 17:13:56 -08:00