Skip to content

Commit 39a9bc2

Browse files
authored
Group all context constants into one module (#7285)
1 parent 138789b commit 39a9bc2

7 files changed

Lines changed: 35 additions & 25 deletions

File tree

utils/_context/_scenarios/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from .appsec_low_waf_timeout import AppsecLowWafTimeout
3030
from .ai_guard import AIGuardScenario
3131
from .integration_frameworks import IntegrationFrameworksScenario
32-
from utils._context.ports import ContainerPorts
32+
from utils._context.constants import ContainerPorts
3333
from utils._context._scenarios.appsec_rasp import AppSecLambdaRaspScenario, AppsecRaspScenario
3434
from utils._context.containers import (
3535
CassandraContainer,

utils/_context/_scenarios/core.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ def __call__(self, test_object): # noqa: ANN001 (tes_object can be a class or a
3030

3131

3232
class _ScenarioGroups:
33+
"""Group scenario into coherents buckets. It's used in two usages :
34+
35+
1. decorate test classes if ever they should be applied to more than one scenario
36+
2. select a set of scenario to execute in the official system-tests workflow
37+
"""
38+
3339
all = ScenarioGroup()
3440
ai_guard = ScenarioGroup()
3541
appsec = ScenarioGroup()

utils/_context/constants.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from enum import StrEnum, IntEnum
2+
3+
4+
class WeblogBuildMode(StrEnum):
5+
"""Describe how a weblog should be built"""
6+
7+
none = "none"
8+
""" The weblog does not require any build step"""
9+
10+
local = "local"
11+
""" The weblog has a fully baked base image, so the build step is extra light,
12+
and does not requires a full job in the CI"""
13+
14+
prebuild = "prebuild"
15+
""" The weblog will be built in a dedicated job in the CI """
16+
17+
18+
class ContainerPorts(IntEnum):
19+
"""Host ports used by tested containers"""
20+
21+
vcr_cassettes = 8300

utils/_context/containers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from utils._context.component_version import ComponentVersion, Version
2222
from utils._context.docker import get_docker_client
2323
from utils._context._image_mirror import mirror_image
24-
from utils._context.ports import ContainerPorts
24+
from utils._context.constants import ContainerPorts
2525
from utils.proxy.tuf import get_tuf_root_json
2626
from utils.proxy.ports import ProxyPorts
2727
from utils.proxy.mocked_response import (

utils/_context/ports.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

utils/_context/weblog_metadata.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,26 @@
1-
from enum import StrEnum
21
from dataclasses import dataclass, replace
32
from pathlib import Path
43
import yaml
54

6-
7-
class BuildMode(StrEnum):
8-
none = "none"
9-
""" The weblog does not require any build step"""
10-
11-
local = "local"
12-
""" The weblog has a fully baked base image, so the build step is extra light,
13-
and does not requires a full job in the CI"""
14-
15-
prebuild = "prebuild"
16-
""" The weblog will be built in a dedicated job in the CI """
5+
from .constants import WeblogBuildMode
176

187

198
@dataclass
209
class WeblogMetaData:
2110
name: str
2211
library: str
23-
build_mode: BuildMode = BuildMode.prebuild
12+
build_mode: WeblogBuildMode = WeblogBuildMode.prebuild
2413
framework_versions: list[str] | None = None
2514
artifact_name: str = ""
2615
""" not declared in the yml file, but populated later """
2716

2817
def __post_init__(self):
29-
self.build_mode = BuildMode(self.build_mode)
18+
self.build_mode = WeblogBuildMode(self.build_mode)
3019

3120
@property
3221
def require_build(self) -> bool:
3322
"""The run_end_to_end job builds the weblog locally (weblog_build_required)."""
34-
return self.build_mode != BuildMode.none
23+
return self.build_mode != WeblogBuildMode.none
3524

3625
@property
3726
def base_dockerfile(self) -> Path | None:

utils/scripts/ci_orchestrators/workflow_data.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from collections import defaultdict
22
import json
33
from utils._context._scenarios import Scenario
4-
from utils._context.weblog_metadata import WeblogMetaData as Weblog, BuildMode
4+
from utils._context.weblog_metadata import WeblogMetaData as Weblog
5+
from utils._context.constants import WeblogBuildMode as BuildMode
56

67

78
def _load_json(file_path: str) -> dict:

0 commit comments

Comments
 (0)