You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2020/01/07 10:16:28 UTC
[camel-k] branch master updated: kamel run --wait should return
non-zero exit code in case of failure
This is an automated email from the ASF dual-hosted git repository.
nferraro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git
The following commit(s) were added to refs/heads/master by this push:
new 2eb3f4d kamel run --wait should return non-zero exit code in case of failure
2eb3f4d is described below
commit 2eb3f4d820026ebf8bbf3fafcbc026c31267c673
Author: James Netherton <ja...@gmail.com>
AuthorDate: Mon Jan 6 10:53:47 2020 +0000
kamel run --wait should return non-zero exit code in case of failure
fixes #1170
---
cmd/kamel/main.go | 3 ---
pkg/cmd/describe_integration.go | 3 ++-
pkg/cmd/describe_kit.go | 3 ++-
pkg/cmd/describe_platform.go | 3 ++-
pkg/cmd/log.go | 4 ++--
pkg/cmd/root.go | 1 +
pkg/cmd/run.go | 8 +++++---
7 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/cmd/kamel/main.go b/cmd/kamel/main.go
index 3402644..a9b9916 100644
--- a/cmd/kamel/main.go
+++ b/cmd/kamel/main.go
@@ -19,7 +19,6 @@ package main
import (
"context"
- "fmt"
"math/rand"
"os"
"time"
@@ -49,8 +48,6 @@ func main() {
func exitOnError(err error) {
if err != nil {
- fmt.Println("Error:", err)
-
os.Exit(1)
}
}
diff --git a/pkg/cmd/describe_integration.go b/pkg/cmd/describe_integration.go
index 8b9b31a..5438d94 100644
--- a/pkg/cmd/describe_integration.go
+++ b/pkg/cmd/describe_integration.go
@@ -18,6 +18,7 @@ limitations under the License.
package cmd
import (
+ "errors"
"fmt"
"io"
"strings"
@@ -66,7 +67,7 @@ type describeIntegrationCommandOptions struct {
func (command *describeIntegrationCommandOptions) validate(args []string) error {
if len(args) != 1 {
- return fmt.Errorf("accepts at least 1 arg, received %d", len(args))
+ return errors.New("describe expects an integration name argument")
}
return nil
}
diff --git a/pkg/cmd/describe_kit.go b/pkg/cmd/describe_kit.go
index e095851..11e9b7b 100644
--- a/pkg/cmd/describe_kit.go
+++ b/pkg/cmd/describe_kit.go
@@ -18,6 +18,7 @@ limitations under the License.
package cmd
import (
+ "errors"
"fmt"
"io"
@@ -59,7 +60,7 @@ type describeKitCommandOptions struct {
func (command *describeKitCommandOptions) validate(args []string) error {
if len(args) != 1 {
- return fmt.Errorf("accepts at least 1 arg, received %d", len(args))
+ return errors.New("describe expects a kit name argument")
}
return nil
}
diff --git a/pkg/cmd/describe_platform.go b/pkg/cmd/describe_platform.go
index d7d5b88..0778ca4 100644
--- a/pkg/cmd/describe_platform.go
+++ b/pkg/cmd/describe_platform.go
@@ -18,6 +18,7 @@ limitations under the License.
package cmd
import (
+ "errors"
"fmt"
"io"
@@ -59,7 +60,7 @@ type describePlatformCommandOptions struct {
func (command *describePlatformCommandOptions) validate(args []string) error {
if len(args) != 1 {
- return fmt.Errorf("accepts at least 1 arg, received %d", len(args))
+ return errors.New("describe expects a platform name argument")
}
return nil
}
diff --git a/pkg/cmd/log.go b/pkg/cmd/log.go
index ce78985..8378c37 100644
--- a/pkg/cmd/log.go
+++ b/pkg/cmd/log.go
@@ -18,7 +18,7 @@ limitations under the License.
package cmd
import (
- "fmt"
+ "errors"
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
k8slog "github.com/apache/camel-k/pkg/util/kubernetes/log"
@@ -53,7 +53,7 @@ type logCmdOptions struct {
func (o *logCmdOptions) validate(_ *cobra.Command, args []string) error {
if len(args) != 1 {
- return fmt.Errorf("accepts 1 arg, received %d", len(args))
+ return errors.New("log expects an integration name argument")
}
return nil
diff --git a/pkg/cmd/root.go b/pkg/cmd/root.go
index 8f1450c..699d3cd 100644
--- a/pkg/cmd/root.go
+++ b/pkg/cmd/root.go
@@ -63,6 +63,7 @@ func kamelPreAddCommandInit(options *RootCmdOptions) *cobra.Command {
Use: "kamel",
Short: "Kamel is a awesome client tool for running Apache Camel integrations natively on Kubernetes",
Long: kamelCommandLongDescription,
+ SilenceUsage: true,
}
cmd.PersistentFlags().StringVar(&options.KubeConfig, "config", os.Getenv("KUBECONFIG"), "Path to the config file to use for CLI requests")
diff --git a/pkg/cmd/run.go b/pkg/cmd/run.go
index 83572a8..60f6896 100644
--- a/pkg/cmd/run.go
+++ b/pkg/cmd/run.go
@@ -120,7 +120,7 @@ type runCmdOptions struct {
func (o *runCmdOptions) validateArgs(_ *cobra.Command, args []string) error {
if len(args) < 1 {
- return errors.New("accepts at least 1 arg, received 0")
+ return errors.New("run expects at least 1 argument, received 0")
}
if len(args) > 1 && o.IntegrationName == "" {
return errors.New("integration name is mandatory when using multiple sources")
@@ -207,8 +207,11 @@ func (o *runCmdOptions) run(cmd *cobra.Command, args []string) error {
return err
}
- if integrationPhase == nil || *integrationPhase == v1.IntegrationPhaseRunning || *integrationPhase == v1.IntegrationPhaseError {
+ if *integrationPhase == v1.IntegrationPhaseRunning {
+ fmt.Println("Running")
break
+ } else if integrationPhase == nil || *integrationPhase == v1.IntegrationPhaseError {
+ return fmt.Errorf("integration \"%s\" deployment failed", integration.Name)
}
// The integration watch timed out so recreate it using the latest integration resource version
@@ -254,7 +257,6 @@ func (o *runCmdOptions) waitForIntegrationReady(integration *v1.Integration) (*v
}
if i.Status.Phase == v1.IntegrationPhaseError {
- fmt.Println("integration deployment failed")
return false
}
}