Skip to content

Commit

Permalink
Add support for underscores in DYNAMIC_SIDECAR_DOCKER_IMAGE_RE (#3139)
Browse files Browse the repository at this point in the history
* Add support for underscores in DYNAMIC_SIDECAR_DOCKER_IMAGE_RE

* adds test

* add more regex tests

* Refactor REGEX tests

Co-authored-by: Dustin Kaiser <mail@dustinkaiser.eu>
Co-authored-by: Pedro Crespo-Valero <32402063+pcrespov@users.noreply.github.com>
  • Loading branch information
3 people authored Jun 30, 2022
1 parent 1449f68 commit 2bc4d08
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# - itisfoundation
# - 10.0.0.0:8473 (IP & Port)
DYNAMIC_SIDECAR_DOCKER_IMAGE_RE = (
r"(^([a-zA-Z0-9:.-]+)/)?(dynamic-sidecar):([a-zA-Z0-9.-]+$)"
r"(^([_a-zA-Z0-9:.-]+)/)?(dynamic-sidecar):([_a-zA-Z0-9.-]+$)"
)

REGEX_DY_SERVICE_SIDECAR = rf"^{DYNAMIC_SIDECAR_SERVICE_PREFIX}_[a-zA-Z0-9-_]*"
Expand Down
20 changes: 13 additions & 7 deletions services/director-v2/tests/unit/test_core_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# pylint:disable=unused-argument
# pylint:disable=redefined-outer-name

from typing import Any, Dict, List, Set
from typing import Any

import pytest
from _pytest.monkeypatch import MonkeyPatch
Expand All @@ -18,7 +18,7 @@
)


def _get_backend_type_options() -> Set[str]:
def _get_backend_type_options() -> set[str]:
return {x for x in dir(S3Provider) if not x.startswith("_")}


Expand Down Expand Up @@ -64,7 +64,7 @@ def test_enforce_r_clone_requirement(monkeypatch: MonkeyPatch) -> None:
RCloneSettings()


def test_settings_with_project_env_devel(project_env_devel_environment: Dict[str, Any]):
def test_settings_with_project_env_devel(project_env_devel_environment: dict[str, Any]):
# loads from environ
settings = AppSettings.create_from_envs()
print("captured settings: \n", settings.json(indent=2))
Expand All @@ -75,7 +75,7 @@ def test_settings_with_project_env_devel(project_env_devel_environment: Dict[str
assert settings.POSTGRES.dsn == "postgresql://test:test@localhost:5432/test"


def test_settings_with_env_devel(mock_env_devel_environment: Dict[str, str]):
def test_settings_with_env_devel(mock_env_devel_environment: dict[str, str]):
settings = AppSettings.create_from_envs()
print("captured settings: \n", settings.json(indent=2))
assert settings
Expand All @@ -87,6 +87,12 @@ def test_settings_with_env_devel(mock_env_devel_environment: Dict[str, str]):
"local/dynamic-sidecar:production",
"itisfoundation/dynamic-sidecar:merge-github-testbuild-latest",
"itisfoundation/dynamic-sidecar:1.0.0",
"itisfoundation/dynamic-sidecar:staging-github-staging_diolkos1-2022-06-15--15-04.75ddf7e3fb86944ef95fcf77e4075464848121f1",
"itisfoundation/dynamic-sidecar:hotfix-github-2022-06-24--12-34.162bfe899d6b62d808e70a07da280fd390bc4434",
"itisfoundation/dynamic-sidecar:hotfix-v1-28-1-github-testbuild-latest",
"itisfoundation/dynamic-sidecar:staging-github-latest",
"itisfoundation/dynamic-sidecar:release-github-v1.28.0-2022-05-30--14-52.62c4c48b1846ecaa8280773f48a2f14bf0f3047b",
"itisfoundation/dynamic-sidecar:master-github-2022-06-24--14-35.38add6817bc8cafabc14ec7dacd9b249daa3a11e",
"local/dynamic-sidecar:sadasd",
"itisfoundation/dynamic-sidecar:sadasd",
"10.10.10.10.no.ip:8080/dynamic-sidecar:10.0.1",
Expand Down Expand Up @@ -118,8 +124,8 @@ def test_dynamic_sidecar_settings(testing_environ_expected_success: str) -> None

@pytest.fixture(
params=[
"10.10.10.10.no_ip:8080/dynamic-sidecar:sadasd",
"10.10.10.10.no.ip:8080/dynamic-sidecar:the_tag",
"10.10.10.10.no/ip:8080/dynamic-sidecar:sadasd",
"10.10.10.10.no$ip:8080/dynamic-sidecar:the_tag",
],
)
def testing_environ_expected_failure(
Expand Down Expand Up @@ -150,7 +156,7 @@ def test_expected_failure_dynamic_sidecar_settings(
)
def test_services_custom_constraints(
custom_constraints: str,
expected: List[str],
expected: list[str],
project_env_devel_environment,
monkeypatch: MonkeyPatch,
) -> None:
Expand Down

0 comments on commit 2bc4d08

Please sign in to comment.