about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--main.go24
1 files changed, 20 insertions, 4 deletions
diff --git a/main.go b/main.go
index 0fcf93d66ef6..3a0febbb0a39 100644
--- a/main.go
+++ b/main.go
@@ -98,25 +98,36 @@ func applyCommand() {
 		kubectlArgs = []string{"apply", "-f", "-"}
 	}
 
-	runKubectlWithResources(ctx, &kubectlArgs, resources)
+	if err := runKubectlWithResources(ctx, &kubectlArgs, resources); err != nil {
+		failWithKubectlError(err)
+	}
 }
 
 func replaceCommand() {
 	ctx, resources := loadContextAndResources(replaceFile)
 	args := []string{"replace", "--save-config=true", "-f", "-"}
-	runKubectlWithResources(ctx, &args, resources)
+
+	if err := runKubectlWithResources(ctx, &args, resources); err != nil {
+		failWithKubectlError(err)
+	}
 }
 
 func deleteCommand() {
 	ctx, resources := loadContextAndResources(deleteFile)
 	args := []string{"delete", "-f", "-"}
-	runKubectlWithResources(ctx, &args, resources)
+
+	if err := runKubectlWithResources(ctx, &args, resources); err != nil {
+		failWithKubectlError(err)
+	}
 }
 
 func createCommand() {
 	ctx, resources := loadContextAndResources(createFile)
 	args := []string{"create", "--save-config=true", "-f", "-"}
-	runKubectlWithResources(ctx, &args, resources)
+
+	if err := runKubectlWithResources(ctx, &args, resources); err != nil {
+		failWithKubectlError(err)
+	}
 }
 
 func loadContextAndResources(file *string) (*context.Context, *[]string) {
@@ -157,3 +168,8 @@ func runKubectlWithResources(c *context.Context, kubectlArgs *[]string, resource
 
 	return kubectl.Wait()
 }
+
+func failWithKubectlError(err error) {
+	fmt.Errorf("Kubectl error: %v\n", err)
+	os.Exit(1)
+}