Turn on the golangci-lint exhaustive linter. This is the first step
towards catching more missing cases during development rather than
in tests, or in production.
This might be best reviewed commit-by-commit, as the first commit turns
on the linter with the `default-signifies-exhaustive: true` option set,
which requires a lot less changes in the current codebase.
I think it's probably worth doing the second commit as well, as that
will get us the real benefits, even though we end up with a little bit
more churn. However it means all the `switch` statements are covered,
which isn't the case after the first commit, since we do have a lot of
`default` statements that just call `assert.Fail`.
Fixes#14601
## 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
- [x] 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. -->
<!---
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. -->
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.
Similar to how https://github.com/pulumi/pulumi/pull/13953 moves some
code from sdk/go/common to /pkg. This display code is only used in /pkg,
another simple reduction of what's in sdk/go/common.
<!---
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. -->
Replaces most instances of bail results outside the core engine with
BailErorr instead.
The only parts of the codebase still using `result.Bail()` are in
pkg/resource/deploy.
## 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. -->
Fixes https://github.com/pulumi/pulumi/issues/12738https://github.com/pulumi/pulumi/pull/11834 turned on the prealloc
linter and changed a load of slice uses from just `var x T[]` to `x :=
make([]T, 0, preallocSize)`. This was good for performance but it turns
out there are a number of places in the codebase that treat a `nil`
slice as semnatically different to an empty slice.
Trying to test that, or even reason that through for every callsite is
untractable, so this PR replaces all expressions of the form `make([]T,
0, size)` with a call to `slice.Prealloc[T](size)`. When size is 0 that
returns a nil array, rather than an empty array.
Retain on delete currently applies to replaces and deletes. It is
unclear when a resource is retained on delete. To clarify this, this
commit:
- Improves update status messages with "[retain]"
to clarify when a resource is retained on delete and dropped.
- Adds info warning on preview as to which resources will be dropped in the cloud environment.
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.
Incremental step towards #12132
Migrates uses of contract.{Assert, AssertNoError, Require} in pkg/engine
to `*f` variants so that we're required to provide more error context.
Refs #12132
For the options presented in the 'Do you want to perform this update?'
dialog, move the experimental option to the bottom.
Before:
```
Do you want to perform this update? [Use arrows to move, type to filter]
[experimental] yes, using Update Plans (https://pulumi.com/updateplans)
yes
> no
details
```
Now:
```
Do you want to perform this update? [Use arrows to move, type to filter]
yes
> no
details
[experimental] yes, using Update Plans (https://pulumi.com/updateplans)
```
Resolves#11800
11118: ci: Update post-release PR to align with release process r=AaronFriel a=AaronFriel
As the release process now includes a "freeze PR" which updates `.version` _prior_ to release, the post-release PR shouldn't attempt to make the same change, as it causes a merge conflict.
This removes the notion of "next-version" from the CI scripts, as that post-release PR was the only place it was used.
The post-release PR can also be auto-merged, so `queue-merge` is set to true.
11249: ci: Reduce Windows test parallelism r=AaronFriel a=AaronFriel
Increases likelihood of CI passing on Windows due to longstanding CPU exhaustion bug on runners. (GitHub support ticket 1791026 on my account.)
11284: Make convert's pcl output yaml agnostic r=Frassle a=Frassle
<!---
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. -->
We're going to use convert for more data sources than just YAML (e.g. hcl, arm, etc). So we don't want the PCL output option to be YAML specific given it should be usable for any input source.
11288: [cli] Update the survey module r=pgavlin a=pgavlin
Pick up the bugfix to https://github.com/AlecAivazis/survey/issues/228.
This also provides a cleaner API for setting survey icons.
11289: [cli] Add a newline in the refresh confirmation prompt r=pgavlin a=pgavlin
The lack of a newline causes the prompt to wrap in terminals that are fewer than 120 or so columns wide. The wrapping confuses the survey package's redraw, which causes the repeated prompts each time the survey is redrawn (i.e. on every keypress). Removing the wrapping by adding a newline avoids this issue.
Co-authored-by: Aaron Friel <mayreply@aaronfriel.com>
Co-authored-by: Fraser Waters <fraser@pulumi.com>
Co-authored-by: Pat Gavlin <pat@pulumi.com>
The lack of a newline causes the prompt to wrap in terminals that are
fewer than 120 or so columns wide. The wrapping confuses the survey
package's redraw, which causes the repeated prompts each time the survey
is redrawn (i.e. on every keypress). Removing the wrapping by adding a
newline avoids this issue.
This threads a new option "Experimental" through to the engine which is
used to decided if plans should be used or not. This also generates
plans for any preview with --save-plan, but also now generates plans
during the preview phase of up.
This PR provides an INFO message to indicate to users if the update that they are trying to run is not deploying any resources(other than the `pulumi:pulumi:Stack` resource).
* Moving previewDigest and exporting it, closes#9851
* Moving previewDigest and exporting it, closes#9851
* Updating changelog-pending
* Go Mod Tidy
* replacing to local
* more go.mod changes
* reseting go mod
* full move
* Fixing golint
* No go.mod changes needed
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.
* Implement resource plans in the engine
* Plumb plans through the CLI.
* Update wording
* plan renderer
* constraints
* Renames
* Update message
* fixes for rebase breaks and diffs
* WIP: outputs in plans
* fix diff
* fixup
* Liniting and test fixing
* Test and fix PropertyPath.String()
* Fix colors
* Fix cmdutil.PrintTable to handle non-simple strings
* More tests
* Readd test_plan.go
* lint
* Test expected deletes
* Test expected delete
* Test missing create
* Fix test for missing creates
* rm Paths()
* property set shrink test
* notes
* More tests
* Pop op before constraint check
* Delete plan cmd, rename arguments to preview and up
* Hide behind envvars
* typo
* Better constraint diffs
* Adds/Deletes/Updates
* Fix aliased
* Check more constraints
* fix test
* revert stack changes
* Resource sames test
* Fix same resource test
* Fix more tests
* linting
* Update pkg/cmd/pulumi/up.go
Co-authored-by: Alex Mullans <a.mullans@pulumi.com>
* Update pkg/cmd/pulumi/preview.go
Co-authored-by: Alex Mullans <a.mullans@pulumi.com>
* Auto refresh if using plans
* Fix TestGetRefreshOption
* Fix TestExplicitDeleteBeforeReplace
* lint
* More copying in tests because I do not trust myself to get mutation correct
* Small preview plan test
* Add TestPlannedUpdateChangedStack
* Revert auto-refresh changes
* Validate outputs don't change
* omitempty
* Add manifest to plan
* Add proper Plan type
* wip config work
* Config and manifest serder
* linting
* Asset NoError
* Actually check error
* Fix clone
* Test diag message
* Start on more tests
* Add String and GoString to Result
I got fed up assert errors in tests that looked like:
```
Expected nil, but got: &result.simpleResult{err:(*errors.fundamental)(0xc0002fa5d0)}
```
It was very hard to work out at a glance what had gone wrong and I kept
having to hook a debugger just to look at what the error was.
With GoString these now print something like:
```
Expected nil, but got: &simpleResult{err: Unexpected diag message: <{%reset%}>resource violates plan: properties changed: -zed, -baz, -foo<{%reset%}>
}
```
Which is much more ussful.
* Add test error text
* Fix reporting of unseen op errors
* Fix unneeded deletes
* Fix unexpected deletes
* Fix up tests
* Fix merge conflict
* lint
* Fix nil map error
* Fix serialisation typo
* Diff against old inputs
* Diff against checked goal
* Diff against empty for creates
* Fix test
* inputs not outputs
* Seperate PlanDiff type
* Add properties
* Fix input diffs
* Handle creates
* lint
* Add plan message
* Clone plan for update preview
* Save and serialise env vars in plans
* lint
* pretty print json
* input output difference test
* test alias
* fix typo in for loop
* Handle resource plans with nil goal
* go mod tidy
* typo
* Auto use plans from up previews in experimental mode
* Don't preview if we have plan
* Don't run previews with plans now
* fixing tests
* Handle diffs and goals
* Update copystructure
* tests/go.sum
* Revert mod changes
* Add copystructure to tests/go.sum
* includeUnknowns
* go mod tidy
* Make plans for imports
* Remove unused function
* Move code more locally
* Handle nil in serialize
* Handle empty output diffs
* Add test for dropping computed values
* Allow computed properties to become deletes
* if out the generation of plans unless experimental mode is opt'd into
* lint
* typo
* Revert back to plans not skipping previews, this is orthognal to --skip-preview
* Trying to work out non-determinism
* Remove notes.txt
* Hacking with check idea
* Pass checked inputs back to Check from plan file
* Include resource urn in constraint error
* Give much more informative errors when plans fail
* lint
* Update expected diag strings in tests
* Remove unused code
* Duplicate Diff and DeepEquals methods for plans
* Add comment about check ops with failures
* Fix CheckedInputs comment
* OutputDiff doesn't need to be a pointer
* Fix checks against computed
* diffStringSets
* lint
* lint pkg
* Use 4 space indent
* Don't wrap Buffer in Writer
* Mark flags hidden rather than disabled
* Remove envvars from plans
* Assert MarkHidden error
* Add to changelog
* Note plan/save-plan is experimental
Co-authored-by: Pat Gavlin <pat@pulumi.com>
Co-authored-by: Alex Mullans <a.mullans@pulumi.com>
* Make `async:true` the default for `invoke` calls (#3750)
* Switch away from native grpc impl. (#3728)
* Remove usage of the 'deasync' library from @pulumi/pulumi. (#3752)
* Only retry as long as we get unavailable back. Anything else continues. (#3769)
* Handle all errors for now. (#3781)
* Do not assume --yes was present when using pulumi in non-interactive mode (#3793)
* Upgrade all paths for sdk and pkg to v2
* Backport C# invoke classes and other recent gen changes (#4288)
Adjust C# generation
* Replace IDeployment with a sealed class (#4318)
Replace IDeployment with a sealed class
* .NET: default to args subtype rather than Args.Empty (#4320)
* 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 (#4379)
Use `result.Result` in more places, so when a confirmation prompt is
declined, we just return `result.Bail()` after printing a message
without the `error: ` prefix.
Fixes#2070
If you took the time to type out `--skip-preview`, we should have high
confidence that you don't want a preview and you're okay with the
operation just happening without a prompt.
Fixes#1448
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.
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':
...