Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

internal/core: return error if type is ErrSentinel to signal exit codes #768

Merged
merged 2 commits into from
Nov 9, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion internal/cli/app_docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ func (c *AppDocsCommand) Run(args []string) int {
return c.builtinMDX(args)
}

c.DoApp(c.Ctx, func(ctx context.Context, app *clientpkg.App) error {
err = c.DoApp(c.Ctx, func(ctx context.Context, app *clientpkg.App) error {
docs, err := app.Docs(ctx, &pb.Job_DocsOp{})
if err != nil {
app.UI.Output(clierrors.Humanize(err), terminal.WithErrorStyle())
Expand Down Expand Up @@ -537,6 +537,9 @@ func (c *AppDocsCommand) Run(args []string) int {

return nil
})
if err != nil {
return 1
}

return 0
}
Expand Down
5 changes: 4 additions & 1 deletion internal/cli/artifact_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (c *ArtifactBuildCommand) Run(args []string) int {
return 1
}

c.DoApp(c.Ctx, func(ctx context.Context, app *clientpkg.App) error {
err := c.DoApp(c.Ctx, func(ctx context.Context, app *clientpkg.App) error {
_, err := app.Build(ctx, &pb.Job_BuildOp{
DisablePush: !c.flagPush,
})
Expand All @@ -39,6 +39,9 @@ func (c *ArtifactBuildCommand) Run(args []string) int {

return nil
})
if err != nil {
return 1
}

return 0
}
Expand Down
5 changes: 4 additions & 1 deletion internal/cli/artifact_push.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (c *ArtifactPushCommand) Run(args []string) int {

client := c.project.Client()

c.DoApp(c.Ctx, func(ctx context.Context, app *clientpkg.App) error {
err := c.DoApp(c.Ctx, func(ctx context.Context, app *clientpkg.App) error {
// Get the most recent build
build, err := client.GetLatestBuild(ctx, &pb.GetLatestBuildRequest{
Application: app.Ref(),
Expand All @@ -50,6 +50,9 @@ func (c *ArtifactPushCommand) Run(args []string) int {

return nil
})
if err != nil {
return 1
}

return 0
}
Expand Down
5 changes: 4 additions & 1 deletion internal/cli/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func (c *baseCommand) Init(opts ...Option) error {
// thread-safe.
//
// If any error is returned, the caller should just exit. The error handling
// including messaging to the user is handling by this function call.
// including messaging to the user is handled by this function call.
//
// If you want to early exit all the running functions, you should use
// the callback closure properties to cancel the passed in context. This
Expand Down Expand Up @@ -306,6 +306,9 @@ func (c *baseCommand) DoApp(ctx context.Context, f func(context.Context, *client
if err := f(ctx, app); err != nil {
if err != ErrSentinel {
finalErr = multierror.Append(finalErr, err)
} else {
// if we have an ErrSentinel here, we've already output info to the UI
return err
krantzinator marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion internal/cli/deployment_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (c *DeploymentCreateCommand) Run(args []string) int {

client := c.project.Client()

c.DoApp(c.Ctx, func(ctx context.Context, app *clientpkg.App) error {
err := c.DoApp(c.Ctx, func(ctx context.Context, app *clientpkg.App) error {
// Get the most recent pushed artifact
push, err := client.GetLatestPushedArtifact(ctx, &pb.GetLatestPushedArtifactRequest{
Application: app.Ref(),
Expand Down Expand Up @@ -106,6 +106,9 @@ func (c *DeploymentCreateCommand) Run(args []string) int {

return nil
})
if err != nil {
return 1
}

return 0
}
Expand Down
2 changes: 1 addition & 1 deletion internal/core/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (a *App) doOperation(
log.Warn("error running before hook", "err", err)

if h.ContinueOnFailure() {
log.Info("hook configured to continueon failure, ignoring error")
log.Info("hook configured to continue on failure, ignoring error")
doErr = nil
}
}
Expand Down