Skip to content

Commit

Permalink
T6354: do an explicit read from version file to avoid circular reference
Browse files Browse the repository at this point in the history
  • Loading branch information
jestabro committed May 17, 2024
1 parent 6b70110 commit e0105ef
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions python/vyos/system/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
from functools import wraps
from tempfile import TemporaryDirectory
from typing import TypedDict
from json import loads

from vyos import version
from vyos.defaults import directories
from vyos.system import disk, grub

# Define variables
Expand Down Expand Up @@ -201,9 +202,12 @@ def get_running_image() -> str:
if running_image_result:
running_image: str = running_image_result.groupdict().get(
'image_version', '')
# we need to have a fallback for live systems
# we need to have a fallback for live systems:
# explicit read from version file
if not running_image:
running_image: str = version.get_version()
json_data: str = Path(directories['data']).joinpath('version.json').read_text()
dict_data: dict = loads(json_data)
running_image: str = dict_data['version']

return running_image

Expand Down

0 comments on commit e0105ef

Please sign in to comment.