Skip to content

Commit

Permalink
template upload checks zango version
Browse files Browse the repository at this point in the history
  • Loading branch information
deepakdinesh1123 committed Nov 11, 2024
1 parent 8a61c6b commit 1736fe9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
17 changes: 9 additions & 8 deletions backend/src/zango/api/platform/tenancy/v1/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,15 @@ def update(self, instance, validated_data):
"prod": "main",
}
if extra_config_json.get("git_config", None):
extra_config_json["git_config"]["branch"] = {
**extra_config_json["git_config"]["branch"],
**{
k: v
for k, v in default_branch_config.items()
if extra_config_json["git_config"]["branch"][k] is None
},
}
if extra_config_json["git_config"].get("repo_url", None):
extra_config_json["git_config"]["branch"] = {
**extra_config_json["git_config"]["branch"],
**{
k: v
for k, v in default_branch_config.items()
if extra_config_json["git_config"]["branch"][k] is None
},
}
validated_data["extra_config"] = extra_config_json
except json.JSONDecodeError:
raise serializers.ValidationError(
Expand Down
13 changes: 13 additions & 0 deletions backend/src/zango/api/platform/tenancy/v1/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
import os
import zipfile

from packaging.specifiers import SpecifierSet
from packaging.version import Version

import zango


def extract_app_details_from_zip(template_zip):
settings_filename = "settings.json"
Expand Down Expand Up @@ -31,6 +36,14 @@ def extract_app_details_from_zip(template_zip):

# Parse the JSON content
settings = json.loads(settings_content)
if settings.get("zango_version"):
zango_version = settings["zango_version"]
installed_zango_version = Version(zango.__version__)
specifier = SpecifierSet(zango_version)
if installed_zango_version not in specifier:
raise Exception(
f"Zango version {installed_zango_version} is not compatible with {zango_version}"
)
return (
settings["version"],
settings["app_name"],
Expand Down

0 comments on commit 1736fe9

Please sign in to comment.