Add support for minimal version check

This commit is contained in:
Stefan Reimer 2023-10-27 10:44:44 +00:00
parent e070fecb9f
commit bebd55bbae

View File

@ -6,11 +6,14 @@ import tempfile
import importlib
import pulumi
import subprocess
import semver
from functools import wraps
import logging
from . import __version__
logger = logging.getLogger(__name__)
# Disable Pulumis version check globally
@ -135,6 +138,17 @@ def pulumi_ws(func):
except AttributeError:
_version = "undefined"
# bail out if we need a minimal cloudbender version for a template
try:
_min_version = self._pulumi_code.MIN_CLOUDBENDER_VERSION
if semver.compare(__version__.strip("v"),_min_version.strip("v")) < 0:
raise ValueError(
f"Minimal required CloudBender version is {_min_version}, but we are {__version__}!"
)
except AttributeError:
pass
# Tag all resources with our metadata, allowing "prune" eventually
_tags["zdt:cloudbender.source"] = "{}:{}".format(
os.path.basename(self._pulumi_code.__file__), _version