|
31 | 31 | load_config, |
32 | 32 | ) |
33 | 33 |
|
| 34 | +from buildrunner import __version__ as BUILDRUNNER_VERSION |
| 35 | + |
34 | 36 | from .models import GlobalConfig |
35 | 37 |
|
36 | 38 | from . import fetch, jinja_context |
37 | 39 |
|
38 | | - |
39 | 40 | MASTER_GLOBAL_CONFIG_FILE = "/etc/buildrunner/buildrunner.yaml" |
40 | 41 | VERSION_FILE_PATH = ( |
41 | 42 | f"{os.path.realpath(os.path.join(os.path.dirname(__file__), '..'))}/version.py" |
@@ -124,27 +125,14 @@ def _validate_version(config: dict) -> None: |
124 | 125 | buildrunner. If the config version is greater than the buildrunner version or any parsing error occurs |
125 | 126 | it will raise a buildrunner exception. |
126 | 127 | """ |
127 | | - buildrunner_version = None |
128 | | - |
129 | 128 | if not os.path.exists(VERSION_FILE_PATH): |
130 | 129 | LOGGER.warning( |
131 | 130 | f"File {VERSION_FILE_PATH} does not exist. This could indicate an error with " |
132 | 131 | f"the buildrunner installation. Unable to validate version." |
133 | 132 | ) |
134 | 133 | return |
135 | 134 |
|
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 |
| 135 | + buildrunner_version = ".".join((BUILDRUNNER_VERSION.split(".") + ["0", "0"])[:2]) |
148 | 136 |
|
149 | 137 | if not buildrunner_version: |
150 | 138 | raise BuildRunnerVersionError("unable to determine buildrunner version") |
|
0 commit comments