Skip to content

Commit

Permalink
fix(lxd): update LXD version naming support LTS (#532)
Browse files Browse the repository at this point in the history
  • Loading branch information
syu-w authored and mr-cal committed Mar 15, 2024
1 parent 76c937b commit a7c8ece
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
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

0 comments on commit a7c8ece

Please sign in to comment.