This is an automated email from the ASF dual-hosted git repository.

tsato pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git


The following commit(s) were added to refs/heads/main by this push:
     new db2e7e5e5 feat(cli): Add autocomplete on integrations, kits, kamelets 
commands
db2e7e5e5 is described below

commit db2e7e5e5f95aeba4cfaca72480d39a10482ffb3
Author: Gaelle Fournier <[email protected]>
AuthorDate: Tue Dec 13 14:00:30 2022 +0100

    feat(cli): Add autocomplete on integrations, kits, kamelets commands
    
    * kamel get / kamel delete autocompletes on integrations
    * kamel get kit autocompletes on all kits
    * kamel delete kit autocompletes on non-platform kits
    * kamel kamelet delete autocompletes on non-readonly and non-bundled 
kamelets
    * kamel describe kamelet autocompletes on all kamelets
    
    Closes #3628
---
 pkg/cmd/completion_bash.go | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/pkg/cmd/completion_bash.go b/pkg/cmd/completion_bash.go
index 66654c025..4d7234cdd 100644
--- a/pkg/cmd/completion_bash.go
+++ b/pkg/cmd/completion_bash.go
@@ -175,6 +175,30 @@ __kamel_kubectl_get_known_integrationkits() {
     compopt -o nospace
 }
 
+
+__kamel_kubectl_get_kamelets() {
+    local template
+    local kubectl_out
+
+    template="{{ range .items  }}{{ .metadata.name }} {{ end }}"
+
+    if kubectl_out=$(kubectl get -o template --template="${template}" kamelets 
2>/dev/null); then
+        COMPREPLY=( $( compgen -W "${kubectl_out}" -- "$cur" ) )
+    fi
+}
+
+__kamel_kubectl_get_non_bundled_non_readonly_kamelets() {
+    local template
+    local kubectl_out
+
+    template="{{ range .items  }}{{ .metadata.name }} {{ end }}"
+    
label_conditions="camel.apache.org/kamelet.bundled=false,camel.apache.org/kamelet.readonly=false"
+
+    if kubectl_out=$(kubectl get -l ${label_conditions} -o template 
--template="${template}" kamelets 2>/dev/null); then
+        COMPREPLY=( $( compgen -W "${kubectl_out}" -- "$cur" ) )
+    fi
+}
+
 __custom_func() {
     case ${last_command} in
         kamel_describe_integration)
@@ -185,6 +209,10 @@ __custom_func() {
             __kamel_kubectl_get_integrationkits
             return
             ;;
+        kamel_describe_kamelet)
+            __kamel_kubectl_get_kamelets
+            return
+            ;;
         kamel_delete)
             __kamel_kubectl_get_integrations
             return
@@ -193,10 +221,22 @@ __custom_func() {
             __kamel_kubectl_get_integrations
             return
             ;;
+        kamel_get)
+            __kamel_kubectl_get_integrations
+            return
+            ;;
         kamel_kit_delete)
             __kamel_kubectl_get_non_platform_integrationkits
             return
             ;;
+        kamel_kit_get)
+            __kamel_kubectl_get_integrationkits
+            return
+            ;;
+        kamel_kamelet_delete)
+            __kamel_kubectl_get_non_bundled_non_readonly_kamelets
+            return
+            ;;
         *)
             ;;
     esac

Reply via email to