From efffb00a3da4e95d4a39facda58d8baabc854140 Mon Sep 17 00:00:00 2001 From: Christoph Deppisch Date: Sun, 3 Mar 2019 14:52:23 +0100 Subject: [PATCH] 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 560b91e747..a56eaee83b 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 43078ae820..608b612483 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 {