mirror of https://github.com/pulumi/pulumi.git
738f5b4e4e
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. |
||
---|---|---|
.. | ||
lifecycletest | ||
combinedManager.go | ||
deployment.go | ||
deployment_test.go | ||
destroy.go | ||
detailedDiff.go | ||
detailedDiff_test.go | ||
doc.go | ||
engine.go | ||
errors.go | ||
events.go | ||
events_test.go | ||
eventsink.go | ||
import.go | ||
journal.go | ||
plugin_host.go | ||
plugins.go | ||
plugins_test.go | ||
project.go | ||
query.go | ||
refresh.go | ||
snapshot.go | ||
update.go | ||
update_test.go |