Skip to content

Commit 71ff7a7

Browse files
committed
Skip AutoPkg recipe type convention checks when type is unknown
Closes #55
1 parent c9102c1 commit 71ff7a7

3 files changed

Lines changed: 44 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ All notable changes to this project will be documented in this file. This projec
1212

1313
## [Unreleased]
1414

15-
Nothing yet.
15+
### Changed
16+
17+
- Skipped AutoPkg recipe type convention checks when type is unknown. (#55)
1618

1719
## [1.24.0] - 2026-04-12
1820

pre_commit_macadmin_hooks/check_autopkg_recipes.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,19 @@ def validate_proc_type_conventions(process, filename):
451451
],
452452
}
453453

454+
# Extract all known recipe types from conventions
455+
all_known_types = []
456+
for recipe_group in proc_type_conventions:
457+
for recipe_type in recipe_group:
458+
all_known_types.append(f".{recipe_type}.")
459+
460+
# Skip validation if filename doesn't contain any known recipe type
461+
if not any(known_type in filename for known_type in all_known_types):
462+
print(
463+
f"{filename}: WARNING: Unknown recipe type. Skipping processor convention checks."
464+
)
465+
return True
466+
454467
passed = True
455468
processors = [x.get("Processor") for x in process]
456469
for recipe_group in proc_type_conventions:

tests/test_check_autopkg_recipes.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,34 @@ def test_validate_no_var_in_app_path_passes(self):
201201
result = target.validate_no_var_in_app_path(process, "file.recipe")
202202
self.assertTrue(result)
203203

204+
def test_validate_proc_type_conventions_unknown_type_passes(self):
205+
# Unknown recipe type should skip validation and pass with warning
206+
process = [{"Processor": "MunkiImporter"}]
207+
with mock.patch("builtins.print") as mock_print:
208+
result = target.validate_proc_type_conventions(process, "App.custom.recipe")
209+
self.assertTrue(result)
210+
mock_print.assert_called_with(
211+
"App.custom.recipe: WARNING: Unknown recipe type. Skipping processor convention checks."
212+
)
213+
214+
def test_validate_proc_type_conventions_known_type_wrong_processor_fails(self):
215+
# Munki processor in a download recipe should fail
216+
process = [{"Processor": "MunkiImporter"}]
217+
with mock.patch("builtins.print") as mock_print:
218+
result = target.validate_proc_type_conventions(
219+
process, "App.download.recipe"
220+
)
221+
self.assertFalse(result)
222+
mock_print.assert_called_with(
223+
"App.download.recipe: Processor MunkiImporter is not conventional for this recipe type."
224+
)
225+
226+
def test_validate_proc_type_conventions_known_type_correct_processor_passes(self):
227+
# Munki processor in a munki recipe should pass
228+
process = [{"Processor": "MunkiImporter"}]
229+
result = target.validate_proc_type_conventions(process, "App.munki.recipe")
230+
self.assertTrue(result)
231+
204232

205233
if __name__ == "__main__":
206234
unittest.main()

0 commit comments

Comments
 (0)