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

CLI: lxc storage volume completion fixes and command description update #14702

Merged

Conversation

kadinsayani
Copy link
Contributor

@kadinsayani kadinsayani commented Dec 19, 2024

Fixes #14682.

Summary of changes:

  • Fixes shell completions for lxc storage volume show. GetStoragePoolVolumeNames returns the full volume name including "/snapshots/", which is incorrect in the context of the CLI. To address this issue, parsing has been added to serve valid completions for snapshot volumes.
  • Updates the command description for lxc storage volume snapshot.
  • Fixes cmpInstanceSetKeys logic to provide completions for any instance keys which are currently set, not just prefixed keys.

…e show`

Fixes canonical#14682.

This commit fixes shell completions for snapshots when running `lxc
storage volume show`. `GetStoragePoolVolumeNames` returns the full
volume name including "/snapshots/", which is incorrect in the context
of the CLI.

Signed-off-by: Kadin Sayani <[email protected]>
(cherry picked from commit 1bcc8b3)
…tion

The command is `lxc storage volume snapshot <pool> <volume>` not `lxc
storage volume snapshot create <pool> <volume>`

Signed-off-by: Kadin Sayani <[email protected]>
(cherry picked from commit 5a669ef)
Signed-off-by: Kadin Sayani <[email protected]>
(cherry picked from commit b67bf1a)
@kadinsayani kadinsayani force-pushed the 14682-storage-volume-completion-fixes branch from b6bd50a to 3ad34fc Compare December 19, 2024 22:55
simondeziel
simondeziel previously approved these changes Dec 19, 2024
lxc/completion.go Outdated Show resolved Hide resolved
lxc/completion.go Outdated Show resolved Hide resolved
lxc/completion.go Outdated Show resolved Hide resolved
Copy link
Member

@tomponline tomponline left a comment

Choose a reason for hiding this comment

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

I'm still concerned with the approaches we're using to gather keys.

We need to have a single source of truth for config keys and not mix instancetype and metadata API sources.

@kadinsayani
Copy link
Contributor Author

kadinsayani commented Dec 20, 2024

I'm still concerned with the approaches we're using to gather keys.

We need to have a single source of truth for config keys and not mix instancetype and metadata API sources.

After the addition of improved configuration key validation with #14584, we don't actually need any validation in cmpInstanceSetKeys, since we can assume any set key is valid for an instance. I'll update this PR to only filter out volatile.* keys. Should we also filter out image.* keys?

…g keys

This commit fixes `cmpInstanceSetKeys` to return any set instance
configuration key rather than just keys with known prefixes. We don't
need to validate type here since a VM specific config key cannot be set
for a container, and vice-versa, and we only return config keys that
show up in an instance's full config.

Signed-off-by: Kadin Sayani <[email protected]>
(cherry picked from commit 4307f76)
Signed-off-by: Kadin Sayani <[email protected]>
@kadinsayani
Copy link
Contributor Author

I'm still concerned with the approaches we're using to gather keys.

We need to have a single source of truth for config keys and not mix instancetype and metadata API sources.

I've removed the instancetype package import. I think we should stick to the metadata API to ensure compatibility.

Copy link
Member

@tomponline tomponline left a comment

Choose a reason for hiding this comment

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

Thanks!

@tomponline tomponline merged commit 4df9163 into canonical:main Dec 20, 2024
26 checks passed
@kadinsayani kadinsayani deleted the 14682-storage-volume-completion-fixes branch December 20, 2024 16:49
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 storage volume <action> completion issue with snapshots
3 participants