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

fix(lxd): update LXD version naming support LTS #532

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions craft_providers/lxd/lxd.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ def version(self) -> str:
"""Query LXD version.

The version is of the format:
<major>.<minor>[.<micro>]
<major>.<minor>[.<micro>] [LTS]

Version examples:
- 5.21.0 LTS
- 4.13
- 4.0.5
- 2.0.12
Expand All @@ -107,7 +108,14 @@ def version(self) -> str:
details=details_from_called_process_error(error),
) from error

return proc.stdout.strip()
version_string = proc.stdout.strip()
if version_string:
return version_string.split()[0]

raise LXDError(
"Failed to parse LXD version.",
details=f"Version data returned: {version_string!r}",
)

def wait_ready(
self,
Expand Down
1 change: 1 addition & 0 deletions tests/unit/lxd/test_lxd.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def test_init_error(fake_process):
("4.0", True),
("4.1.4", True),
("4.10", True),
("5.21.0 LTS", True),
],
)
def test_is_supported_version(fake_process, version, compatible):
Expand Down
Loading