Skip to content

Commit

Permalink
feat: support pessimistic versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
Apollorion committed Jan 28, 2025
1 parent 18dff64 commit 178c792
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions spacemk/exporters/terraform.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,16 @@ def _check_workspaces_data(self, data: list[dict]) -> list[dict]:
logging.info("Start checking workspaces data")

def check_for_bsl_terraform(version):
warning = None

# Ensure version is not pessimistic
if version.startswith("~") or version.startswith("^"):
version = f"{version[1]}={version[2:]}"
warning = "Pessimistic version, will be changed to opportunistic."

if version == "latest" or semver.match(version, ">=1.5.7"):
return True
return False
return True, warning
return False, warning

for key, item in enumerate(data):
warnings = []
Expand All @@ -202,8 +209,11 @@ def check_for_bsl_terraform(version):
if item.get("attributes.vcs-repo.service-provider") is None:
warnings.append("No VCS configuration")

if check_for_bsl_terraform(item.get("attributes.terraform-version")):
bsl, warning = check_for_bsl_terraform(item.get("attributes.terraform-version"))
if bsl:
warnings.append("BSL Terraform version")
if warning is not None:
warnings.append(warning)

data[key]["warnings"] = ", ".join(warnings)

Expand Down

0 comments on commit 178c792

Please sign in to comment.