Skip to content

Commit d038837

Browse files
authored
Merge pull request #12 from scality/improvement/add_pattern_based_deletion
✨ add deletion for superseded project with dev suffix in parent's version
2 parents 97006d2 + 419df32 commit d038837

6 files changed

Lines changed: 240 additions & 24 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
samples/
66
results/
77

8+
# Local workflow reproduction scripts (intentionally untracked)
9+
tests/custom/*
10+
811
### Linux ###
912
*~
1013

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ pip install -r requirements.txt
123123
| `project-prefix` || Prefix for project names | `ci-` |
124124
| `project-suffix` || Suffix for project names | `-prod` |
125125
| `project-tags` || Comma-separated tags | `production,ci-cd` |
126+
| `delete-on-version-suffix-match` || Delete existing leaf project when version matches suffix pattern (default `false`) | `true` |
127+
| `delete-version-suffix-pattern` || Case-insensitive regex evaluated against project version when delete is enabled (default `dev`) | `dev$` |
126128

127129
*One of `project-sbom`, `project-sbom-list`, or `project-sbom-dir` is required.
128130

src/config/config.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ class AppConfig: # pylint: disable=too-many-instance-attributes
3636
(default: "AGGREGATE_LATEST_VERSION_CHILDREN")
3737
api_timeout (int): API request timeout in seconds (default: 300)
3838
dry_run (bool): If True, perform a dry run without making changes (default: False)
39+
delete_on_version_suffix_match (bool): Delete existing project when version matches suffix pattern
40+
delete_version_suffix_pattern (str): Regex pattern (case-insensitive) used to detect versions
3941
Raises:
4042
ConfigurationError: If required configuration is missing or invalid
4143
ValidationError: If validation of specific fields fails
@@ -71,6 +73,8 @@ class AppConfig: # pylint: disable=too-many-instance-attributes
7173
is_latest: bool = False
7274
auto_detect_latest: bool = True
7375
dry_run: bool = False
76+
delete_on_version_suffix_match: bool = False
77+
delete_version_suffix_pattern: str = "dev"
7478

7579
# Tags
7680
project_tags: Optional[str] = None
@@ -203,6 +207,12 @@ def from_environment(cls) -> "AppConfig":
203207
).strip(),
204208
hierarchy_input_dir=os.getenv("INPUT_HIERARCHY_INPUT_DIR", "").strip() or None,
205209
api_timeout=int(os.getenv("INPUT_API_TIMEOUT", "300").strip()),
210+
delete_on_version_suffix_match=(
211+
os.getenv("INPUT_DELETE_ON_VERSION_SUFFIX_MATCH", "false").strip().lower() == "true"
212+
),
213+
delete_version_suffix_pattern=(
214+
os.getenv("INPUT_DELETE_VERSION_SUFFIX_PATTERN", "dev").strip() or "dev"
215+
),
206216
)
207217

208218
def validate_for_upload(self) -> None:

src/domain/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@ class HTTPStatus(Enum): # pylint: disable=too-few-public-methods
1717

1818
OK = 200
1919
CREATED = 201
20+
NO_CONTENT = 204
2021
UNAUTHORIZED = 401
2122
FORBIDDEN = 403
23+
CONFLICT = 409

0 commit comments

Comments
 (0)