Skip to content

Commit f2f54be

Browse files
refactor: replace final string comparison with type-safe enum check
- Replace container platform check string comparison with enum comparison - Change `args.artifact_type == "container"` to `config.artifact_type == ArtifactType.CONTAINER` - Add comprehensive test coverage for enum comparisons and value access - Completes strangler fig migration of artifact type logic to type-safe enums This final change eliminates the last remaining string-based artifact type comparison in the container platform validation logic, completing the migration to type-safe enum comparisons throughout the orchestrator.
1 parent 9e83ef5 commit f2f54be

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

entrypoint/entrypoint/orchestrator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def invoke_sbomgen(args) -> int:
204204
sbomgen_args.append("--skip-files")
205205
sbomgen_args.append(args.skip_files)
206206

207-
if args.artifact_type == "container":
207+
if config.artifact_type == ArtifactType.CONTAINER:
208208

209209
if args.platform:
210210
platform_arg = args.platform.lower()

entrypoint/tests/test_data_model.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,16 @@ def test_scan_config_binary_type_comparison():
7878
def test_scan_config_archive_type_comparison():
7979
config = ScanConfig(artifact_type=ArtifactType.ARCHIVE)
8080
assert config.artifact_type == ArtifactType.ARCHIVE
81+
82+
def test_scan_config_container_platform_check():
83+
config = ScanConfig(artifact_type=ArtifactType.CONTAINER)
84+
assert config.artifact_type == ArtifactType.CONTAINER
85+
86+
def test_scan_config_artifact_type_value():
87+
config = ScanConfig(artifact_type=ArtifactType.REPOSITORY)
88+
assert config.artifact_type.value == "repository"
89+
90+
def test_scan_config_display_mapping():
91+
config = ScanConfig(artifact_type=ArtifactType.REPOSITORY)
92+
display_type = "repository" if config.artifact_type == ArtifactType.REPOSITORY else config.artifact_type.value
93+
assert display_type == "repository"

0 commit comments

Comments
 (0)