Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable CLI completion for integration, kit, kamelet names #3628

Closed
tadayosi opened this issue Sep 12, 2022 · 10 comments · Fixed by #3902
Closed

Enable CLI completion for integration, kit, kamelet names #3628

tadayosi opened this issue Sep 12, 2022 · 10 comments · Fixed by #3902
Assignees
Labels
area/cli Kamel CLI good first issue Does not require full understanding of the codebase kind/feature New feature or request status/never-stale

Comments

@tadayosi
Copy link
Member

tadayosi commented Sep 12, 2022

Currently there's no completion after for example:

kamel get/delete [TAB]
kamel kit get/delete [TAB]
kamel kamelet delete [TAB]
kamel bind [TAB]

Ideally they should show the integration/kit/kamelet names already deployed on the cluster.

@tadayosi tadayosi added kind/feature New feature or request area/cli Kamel CLI labels Sep 12, 2022
@squakez
Copy link
Contributor

squakez commented Sep 12, 2022

Do you think is this okey for "good first issue" label?

@tadayosi tadayosi added the good first issue Does not require full understanding of the codebase label Sep 12, 2022
@github-actions
Copy link
Contributor

This issue has been automatically marked as stale due to 90 days of inactivity.
It will be closed if no further activity occurs within 15 days.
If you think that’s incorrect or the issue should never stale, please simply write any comment.
Thanks for your contributions!

@gansheer
Copy link
Contributor

gansheer commented Dec 13, 2022

The kamel kit delete completion already exists : the command only shows non-platform kits. Is this behavior something that should evolve to all kits (even the platform ones) for the kamel kit delete or should it stay like this?
I don't know why this exclusion of platform kits is done.

__kamel_kubectl_get_non_platform_integrationkits() {
local template
local kubectl_out
template="{{ range .items }}{{ .metadata.name }} {{ end }}"
label_condition="camel.apache.org/kit.type!=platform"
if kubectl_out=$(kubectl get -l ${label_condition} -o template --template="${template}" integrationkits 2>/dev/null); then
COMPREPLY=( $( compgen -W "${kubectl_out}" -- "$cur" ) )
fi
}

@lburgazzoli @astefanutti do you have any information ?

gansheer added a commit to gansheer/camel-k that referenced this issue Dec 13, 2022
* 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

Closes apache#3628
@gansheer
Copy link
Contributor

@tadayosi @squakez

What is expected on then kamel bind autocomplete ? While we could default to the custom resources kamelets.camel.apache.org, the command description "Bind Kubernetes resources, such as Kamelets, in an integration flow. Endpoints are expected in the format "[[apigroup/]version:]kind:[namespace/]name" or plain Camel URIs." clearly indicates more possibilities.

What I understand from "Kubernetes resources" looks like a lot of possible kubernetes objects (more than we could predict) to have an autocomplete on it but I might be wrong.

@squakez
Copy link
Contributor

squakez commented Dec 14, 2022

What is expected on then kamel bind autocomplete ?

The kamel bind can accept any kamelet or generic Camel URI. I'd say that the autocompletion could look up on Kamelets that are available in the namespace where we're willing to run the KameletBinding. We cannot do much more than that, as the user can provide any other URI.

@tadayosi
Copy link
Member Author

Yeah, as @gansheer outlined it doesn't seem to make much sense to provide auto completion for kamel bind as it accepts a variety of inputs. We can focus on the other commands for implementing auto completion and ignore kamel bind for the time being.

gansheer added a commit to gansheer/camel-k that referenced this issue Dec 14, 2022
* 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 apache#3628
@astefanutti
Copy link
Member

The kamel kit delete completion already exists : the command only shows non-platform kits. Is this behavior something that should evolve to all kits (even the platform ones) for the kamel kit delete or should it stay like this? I don't know why this exclusion of platform kits is done.

__kamel_kubectl_get_non_platform_integrationkits() {
local template
local kubectl_out
template="{{ range .items }}{{ .metadata.name }} {{ end }}"
label_condition="camel.apache.org/kit.type!=platform"
if kubectl_out=$(kubectl get -l ${label_condition} -o template --template="${template}" integrationkits 2>/dev/null); then
COMPREPLY=( $( compgen -W "${kubectl_out}" -- "$cur" ) )
fi
}

@lburgazzoli @astefanutti do you have any information ?

I think the general idea was that kits of type platform are managed by the operator, as opposed to kits created by users, and should be "hidden" away from users.

gansheer added a commit to gansheer/camel-k that referenced this issue Dec 14, 2022
* 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 apache#3628
@gansheer
Copy link
Contributor

I think the general idea was that kits of type platform are managed by the operator, as opposed to kits created by users, and should be "hidden" away from users.

I get the idea, but since the command allows the deletion platform kits without any specific flag I wonder if it is a good idea to have a completion that does not retrieve the same results than the allowed values for the command.

I fear it might just confuse the user. I am really tempted to remove the platform exclusion filter but am unsure about the end user real life use case.

@tadayosi
Copy link
Member Author

tadayosi commented Dec 15, 2022

Hi,

I get the idea, but since the command allows the deletion platform kits without any specific flag I wonder if it is a good idea to have a completion that does not retrieve the same results than the allowed values for the command.

Actually, no, you cannot delete platform kits with kamel kit delete. They are protected from cli. There's even no flag to force performing it. So sometimes I tend to need to do this to clean up platform kits: kubectl delete ik ...

@gansheer
Copy link
Contributor

Hi,

Hi,

Actually, no, you cannot delete platform kits with kamel kit delete. They are protected from cli. There's even no flag to force performing it. So sometimes I tend to need to do this to clean up platform kits: kubectl delete ik ...

You are absolutely right, I just realized I used the kubectl command most of the time. The completion command is good for kamel kit delete.

Thank you 👍

tadayosi pushed a commit that referenced this issue Dec 16, 2022
* 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
@tadayosi tadayosi assigned tadayosi and gansheer and unassigned tadayosi Dec 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cli Kamel CLI good first issue Does not require full understanding of the codebase kind/feature New feature or request status/never-stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants