Propagate errors on deployment failures

We were not propagating the error from `deployLatest` through
to the CLI error result.  Despite out recent efforts to integrate
gometalinter, there were also several additional similar cases of
ignored error results reported by `errcheck`.  Not yet clear why
these are not being reported via gometalinter.

Fixes #262.
This commit is contained in:
Luke Hoban 2017-06-21 22:02:57 -07:00
parent 72bb2b2309
commit a63efc42a3
6 changed files with 16 additions and 6 deletions

1
.gitignore vendored
View file

@ -1,4 +1,5 @@
*.swp
/mu
/vendor/
/.vscode/

View file

@ -62,7 +62,7 @@ func newDeployCmd() *cobra.Command {
if err != nil {
return err
}
deployLatest(cmd, info, deployOptions{
err = deployLatest(cmd, info, deployOptions{
Destroy: false,
DryRun: dryRun,
Analyzers: analyzers,
@ -73,7 +73,7 @@ func newDeployCmd() *cobra.Command {
Summary: summary,
Output: output,
})
return nil
return err
}),
}

View file

@ -46,11 +46,14 @@ func newDestroyCmd() *cobra.Command {
name := info.Target.Name
if dryRun || yes ||
confirmPrompt("This will permanently destroy all resources in the '%v' environment!", name) {
deployLatest(cmd, info, deployOptions{
err = deployLatest(cmd, info, deployOptions{
Destroy: true,
DryRun: dryRun,
Summary: summary,
})
if err != nil {
return err
}
}
return nil
}),

View file

@ -220,7 +220,9 @@ func removeTarget(env *deploy.Target) {
// simply renames the file, which is simpler, more efficient, etc.
func backupTarget(file string) {
contract.Require(file != "", "file")
os.Rename(file, file+".bak") // ignore errors.
if err := os.Rename(file, file+".bak"); err != nil {
// ignore errors.
}
// IDEA: consider multiple backups (.bak.bak.bak...etc).
}

View file

@ -62,7 +62,9 @@ func newPackEvalCmd() *cobra.Command {
if err != nil {
return err
}
deploy.InitEvalConfig(result.B.Ctx(), e, envInfo.Target.Config)
if err := deploy.InitEvalConfig(result.B.Ctx(), e, envInfo.Target.Config); err != nil {
return err
}
}
// Finally, execute the entire program, and serialize the return value (if any).

View file

@ -100,7 +100,9 @@ func (src *evalSource) Iterate() (SourceIterator, error) {
src.plugctx.SetCurrentInterpreter(e)
// Now create the evaluator coroutine and prepare it to take its first step.
forkEval(src, rz, e)
if err := forkEval(src, rz, e); err != nil {
return nil, err
}
// Finally, return the fresh iterator that can take things from here.
return &evalSourceIterator{