Commit Graph

46 Commits

Author SHA1 Message Date
Thomas Gummerer 05fc7ab993
Include all engine events in the event log ()
In https://github.com/pulumi/pulumi/pull/14607 we introduced filtering
of engine events before they are displayed. However in the process we
also started filtering them from the event log. The event log is used
for two things, the automation API and debugging. The automation API
already ignores events it doesn't know about (and it should because a
new version of the CLI can always introduce new events that aren't
filtered), and for debugging it is very useful to have all events in the
event log.

In fact we are going to introduce a new debugging event, which the
automation API will need (plugins for IDEs are going to be written using
the automation API to intercept the engine events).

Move the filtering after the writing to the event log, so we always have
all events there, but still filter events that are not relevant to the
service etc.
2024-08-30 10:31:19 +00:00
Thomas Gummerer 8219c922a2
display: only hide replacement steps in diff ()
When displaying diff events, we currently try to hide non-logical
replacement steps unless we specifically enable showing them. However we
currently do that for all non-logical operations, regardless whether
they are replacement steps or not.

In particular a RefreshStep is non-logical, but it's also not a
replacement step. We still want to show them during the diff because
their output can be important. Especially if the user just requested a
diff it doesn't make sense to hide the diff from them at the same time.

The intention here is to only hide replacement steps, so do that.

The full diff with the display tests is here:
https://gist.github.com/tgummerer/fcd012f13669a9cdc39530cde7770260 It's
unedited, so it includes some flakyness which isn't interesting.

I looked it over, and I think it looks like what we want, but I'm
curious to hear what others think. E.g.
https://gist.github.com/tgummerer/fcd012f13669a9cdc39530cde7770260#file-testdata-diff-L558
looks more correct now, as it shows the two delete operation that
actually happened, that it didn't show before, and it still shows the
same operation (Calling this one out in particular, since it took me a
bit to understand that we still have the same operation in the diff)

Fixes https://github.com/pulumi/pulumi/issues/7665
2024-04-26 14:54:21 +00:00
Fraser Waters bbaf871ad1
Check qualified type for root stackness ()
With the introduction of component programs there will be mulitple
"pulumi:pulumi:stack" resources in a program. We should therefore check
against the qualified type of resources to see if they are the root
stack, not just their direct type.
2023-12-04 10:36:51 +00:00
Fraser Waters 54c956af6d
Send all events to the engine event stream ()
<!--- 
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. -->

Currently the engine skips sending some resource events to the event
stream. Currently that's any "RemovePendingDelete" steps and anything to
do with default providers.

This was added so that we wouldn't display "internal implemntation
details" like default providers to the user in the tree or diff views.

However we wanted to use the engine event stream to support generating
an import file from preview deployments (make an import for every
resource that needs to be created). This mostly works except for the
imports we also need to know some of the provider details, and while the
event stream will tell us about explicit providers the skipping of
default providers means we can't get their information in the import
generater code.

So this moves this filtering out of the engine and to the display logic
instead. We still leave it up to the engine to mark what events it
considers "internal" but they're always sent to the event stream.

## 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 - This shouldn't change anything user visible so should be
covered by existing tests
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change - No user visible
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. -->
2023-11-20 21:55:59 +00:00
Fraser Waters d771acf707
Add tokens.StackName ()
<!--- 
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. -->

This adds a new type `tokens.StackName` which is a relatively strongly
typed container for a stack name. The only weakly typed aspect of it is
Go will always allow the "zero" value to be created for a struct, which
for a stack name is the empty string which is invalid. To prevent
introducing unexpected empty strings when working with stack names the
`String()` method will panic for zero initialized stack names.
 
Apart from the zero value, all other instances of `StackName` are via
`ParseStackName` which returns a descriptive error if the string is not
valid.

This PR only updates "pkg/" to use this type. There are a number of
places in "sdk/" which could do with this type as well, but there's no
harm in doing a staggered roll out, and some parts of "sdk/" are user
facing and will probably have to stay on the current `tokens.Name` and
`tokens.QName` types.

There are two places in the system where we panic on invalid stack
names, both in the http backend. This _should_ be fine as we've had long
standing validation that stacks created in the service are valid stack
names.

Just in case people have managed to introduce invalid stack names, there
is the `PULUMI_DISABLE_VALIDATION` environment variable which will turn
off the validation _and_ panicing for stack names. Users can use that to
temporarily disable the validation and continue working, but it should
only be seen as a temporary measure. If they have invalid names they
should rename them, or if they think they should be valid raise an issue
with us to change the validation code.

## 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. -->
- [x] 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. -->
2023-11-15 07:44:54 +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
Abhinav Gupta 7aa5b77a0c
all: Reformat with gofumpt
Per team discussion, switching to gofumpt.

[gofumpt][1] is an alternative, stricter alternative to gofmt.
It addresses other stylistic concerns that gofmt doesn't yet cover.

  [1]: https://github.com/mvdan/gofumpt

See the full list of [Added rules][2], but it includes:

- Dropping empty lines around function bodies
- Dropping unnecessary variable grouping when there's only one variable
- Ensuring an empty line between multi-line functions
- simplification (`-s` in gofmt) is always enabled
- Ensuring multi-line function signatures end with
  `) {` on a separate line.

  [2]: https://github.com/mvdan/gofumpt#Added-rules

gofumpt is stricter, but there's no lock-in.
All gofumpt output is valid gofmt output,
so if we decide we don't like it, it's easy to switch back
without any code changes.

gofumpt support is built into the tooling we use for development
so this won't change development workflows.

- golangci-lint includes a gofumpt check (enabled in this PR)
- gopls, the LSP for Go, includes a gofumpt option
  (see [installation instrutions][3])

  [3]: https://github.com/mvdan/gofumpt#installation

This change was generated by running:

```bash
gofumpt -w $(rg --files -g '*.go' | rg -v testdata | rg -v compilation_error)
```

The following files were manually tweaked afterwards:

- pkg/cmd/pulumi/stack_change_secrets_provider.go:
  one of the lines overflowed and had comments in an inconvenient place
- pkg/cmd/pulumi/destroy.go:
  `var x T = y` where `T` wasn't necessary
- pkg/cmd/pulumi/policy_new.go:
  long line because of error message
- pkg/backend/snapshot_test.go:
  long line trying to assign three variables in the same assignment

I have included mention of gofumpt in the CONTRIBUTING.md.
2023-03-03 09:00:24 -08:00
Fraser Waters 1aadd3d786 Set O_APPEND on the engine event log file 2023-02-15 09:35:17 +00:00
Pat Gavlin 817c3b5c88
[cli] Add a replay-events debug command. ()
This command renders a recorded stream of engine events using either the
progress or diff renderer. This is useful for debugging problems with
these renderers.
2022-04-07 09:03:19 -07:00
Fraser Waters 86f3f712aa
Readd "Make StackReference.Name a tokens.Name ()" ()
* Readd "Make StackReference.Name a tokens.Name ()"

This reverts commit f0aa4df149.

This also removes the AsName asserting casts for stack names. We do want
to add them in at some point to be sure that bad names don't slip in
somehow but they don't need adding with this.

* Update sdk/go/common/util/fsutil/qname.go

Co-authored-by: Ian Wahbe <ian@wahbe.com>

Co-authored-by: Ian Wahbe <ian@wahbe.com>
2022-03-17 21:37:11 +00:00
Ian Wahbe f0aa4df149
Revert "Make StackReference.Name a tokens.Name ()" ()
This reverts commit a72df9aefa.
2022-03-09 13:48:52 -08:00
Fraser Waters a72df9aefa
Make StackReference.Name a tokens.Name ()
* Make StackReference.Name a tokens.Name

* Don't panic in ParseStackReference
2022-03-07 20:59:44 +00:00
Kyle Dixler 6e9e248f2c
reverted 8ffac5c () () ()
Co-authored-by: Kyle Dixler <kyle@pulumi.com>
2022-02-02 14:59:01 -08:00
Kyle Dixler 8ffac5ca2c
fix pulumi new selector behaves poorly when lines wrap ()
* bumped github.com/AlecAivazis/survey to v2.3.2 and encapsulated duplicated logic

* updated CHANGELOG_PENDING.md

Co-authored-by: Kyle Dixler <kyle@pulumi.com>
2022-01-31 07:15:45 -08:00
Komal 2f433d64b7
[cli] Emit JSON events for updates via `--json` flag () 2021-10-26 16:21:27 -07:00
Komal 3d42198991
Clean up diagnostic messages in event log ()
* Don't escape characters in event log.

* Respect NO_COLOR
2021-09-21 17:22:39 -07:00
pulumi-bot 73a66f48ea [breaking] Changing the version of go.mod in sdk / pkg to be v3 2021-04-14 19:32:18 +01:00
Paul Stack 0824fc9a8b
Revert "Narrow a few interfaces." () 2020-07-09 15:19:12 +01:00
Pat Gavlin 45d2fa95d6
Narrow a few interfaces. ()
- Remove `Info` from `Source`. This method was not used.
- Remove `Stack` from `EvalSource`. This method was not used.
- Remove `Type` and `URN` from `Step`. These values are available via
  `Res().URN.Type()` and `Res().URN`, respectively. This removes the
  possibility of inconsistencies between the type, URN, and state of the
  resource associated with a `Step`.
- Remove URN from StepEventMetadata.
2020-07-01 15:32:50 -07:00
CyrusNajmabadi 66bd3f4aa8
Breaking changes due to Feature 2.0 work
* Make `async:true` the default for `invoke` calls ()

* Switch away from native grpc impl. ()

* Remove usage of the 'deasync' library from @pulumi/pulumi. ()

* Only retry as long as we get unavailable back.  Anything else continues. ()

* Handle all errors for now. ()


* Do not assume --yes was present when using pulumi in non-interactive mode ()

* Upgrade all paths for sdk and pkg to v2

* Backport C# invoke classes and other recent gen changes ()

Adjust C# generation

* Replace IDeployment with a sealed class ()

Replace IDeployment with a sealed class

* .NET: default to args subtype rather than Args.Empty ()

* Adding system namespace for Dotnet code gen

This is required for using Obsolute attributes for deprecations

```
Iam/InstanceProfile.cs(142,10): error CS0246: The type or namespace name 'ObsoleteAttribute' could not be found (are you missing a using directive or an assembly reference?) [/Users/stack72/code/go/src/github.com/pulumi/pulumi-aws/sdk/dotnet/Pulumi.Aws.csproj]
Iam/InstanceProfile.cs(142,10): error CS0246: The type or namespace name 'Obsolete' could not be found (are you missing a using directive or an assembly reference?) [/Users/stack72/code/go/src/github.com/pulumi/pulumi-aws/sdk/dotnet/Pulumi.Aws.csproj]
```

* Fix the nullability of config type properties in C# codegen ()
2020-04-14 09:30:25 +01:00
evanboyle d3f5bbce48 go fmt 2020-03-18 17:27:02 -07:00
evanboyle c3f6ae2451 move pkg/util/logging -> sdk/go/common/util/logging 2020-03-18 15:34:58 -07:00
evanboyle 67cb405c93 move pkg/apitype -> sdk/common/apitype 2020-03-18 15:00:30 -07:00
evanboyle 70f386a967 move pkg/tokens -> sdk/go/common/tokens 2020-03-18 14:49:56 -07:00
evanboyle fccf301d14 move pkg/util/contract -> sdk/go/common/util/contract 2020-03-18 14:40:07 -07:00
evanboyle fba783caf9 move pkg/resource -> sdk/go/common/resource, but leave nested resource packages 2020-03-18 13:36:19 -07:00
Chris Smith 5f8951c4dc
Serialize resource states the right way () 2019-12-16 09:57:54 -08:00
Luke Hoban 25206c5ea8 Add an experimental `pulumi watch` command ()
Adds a new experimental `pulumi watch` CLI command which can be used for inner loop development on a Pulumi stack.  This command is only available currently via `PULUMI_EXPERIMENTAL=true` while in active development.

The `watch` command does the following:
1. Watches the workspace (the tree rooted at the `Pulumi.yaml` file) for changes
2. Triggers an `update` to the stack whenever there is a change
3. Streams output containing summaries of key update events as well as logs from any resources under management into a combined CLI output

Part of https://github.com/pulumi/pulumi/issues/3448.

The PULUMI_EXPERIMENTAL flag also makes`query` and `policy` available.
2019-11-06 12:56:29 -08:00
Pat Gavlin b7404f202e
Expose update events to ExtraRuntimeValidation. ()
* Add the ability to log all engine events to a file.

The path to the file can be specified using the `--event-log` flag to
the CLI. The file will be truncated if it exists. Events are written as
a list of JSON values using the schema described by `pkg/apitype`.

* Expose update engine events to ExtraRuntimeValidation.

Just what it says on the tin. Events from previews are not exposed.
2019-09-06 17:07:54 -07:00
Alex Clemmer 5ce46e2882 Add display mode for `pulumi query`
The Pulumi CLI currently has two "display modes" -- one for rendering
diffs and one for rendering program updates. Neither of these is
particularly well-suited to `pulumi query`, which essentially needs to
render stdout from the query program verbatim.

This commit will add a separate display mode for this purpose:

* In interactive mode, `pulumi query` will use the display spinner to
  say "running query". In non-interactive mode, this will be omitted.
* Query mode will print stdout from the query program verbatim, but
  ignore `diag.Infoerr` so that they're not double-printed when they're
  emitted again as error events.
* Query mode also does not double-print newlines at the end of diag
  events.
2019-05-02 18:08:08 -07:00
joeduffy 23f905a468 Respect --show flags for --json (and --diff) 2019-04-25 17:36:31 -07:00
joeduffy 250bcb9751 Add a --json flag to the preview command
This change adds a --json flag to the preview command, enabling
basic JSON serialization of preview plans. This effectively flattens
the engine event stream into a preview structure that contains a list
of steps, diagnostics, and summary information. Each step contains
the deep serialization of resource state, in addition to metadata about
the step, such as what kind of operation it entails.

This is a partial implementation of . In particular,
we only support --json on the `preview` command itself, and not `up`,
meaning that it isn't possible to serialize the result of an actual
deployment yet (thereby limiting what you can do with outputs, etc).
2019-04-25 17:36:31 -07:00
Pat Gavlin ded3882afd
Fix synchronization with the event renderer ()
The event rendering goroutine in the remote backend was not properly
synchronizing with the goroutine that created it, and could continue
executing after its creator finished. I believe that this is the root
cause of .
2018-12-13 19:58:26 -08:00
CyrusNajmabadi 76d08f8590
Simplify summary text. () 2018-10-30 21:57:38 -07:00
CyrusNajmabadi 73b42d753b
Include diagnostic prefix in the output for the diff display. () 2018-10-30 17:46:22 -07:00
CyrusNajmabadi 9b1c2ff54d
Round time to the nearest second to clean up our display () 2018-10-30 17:42:03 -07:00
CyrusNajmabadi 8eff0e3142
Remove need to dynamically determine if we're in preview or not. () 2018-10-30 15:42:33 -07:00
Joe Duffy c5a86ae7c2
Add an option to suppress displaying stack outputs ()
This adds an option, --suppress-outputs, to many commands, to
avoid printing stack outputs for stacks that might contain sensitive
information in their outputs (like key material, and whatnot).

Fixes .
2018-10-06 14:13:02 -07:00
CyrusNajmabadi 16ae1f2a81
Fix rendering of the 'outputs:' header in the diff view. () 2018-10-03 13:06:20 -07:00
joeduffy b06a02f03c Use go-humanize instead of lame hand-pluralization 2018-09-24 14:40:14 -07:00
joeduffy 3468393490 Make a smattering of CLI UX improvements
Since I was digging around over the weekend after the change to move
away from light black, and the impact it had on less important
information showing more prominently than it used to, I took a step
back and did a deeper tidying up of things. Another side goal of this
exercise was to be a little more respectful of terminal width; when
we could say things with fewer words, I did so.

* Stylize the preview/update summary differently, so that it stands
  out as a section. Also highlight the total changes with bold -- it
  turns out this has a similar effect to the bright white colorization,
  just without the negative effects on e.g. white terminals.

* Eliminate some verbosity in the phrasing of change summaries.

* Make all heading sections stylized consistently. This includes
  the color (bright magenta) and the vertical spacing (always a newline
  separating headings). We were previously inconsistent on this (e.g.,
  outputs were under "---outputs---"). Now   the headings are:
  Previewing (etc), Diagnostics, Outputs, Resources, Duration, and Permalink.

* Fix an issue where we'd parent things to "global" until the stack
  object later showed up. Now we'll simply mock up a stack resource.

* Don't show messages like "no change" or "unchanged". Prior to the
  light black removal, these faded into the background of the terminal.
  Now they just clutter up the display. Similar to the elision of "*"
  for OpSames in a prior commit, just leave these out. Now anything
  that's written is actually a meaningful status for the user to note.

* Don't show the "3 info messages," etc. summaries in the Info column
  while an update is ongoing. Instead, just show the latest line. This
  is more respectful of width -- I often find that the important
  messages scroll off the right of my screen before this change.

    For discussion:

        - I actually wonder if we should eliminate the summary
          altogether and always just show the latest line. Or even
          blank it out. The summary feels better suited for the
          Diagnostics section, and the Status concisely tells us
          how a resource's update ended up (failed, succeeded, etc).

        - Similarly, I question the idea of showing only the "worst"
          message. I'd vote for always showing the latest, and again
          leaving it to the Status column for concisely telling the
          user about the final state a resource ended up in.

* Stop prepending "info: " to every stdout/stderr message. It adds
  no value, clutters up the display, and worsens horizontal usage.

* Lessen the verbosity of update headline messages, so we now instead
  of e.g. "Previewing update of stack 'x':", we just say
  "Previewing update (x):".

* Eliminate vertical whitespace in the Diagnostics section. Every
  independent console.out previously was separated by an entire newline,
  which made the section look cluttered to my eyes. These are just
  streams of logs, there's no reason for the extra newlines.

* Colorize the resource headers in the Diagnostic section light blue.

Note that this will change various test baselines, which I will
update next. I didn't want those in the same commit.
2018-09-24 08:43:46 -07:00
joeduffy 8643bfec22 Don't print redundant "previewing"/"updating" prelude
Now that we're showing SpecUnimportant as regular text, the extra
"Previewing"/"Updating" line that we show really stands out as being
superfluous. For example, we previously said:

    Updating stack 'docker-images'
    Performing changes:

        ...

This change eliminates that second line, so we just have:

    Updating stack 'docker-images':

        ...
2018-09-22 13:34:43 -07:00
Sean Gillespie 3d5f005c95
Fix several output-related issues ()
* Revert "Don't show stack outputs when update fails ()"

This reverts commit e3f89e82aa.

* Be more precise about printing outputs

This commit prints outputs only if they are known to be complete. This
avoids massive red diffs during previews and when component resources
fail to call registerResourceOutputs.

* CR: Clean up large boolean expression and comment

* CR: boolean compromise
2018-09-11 16:44:06 -07:00
joeduffy b1f7cf7050 Fix a few lint warnings 2018-09-05 08:25:23 -07:00
joeduffy bf51d7594a Refactor display logic out of pkg/backend/filestate
This simply refactors all the display logic out of the
pkg/backend/filestate package. This helps to gear us up to better unify
this logic between the filestate and httpstate backends.

Furthermore, this really ought to be in its own non-backend,
CLI-specific package, but I'm taking one step at a time here.
2018-09-05 07:33:18 -07:00