This is an automated email from the ASF dual-hosted git repository. astefanutti 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 3b6a004 feat: add command completion for connect flag 3b6a004 is described below commit 3b6a004e318b13f1ce990e882e87beaab85e6639 Author: John Poth <poth.j...@gmail.com> AuthorDate: Thu Feb 18 18:02:00 2021 +0100 feat: add command completion for connect flag --- pkg/cmd/completion_bash.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/pkg/cmd/completion_bash.go b/pkg/cmd/completion_bash.go index 929ab08..6d554c1 100644 --- a/pkg/cmd/completion_bash.go +++ b/pkg/cmd/completion_bash.go @@ -89,6 +89,32 @@ __kamel_deletion_policy() { COMPREPLY=( $( compgen -W "${type_list}" -- "$cur") ) } +__kamel_kubectl_get_servicebinding() { + local template + local template_gvkn + local kubectl_out + local service_names + local services_list + + template="{{ range .items }}{{ .metadata.name }} {{ end }}" + template_gvkn="{{ range .items }}{{ .kind }}/{{ .apiVersion }}/{{ .metadata.name }} {{ end }}" + if kubectl_out=$(kubectl get -o template --template="${template}" crd -l service.binding/provisioned-service=true 2>/dev/null); then + kubectl_out="${kubectl_out// /,}" + service_names="${kubectl_out}servicebinding" + if kubectl_out=$(kubectl get -o template --template="${template_gvkn}" ${service_names} 2>/dev/null); then + for resource in $kubectl_out + do + name=$(echo ${resource} | cut -d'/' -f 4) + version=$(echo ${resource} | cut -d'/' -f 3) + group=$(echo ${resource} | cut -d'/' -f 2) + kind=$(echo ${resource} | cut -d'/' -f 1) + services_list="${services_list} ${kind}.${version}.${group}/${name}" + done + COMPREPLY=( $( compgen -W "${services_list[*]}" -- "$cur" ) ) + fi + fi +} + __kamel_kubectl_get_configmap() { local template local kubectl_out @@ -252,6 +278,13 @@ func configureKnownBashCompletions(command *cobra.Command) { cobra.BashCompCustom: {"__kamel_deletion_policy"}, }, ) + configureBashAnnotationForFlag( + command, + "connect", + map[string][]string{ + cobra.BashCompCustom: {"__kamel_kubectl_get_servicebinding"}, + }, + ) } func configureBashAnnotationForFlag(command *cobra.Command, flagName string, annotations map[string][]string) {