camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject [camel-k] branch master updated: Fixes #515 Allow file names as delete cmd argument
Date Sun, 03 Mar 2019 14:05:27 GMT
This is an automated email from the ASF dual-hosted git repository.

acosentino 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 efffb00  Fixes #515 Allow file names as delete cmd argument
     new d530b04  Merge pull request #522 from christophd/fix/515/allow-filename-argument
efffb00 is described below

commit efffb00a3da4e95d4a39facda58d8baabc854140
Author: Christoph Deppisch <cdeppisch@redhat.com>
AuthorDate: Sun Mar 3 14:52:23 2019 +0100

    Fixes #515 Allow file names as delete cmd argument
---
 pkg/cmd/delete.go                    | 9 +++++----
 pkg/util/kubernetes/sanitize_test.go | 2 ++
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/pkg/cmd/delete.go b/pkg/cmd/delete.go
index 560b91e..a56eaee 100644
--- a/pkg/cmd/delete.go
+++ b/pkg/cmd/delete.go
@@ -23,6 +23,7 @@ import (
 	"strconv"
 
 	"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
+	"github.com/apache/camel-k/pkg/util/kubernetes"
 	"github.com/spf13/cobra"
 	k8errors "k8s.io/apimachinery/pkg/api/errors"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -77,16 +78,16 @@ func (command *deleteCmdOptions) run(args []string) error {
 	}
 	if len(args) != 0 && !command.deleteAll {
 		for _, arg := range args {
-
-			err := DeleteIntegration(command.Context, c, arg, command.Namespace)
+			name := kubernetes.SanitizeName(arg)
+			err := DeleteIntegration(command.Context, c, name, command.Namespace)
 			if err != nil {
 				if k8errors.IsNotFound(err) {
-					fmt.Println("Integration " + arg + " not found. Skipped.")
+					fmt.Println("Integration " + name + " not found. Skipped.")
 				} else {
 					return err
 				}
 			} else {
-				fmt.Println("Integration " + arg + " deleted")
+				fmt.Println("Integration " + name + " deleted")
 			}
 		}
 	} else if command.deleteAll {
diff --git a/pkg/util/kubernetes/sanitize_test.go b/pkg/util/kubernetes/sanitize_test.go
index 43078ae..608b612 100644
--- a/pkg/util/kubernetes/sanitize_test.go
+++ b/pkg/util/kubernetes/sanitize_test.go
@@ -27,6 +27,8 @@ func TestSanitizeName(t *testing.T) {
 		{"input": "/path/to/abc.js", "expect": "abc"},
 		{"input": "abc.xml", "expect": "abc"},
 		{"input": "./path/to/abc.kts", "expect": "abc"},
+		{"input": "fooToBar.groovy", "expect": "foo-to-bar"},
+		{"input": "foo-to-bar", "expect": "foo-to-bar"},
 	}
 
 	for _, c := range cases {


Mime
View raw message