-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add dagger helpers pkg (#56)
* move fail container to internal/dagger/helpers pkg * make impl consistent
- Loading branch information
Showing
7 changed files
with
182 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package helpers | ||
|
||
import ( | ||
"context" | ||
|
||
"dagger.io/dagger" | ||
) | ||
|
||
// FailPipeline returns a container that immediately fails with the given error. This useful for forcing a pipeline to | ||
// fail inside chaining operations. | ||
func FailPipeline(container *dagger.Container, err error) *dagger.Container { | ||
// fail the container with the given error | ||
container = container.WithExec([]string{"sh", "-c", "echo " + err.Error() + " && exit 1"}) | ||
|
||
// forced evaluation of the pipeline to immediately fail | ||
container, _ = container.Sync(context.Background()) | ||
|
||
return container | ||
} | ||
|
||
// WithContainerFuncHook is an interface that ensures that implementers have a WithContainerFunc method. | ||
type WithContainerFuncHook interface { | ||
// WithContainerFunc returns a dagger function that allows the user to modify the container. | ||
WithContainerFunc() dagger.WithContainerFunc | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.