Skip to content

Commit

Permalink
fix(api): normalize image version handling by removing 'v' prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
0x1026 committed Dec 10, 2024
1 parent 7fb810e commit 86b4acc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions api/src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class Settings(BaseSettings):
def check_image_version(cls, v):
if v == "":
return None
if v and not v.startswith("v"):
return f"v{v}"
if v.startswith("v"):
return v[1:]
return v

@model_validator(mode="before")
Expand Down
10 changes: 5 additions & 5 deletions api/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_settings_with_custom_settings():
APP_NAME="api",
APP_PACKAGE="api2",
APP_ENV="production",
IMAGE_VERSION="v1.0.0",
IMAGE_VERSION="1.0.0",
MARIADB_SERVER="127.0.0.1",
MARIADB_PORT=3307,
MARIADB_USER="user2",
Expand All @@ -40,7 +40,7 @@ def test_settings_with_custom_settings():
assert custom.APP_NAME == "api"
assert custom.APP_PACKAGE == "api2"
assert custom.APP_ENV == "production"
assert custom.IMAGE_VERSION == "v1.0.0"
assert custom.IMAGE_VERSION == "1.0.0"
assert custom.MARIADB_SERVER == "127.0.0.1"
assert custom.MARIADB_PORT == 3307
assert custom.MARIADB_USER == "user2"
Expand All @@ -53,11 +53,11 @@ def test_settings_with_custom_settings():
)


def test_image_version_without_v_prefix():
def test_image_version_wit_v_prefix():
custom = Settings(
IMAGE_VERSION="1.0.0",
IMAGE_VERSION="v1.0.0",
)
assert custom.IMAGE_VERSION == "v1.0.0"
assert custom.IMAGE_VERSION == "1.0.0"


def test_settings_missing_password():
Expand Down

0 comments on commit 86b4acc

Please sign in to comment.