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

snapcraft: Fix LXD snap bash completions #674

Open
wants to merge 1 commit into
base: latest-edge
Choose a base branch
from

Conversation

kadinsayani
Copy link
Contributor

Fixes canonical/lxd#14635, canonical/lxd#14690 and canonical/lxd#14648.

This PR changes the permissions, location, and file extension of the lxc bash completions script to ensure correct execution. The bash-completions package is also added to the snap stage packages.

This commit changes the permissions, location, and file extension of the
`lxc` bash completions script to ensure correct execution.

Signed-off-by: Kadin Sayani <kadin.sayani@canonical.com>
Copy link
Member

@simondeziel simondeziel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but I have 2 questions. Thanks

@@ -1471,9 +1472,10 @@ parts:
# When executed by snapd, the `compopt` support detection doesn't work so fake that it is always `builtin`
set_compopt='s|$(type -t compopt)|"builtin"|'
# Modify requestComp variable to use lxc based on context ($SNAP/bin/lxc in Snap environment)
set_request_comp='s|requestComp="${words\[0\]} __complete ${args\[\*\]}"|requestComp="/snap/lxd/current/bin/lxc __complete ${args[*]}"|'
set_request_comp='s|requestComp="${words\[0\]} __complete ${args\[\*\]}"|requestComp="/snap/lxd/current/commands/lxc __complete ${args[*]}"|'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
set_request_comp='s|requestComp="${words\[0\]} __complete ${args\[\*\]}"|requestComp="/snap/lxd/current/commands/lxc __complete ${args[*]}"|'
set_request_comp='s|requestComp="${words\[0\]} __complete ${args\[\*\]}"|requestComp="/snap/bin/lxc __complete ${args[*]}"|'

Would that work?

@@ -1394,6 +1394,7 @@ parts:
stage-packages:
- acl
- attr
- bash-completion
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that needed for lxc completion bash to work as intended?

tomponline added a commit to canonical/lxd that referenced this pull request Dec 20, 2024
This PR fixes the logic in `cmpRemotes` to ensure remotes are
contextually completed correctly based on the current remote. While
testing canonical/lxd-pkg-snap#674, I noticed
that the `local` remote was not completed while on a different remote.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lxc remote switch should suggest completion of any locally configured remote
2 participants