Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow mixins to ignore a failed command #1846

Merged
merged 2 commits into from
Jan 7, 2022

Conversation

carolynvs
Copy link
Member

@carolynvs carolynvs commented Jan 4, 2022

What does this change

Add the HasErrorHandling interface to the shared pkg/exec/builder
package used by all the mixins. When implemented, a mixin can examine a
failed command and optionally handle it.

The exec mixin now supports ignoring failed commands, which demonstrates
how to use builder.IgnoreErrorHandler struct to use the same error
handling behavior.

Here is the updated doc for the exec mixin: https://deploy-preview-1846--porter.netlify.app/mixins/exec/. I have added comments to the sample yaml config, and a section about ignoring errors.

What issue does it fix

Closes #592

Notes for the reviewer

I am working on a PR for the az mixin that uses this to make resource groups and handle errors when it already exists. getporter/az-mixin#34

Checklist

  • Unit Tests
  • Documentation
  • Schema (porter.yaml)

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
@@ -71,6 +71,8 @@ func NewTestCommand(c *Context) CommandBuilder {
cmd.Env = []string{
fmt.Sprintf("%s=true", test.MockedCommandEnv),
fmt.Sprintf("%s=%s", test.ExpectedCommandEnv, c.Getenv(test.ExpectedCommandEnv)),
fmt.Sprintf("%s=%s", test.ExpectedCommandExitCodeEnv, c.Getenv(test.ExpectedCommandExitCodeEnv)),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added these so that we can simulate a command failing in our unit tests.

Add the HasErrorHandling interface to the shared pkg/exec/builder
package used by all the mixins. When implemented, a mixin can examine a
failed command and optionaly handle it.

The exec mixin now supports ignoring failed commands, which demonstrates
how to use builder.IgnoreErrorHandler struct to use the same error
handling behavior.

Closes getporter#592

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
@carolynvs
Copy link
Member Author

/azp run porter-integration

@carolynvs carolynvs marked this pull request as ready for review January 4, 2022 18:44
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants