pulumi/pkg/cmd/pulumi
Will Jones 738f5b4e4e
Centralise human-friendly error handling in the CLI (#17046)
Presently, all Pulumi CLI commands expose their "run" functions through
`cmdutils.RunFunc`. `RunFunc` wraps the function it is given with some
generic error handling, namely checking if an error is expected (i.e. a
"bail") or not before deciding on an appropriate exit code and logging
as appropriate.

Alongside this, some commands make use of the `PrintEngineResult` helper
function, which spots `DecryptError`s specifically and prints out some
helpful suggestions in the event that such an error occurs. On the
surface, `PrintEngineResult` looks like a good place to solve #16950, in
which we'd like to add a similar feature for snapshot integrity errors
-- that is, spotting when they occur and providing a custom error
message to the user (in this case indicating that they should file an
issue).

Unfortunately, `PrintEngineResult` isn't called for _all_ errors within
a command handler's run function. That said, there's no reason why it
couldn't be, since while it's not generally possible for `DecryptError`s
(the only case handled currently) to crop up in other calls in the
function, we'd like to print the nice message if they ever do. This
commit thus ensures that (a renamed) `PrintEngineResult` is called on
all errors within a command's run function by introducing `runCmdFunc`,
which wraps `cmdutil.RunFunc` specifically for the Pulumi CLI,
inspecting all errors that may appear and printing human-friendly
replacement texts as appropriate. This sets us up for the solution to
issue #16950, where we'll introduce a custom error type for snapshot
integrity errors and then spot this in the new top-level Pulumi CLI
error handler (well, that's the idea at least 🤞).

*Note*: we don't change `cmdutil.RunFunc` itself since currently it
lives in `sdk/go/common` which means that presumably it could be
consumed elsewhere and thus shouldn't contain Pulumi-CLI-specific
things.
2024-08-23 08:48:42 +00:00
..
convert_testdata Refactor convert command to add entrypoint for pulumi convert debugging 2022-10-01 15:40:17 -07:00
pcl_convert_testdata Support PCL as a convert input (and output) 2022-11-11 10:45:40 +00:00
testdata policy publish: default to default-org if possible (#14090) 2023-10-05 16:51:06 +00:00
about.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
about_env.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
about_test.go Move about information to language plugins (#10392) 2022-08-15 14:55:04 +01:00
ai.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
ai_web.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
cancel.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
config.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
config_env.go Fix non-interactive flag for 'new' and 'config env' commands (#16338) 2024-06-06 14:16:45 +00:00
config_env_add.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
config_env_add_test.go Fix TestConfigEnvXXX flakes (#16496) 2024-06-27 03:48:41 +00:00
config_env_init.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
config_env_init_test.go Fix TestConfigEnvXXX flakes (#16496) 2024-06-27 03:48:41 +00:00
config_env_ls.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
config_env_ls_test.go Fix TestConfigEnvXXX flakes (#16496) 2024-06-27 03:48:41 +00:00
config_env_rm.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
config_env_rm_test.go Fix TestConfigEnvXXX flakes (#16496) 2024-06-27 03:48:41 +00:00
config_env_test.go Fix TestConfigEnvXXX flakes (#16496) 2024-06-27 03:48:41 +00:00
config_test.go Lift context parameter for ApplyProjectConfig (#16012) 2024-04-22 06:37:34 +00:00
console.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
convert-trace.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
convert.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
convert_test.go Allow specifying project names with `pulumi convert` (#16708) 2024-07-19 10:57:14 +00:00
crypto.go Fix TestDestroySetsEncryptionsalt test and resulting bug (#15432) 2024-02-15 09:33:27 +00:00
deployment_run.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
deployment_settings_config.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
deployment_settings_config_test.go Add support for public bare git repos on deployment settings (#16907) 2024-08-07 20:05:41 +00:00
deployment_settings_ops.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
deployment_settings_utils.go Add deployment settings tests, cleanup and better handling of non interactive sessions (#16677) 2024-07-30 19:21:26 +00:00
deployment_settings_utils_test.go Fix deployment settings serialization and keys consistency (#16904) 2024-08-12 19:28:13 +00:00
destroy.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
doc.go Document Go packages (#6009) 2021-01-11 11:07:59 -07:00
env.go [cli] Include config from ESC in `pulumi config` (#14560) 2023-11-21 10:44:45 +00:00
errors.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
flags_test.go Set the --continue-on-error flag with PULUMI_CONTINUE_ON_ERROR environment variable (#16442) 2024-06-25 08:28:37 +00:00
gen_completion.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
gen_markdown.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
import.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
import_test.go Add a missing test for the import system (#15664) 2024-03-13 14:13:36 +00:00
install.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
login.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
logout.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
logs.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
logs_test.go Use `assert.NoError` rather than `assert.Nil` (#14233) 2023-10-13 09:46:07 +00:00
main.go avoid duplicate error output in some cases (#16706) 2024-07-19 08:00:51 +00:00
new.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
new_acceptance_test.go new: capitalize prompts consistently (#16747) 2024-07-24 07:56:18 +00:00
new_ai.go upgrade to latest version of golangci-lint (#15977) 2024-04-19 06:20:33 +00:00
new_ai_test.go Fix AI prompt repetition on Windows (#15010) 2024-01-03 23:03:11 +00:00
new_test.go new: capitalize prompts consistently (#16747) 2024-07-24 07:56:18 +00:00
org.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
org_search.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
org_search_ai.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
org_search_ai_test.go Replace some more uses of assert.Contains(err.Error()) with assert.ErrorContains (#14863) 2023-12-15 17:45:32 +00:00
org_search_test.go Enable perfsprint linter (#14813) 2023-12-12 12:19:42 +00:00
package.go Introduce the `pulumi package add` command (#16923) 2024-08-09 12:45:32 +00:00
package_add.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
package_extract_mapping.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
package_extract_schema.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
package_gen_sdk.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
package_pack_sdk.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
package_publish.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
plugin.go Add `plugin run` command (#12613) 2024-02-05 08:35:48 +00:00
plugin_install.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
plugin_install_test.go Refactor: move plugin kind to apitype (#15946) 2024-04-25 17:30:30 +00:00
plugin_ls.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
plugin_rm.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
plugin_run.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
policy.go [breaking] Changing the version of go.mod in sdk / pkg to be v3 2021-04-14 19:32:18 +01:00
policy_disable.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
policy_enable.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
policy_group_ls.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
policy_ls.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
policy_new.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
policy_new_acceptance_test.go Use context.Background in tests (#14029) 2023-09-25 12:25:26 +00:00
policy_new_test.go Use context.Background in tests (#14029) 2023-09-25 12:25:26 +00:00
policy_publish.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
policy_publish_test.go Replace `result.Result` with native errors (#17044) 2024-08-22 14:39:59 +00:00
policy_rm.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
policy_validate.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
preview.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
preview_test.go Fix hang in --preview-file (#15203) 2024-01-25 18:03:38 +00:00
pulumi.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
pulumi_test.go correct version check when we have a dev version installed (#14954) 2023-12-22 16:40:12 +00:00
query.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
refresh.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
replay_events.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
schema.go [codegen/schema] Add a schema checker (#7865) 2021-08-30 19:29:24 -07:00
schema_check.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
stack.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
stack_change_secrets_provider.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
stack_change_secrets_provider_test.go Lift context parameter to SerializeDeployment/Resource/Operations/Properties (#15929) 2024-04-15 07:45:46 +00:00
stack_export.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
stack_graph.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
stack_graph_test.go Adds a flag to graph command to insert fragment (#14858) 2024-01-08 22:03:08 +00:00
stack_history.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
stack_import.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
stack_init.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
stack_init_test.go service to cloud 2023-04-08 09:49:37 -07:00
stack_ls.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
stack_ls_test.go [test] fix `TestCreatingProjectWithEmptyConfig` flakiness (#14777) 2023-12-08 23:00:49 +00:00
stack_output.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
stack_output_fuzz_test.go cli/stack-ouput/test: Fix Powershell test failures 2023-01-30 07:58:47 -08:00
stack_output_test.go fix(cli/stack output): Don't escape HTML characters 2023-06-23 09:11:20 -07:00
stack_rename.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
stack_rm.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
stack_select.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
stack_tag.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
stack_test.go Show a fully qualified stack name in `pulumi stack --show-name -Q` (#16453) 2024-06-26 09:00:22 +00:00
stack_unselect.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
state.go implement skeleton command for `pulumi state move` (#16493) 2024-06-28 09:43:19 +00:00
state_delete.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
state_edit.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
state_edit_encoder.go Lift context parameter to SerializeDeployment/Resource/Operations/Properties (#15929) 2024-04-15 07:45:46 +00:00
state_edit_test.go Fix context in state edit command (#15354) 2024-02-07 09:01:56 +00:00
state_move.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
state_move_test.go state_move: set up a secret manager in the dest stack if it doesn't exist (#16844) 2024-08-02 13:59:15 +00:00
state_rename.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
state_rename_test.go Allow anything in resource names (#14107) 2023-11-20 08:59:00 +00:00
state_unprotect.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
state_upgrade.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
state_upgrade_test.go Add --yes to state upgrade (#15648) 2024-03-12 19:57:41 +00:00
terminal.go crypto/ssh/terminal is deprecated 2023-01-12 09:07:34 -08:00
terminal_test.go Fix negative page size panic (#10475) 2022-08-23 16:45:47 -04:00
up.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
up_test.go all: Reformat with gofumpt 2023-03-03 09:00:24 -08:00
util.go Install missing python versions using pyenv during installation (#16855) 2024-08-19 15:55:54 +00:00
util_remote.go Replace `result.Result` with native errors (#17044) 2024-08-22 14:39:59 +00:00
util_remote_test.go [cli] Experimental support for remote operations 2022-10-27 16:15:59 -07:00
util_test.go chore: fix function names in comment (#16044) 2024-04-24 06:23:35 +00:00
version.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
view-trace.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
watch.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
whoami.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
whoami_test.go Fix panic in whoami (#14108) 2023-10-06 16:56:36 +00:00