Skip to content

Commit fbfc16b

Browse files
author
Jacob Truman
committed
Fix issue parsing version
1 parent 51a9522 commit fbfc16b

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

buildrunner/config/loader.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,19 @@
3131
load_config,
3232
)
3333

34+
from buildrunner import __version__ as BUILDRUNNER_VERSION
35+
3436
from .models import GlobalConfig
3537

3638
from . import fetch, jinja_context
3739

38-
3940
MASTER_GLOBAL_CONFIG_FILE = "/etc/buildrunner/buildrunner.yaml"
4041
VERSION_FILE_PATH = (
4142
f"{os.path.realpath(os.path.join(os.path.dirname(__file__), '..'))}/version.py"
4243
)
4344
RESULTS_DIR = "buildrunner.results"
4445
LOGGER = logging.getLogger(__name__)
4546

46-
4747
def _log_generated_file(
4848
log_generated_files: bool, file_name: str, file_contents: str
4949
) -> None:
@@ -124,27 +124,14 @@ def _validate_version(config: dict) -> None:
124124
buildrunner. If the config version is greater than the buildrunner version or any parsing error occurs
125125
it will raise a buildrunner exception.
126126
"""
127-
buildrunner_version = None
128-
129127
if not os.path.exists(VERSION_FILE_PATH):
130128
LOGGER.warning(
131129
f"File {VERSION_FILE_PATH} does not exist. This could indicate an error with "
132130
f"the buildrunner installation. Unable to validate version."
133131
)
134132
return
135133

136-
with open(VERSION_FILE_PATH, "r", encoding="utf-8") as version_file:
137-
for line in version_file.readlines():
138-
if "__version__" in line:
139-
try:
140-
version_values = (
141-
line.split("=")[1].strip().replace("'", "").split(".")
142-
)
143-
buildrunner_version = f"{version_values[0]}.{version_values[1]}"
144-
except IndexError as exception:
145-
raise ConfigVersionFormatError(
146-
f'couldn\'t parse version from "{line}"'
147-
) from exception
134+
buildrunner_version = ".".join((BUILDRUNNER_VERSION.split(".") + ["0", "0"])[:2])
148135

149136
if not buildrunner_version:
150137
raise BuildRunnerVersionError("unable to determine buildrunner version")

0 commit comments

Comments
 (0)