-
Notifications
You must be signed in to change notification settings - Fork 61
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
feat: add kubectl auto-completion #108
Conversation
f1de3f9
to
5980109
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A part for a minor suggestion it worked for me
universal/ubi8/Dockerfile
Outdated
echo '[ -f ~/.kubectl_aliases ] && source ~/.kubectl_aliases' >> /home/user/.bashrc | ||
EOF | ||
|
||
# kubectl completion | ||
RUN kubectl completion bash > /usr/share/bash-completion/completions/kubectl \ | ||
&& echo "source /usr/share/bash-completion/completions/kubectl" >> /home/user/.bashrc | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move everything related to kubectl in the dedicated heredoc
echo '[ -f ~/.kubectl_aliases ] && source ~/.kubectl_aliases' >> /home/user/.bashrc | |
EOF | |
# kubectl completion | |
RUN kubectl completion bash > /usr/share/bash-completion/completions/kubectl \ | |
&& echo "source /usr/share/bash-completion/completions/kubectl" >> /home/user/.bashrc | |
kubectl completion bash > /usr/share/bash-completion/completions/kubectl | |
echo '[ -f ~/.kubectl_aliases ] && source ~/.kubectl_aliases' >> /home/user/.bashrc | |
echo "source /usr/share/bash-completion/completions/kubectl" >> /home/user/.bashrc | |
EOF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the .bashrc in the container, I see a warning that sdkman only works if the relevant lines are at the end of .bashrc, but we've injected a bunch of source
lines after that block -- is the sdkman warning still true? cc: @l0rd
An easier way to do completions (but one that would require reworking all completions in the dockerfile) would be something like what WTO does:
Further detail on the sdkman concern: this is the current #THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
export SDKMAN_DIR="$HOME/.sdkman"
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh"
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
source /usr/share/bash-completion/completions/git
source /usr/share/bash-completion/completions/oc
[ -f ~/.kubectl_aliases ] && source ~/.kubectl_aliases
export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH" |
Thanks for pointing this out & suggesting an alternative approach @amisevsk. I'm going to take a bit longer to work on this PR to try and see if I can rework all the completions in the dockerfile. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to merge with @l0rd's suggestion from review, and then optionally rework completions as a separate PR
Part of eclipse-che/che#21735 Signed-off-by: Andrew Obuchowicz <[email protected]>
5980109
to
dff64d4
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: amisevsk, AObuchow, l0rd The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
I think this PR can be closed as it's made redundant by https://github.com/devfile/developer-images/pull/107/files#diff-9f21bef4669d474b6ddef409447be53ae91c94cb50b6df9345149a0e89fb5391R229 @l0rd |
Sorry, that was a mistake. I wanted to test your PR and I rebased mine on top of yours and then I forget about it and pushed your changes too 🤷 . So yes I think we can close this one. |
@l0rd no worries 😎 sounds good, closing. |
Resolves the last part of eclipse-che/che#21735 by adding bash autocompletion for kubectl.
To test, use the following image
quay.io/aobuchow/universal-developer-image:kubectl-completion
, i.e.:Then, with a shell inside the container, type in
kubectl -
and hit TAB twice to see autocomplete results.The output should resemble the following: