make kompose exit with 1 if error (#1343)

Old code passes -1 to os.Exit and the value is directly passed to syscall.
The behavior with -1 depends on environments (most cases should convert
into 255 though)

This commit is to remove unnecessary the ambiguity and change it to use 1 instead of 255.
This commit is contained in:
namusyaka
2020-11-04 08:24:52 +08:00
committed by GitHub
parent ee3ae26198
commit 45864ed624
2 changed files with 13 additions and 10 deletions
+4 -8
View File
@@ -17,8 +17,6 @@ limitations under the License.
package cmd
import (
"fmt"
"os"
"strings"
log "github.com/sirupsen/logrus"
@@ -87,12 +85,10 @@ var RootCmd = &cobra.Command{
},
}
// Execute TODO: comment
func Execute() {
if err := RootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(-1)
}
// Execute executes the root level command.
// It returns an erorr if any.
func Execute() error {
return RootCmd.Execute()
}
func init() {
+9 -2
View File
@@ -16,8 +16,15 @@ limitations under the License.
package main
import "github.com/kubernetes/kompose/cmd"
import (
"log"
"github.com/kubernetes/kompose/cmd"
)
func main() {
cmd.Execute()
if err := cmd.Execute(); err != nil {
log.SetFlags(0)
log.Fatal(err)
}
}