Skip to content

Commit ffe2db5

Browse files
committed
Add check for conventional order of JamfUploader processors
1 parent ecabd99 commit ffe2db5

2 files changed

Lines changed: 46 additions & 2 deletions

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+
### Added
16+
17+
- Check for the [recommended order](https://youtu.be/srz4U9RHliQ?list=PLlxHm_Px-Ie1EIRlDHG2lW5H7c2UYvops&t=1010) of JamfUploader processors.
1618

1719
## [1.11.0] - 2021-11-20
1820

pre_commit_hooks/check_autopkg_recipes.py

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,46 @@ def validate_no_superclass_procs(process, filename):
279279
return passed
280280

281281

282+
def validate_jamf_processor_order(process, filename):
283+
"""Warn if JamfUploader processors are not in their conventional order.
284+
https://youtu.be/srz4U9RHliQ?list=PLlxHm_Px-Ie1EIRlDHG2lW5H7c2UYvops&t=1010
285+
"""
286+
287+
# Recommended order of Jamf processors
288+
rec_order = (
289+
"com.github.grahampugh.jamf-upload.processors/JamfCategoryUploader",
290+
"com.github.grahampugh.jamf-upload.processors/JamfExtensionAttributeUploader",
291+
"com.github.grahampugh.jamf-upload.processors/JamfPackageUploader",
292+
"com.github.grahampugh.jamf-upload.processors/JamfScriptUploader",
293+
"com.github.grahampugh.jamf-upload.processors/JamfComputerGroupUploader",
294+
# TODO: The three below may depend on computer groups, but there's no
295+
# easy way to ignore relative order if multiple are used. Focusing on
296+
# JamfPolicyUploader only for now.
297+
"com.github.grahampugh.jamf-upload.processors/JamfPolicyUploader",
298+
# "com.github.grahampugh.jamf-upload.processors/JamfComputerProfileUploader",
299+
# "com.github.grahampugh.jamf-upload.processors/JamfSoftwareRestrictionUploader",
300+
)
301+
302+
passed = True
303+
# All JamfUploader processors in recipe, ignoring duplicates, preserving order.
304+
actual_order = list(
305+
dict.fromkeys(
306+
[x.get("Processor") for x in process if x.get("Processor") in rec_order]
307+
)
308+
)
309+
desired_order = [x for x in rec_order if x in actual_order]
310+
if desired_order != actual_order:
311+
print(
312+
"{}: WARNING: JamfUploader processors are not in "
313+
"the recommended order: {}.".format(
314+
filename,
315+
", ".join([x.split("/")[-1] for x in desired_order]),
316+
)
317+
)
318+
319+
return passed
320+
321+
282322
# def validate_unused_input_vars(recipe, recipe_text, filename):
283323
# """Warn if any input variables are not referenced in the recipe."""
284324

@@ -367,7 +407,6 @@ def validate_proc_type_conventions(process, filename):
367407
"com.github.grahampugh.jamf-upload.processors/JamfPolicyUploader",
368408
"com.github.grahampugh.jamf-upload.processors/JamfScriptUploader",
369409
"com.github.grahampugh.jamf-upload.processors/JamfSoftwareRestrictionUploader",
370-
"com.github.grahampugh.jamf-upload.processors/JamfUploaderSlacker",
371410
],
372411
# https://github.com/autopkg/filewave
373412
"filewave": ["FileWaveImporter"],
@@ -610,6 +649,9 @@ def main(argv=None):
610649
if not validate_no_superclass_procs(process, filename):
611650
retval = 1
612651

652+
if not validate_jamf_processor_order(process, filename):
653+
retval = 1
654+
613655
if HAS_AUTOPKGLIB:
614656
if not validate_proc_args(process, filename):
615657
retval = 1

0 commit comments

Comments
 (0)