-
Notifications
You must be signed in to change notification settings - Fork 226
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
Enable non-zero-exit in case of an error while running "build" #195
Conversation
Signed-off-by: Nenad Ilic <nenadilic84@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see the errors triggered in the comments here. Also does this work if the Docker build fails.
@alexellis, not sure if I know what you mean by
|
You tested one of the error conditions. I'd like you to run each error scenario and show that it triggers the exit code we want. @itscaro may also be able to help show to extend the tests to pick up the exit code automatically. |
commands/build.go
Outdated
@@ -80,27 +79,26 @@ func runBuild(cmd *cobra.Command, args []string) { | |||
} | |||
|
|||
if pullErr := PullTemplates(""); pullErr != nil { | |||
log.Fatalln("Could not pull templates for OpenFaaS.", pullErr) | |||
log.Fatalf("Could not pull templates for OpenFaaS.") | |||
return pullErr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Fatalf will probably cause an exit here. Let's use a combined error message with fmt.Errorf of pullErr and our custom message and return it as the error.
@@ -44,7 +45,9 @@ func init() { | |||
func Execute(customArgs []string) { | |||
faasCmd.SilenceUsage = true | |||
faasCmd.SetArgs(customArgs[1:]) | |||
faasCmd.Execute() | |||
if err := faasCmd.Execute(); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a great start, we just need a few tweaks and I'll merge. When do you think you can have it done by?
Pinging @itscaro to suggest how to test the exit code from the CLI integration tests. |
Will push the changes probably till the end of the day... |
Signed-off-by: Nenad Ilic <nenadilic84@gmail.com>
caf0d4f
to
094761d
Compare
Signed-off-by: Nenad Ilic <nenadilic84@gmail.com>
094761d
to
b1ccf9a
Compare
@alexellis, update the PR and added some tests... Let me know if you have something else in mind |
I think we can merge this now. Not 100% on the tests. I think it's hard to test but we only have the negative cases not a positive one. Ideally want both. |
@alexellis, not sure what you mean? Should I add more tests for the |
There is only a test that shows the negative case (exit code non-zero) - we need a test to show positive case of (exit code zero). |
Merging work so far, thank you 👍 |
Description
Motivation and Context
Resolves the issue: Refactoring: Return non-zero exit codes for error conditions #183
How Has This Been Tested?
Types of changes
Checklist:
git commit -s