Skip to content

Commit a76834b

Browse files
committed
Add required keys and uninstall_method check to AutoPkg munki recipes
1 parent d678f58 commit a76834b

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

CHANGELOG.md

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

1313
## [Unreleased]
1414

15+
### Added
16+
17+
- `check-autopkg-recipes` requires Munki recipe `pkginfo` dicts to contain at least `name` and `description`.
18+
- `check-autopkg-recipes` now validates that `uninstall_method` and `uninstall_script` are set appropriately in Munki recipes.
19+
1520
### Changed
1621

17-
- Add jamf-upload as an AutoPkg recipe type, and updated processors included in jamf/jamf-upload recipe convention.
22+
- `check-autopkg-recipes` includes jamf-upload as an AutoPkg recipe type, and updated processors included in jamf/jamf-upload recipe convention.
23+
- `check-munki-pkgsinfo` requires a `version` key in addition to `name` and `description`.
1824

1925
## [1.18.0] - 2025-01-04
2026

pre_commit_hooks/check_autopkg_recipes.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
validate_pkginfo_key_types,
1717
validate_required_keys,
1818
validate_restart_action_key,
19+
validate_uninstall_method,
1920
)
2021

2122

@@ -580,6 +581,7 @@ def main(argv=None):
580581
# recipe_text = openfile.read()
581582

582583
# Top level keys that all AutoPkg recipes should contain.
584+
# TODO: Make required recipe keys configurable.
583585
required_keys = ["Identifier"]
584586
if not validate_required_keys(recipe, filename, required_keys):
585587
retval = 1
@@ -615,12 +617,30 @@ def main(argv=None):
615617
# If the Input key contains a pkginfo dict, make a best effort to validate its contents.
616618
input_key = recipe.get("Input", recipe.get("input", recipe.get("INPUT")))
617619
if input_key and "pkginfo" in input_key:
620+
621+
# Check for presence of required pkginfo keys.
622+
# TODO: Make required pkginfo keys within a recipe configurable.
623+
req_keys = ["name", "description"]
624+
if not validate_required_keys(input_key["pkginfo"], filename, req_keys):
625+
retval = 1
626+
627+
# Ensure pkginfo keys have expected types.
618628
if not validate_pkginfo_key_types(input_key["pkginfo"], filename):
619629
retval = 1
630+
631+
# Validate RestartAction key.
620632
if not validate_restart_action_key(input_key["pkginfo"], filename):
621633
retval = 1
634+
635+
# Validate uninstall method.
636+
if not validate_uninstall_method(input_key["pkginfo"], filename):
637+
retval = 1
638+
639+
# Check for deprecated pkginfo keys.
622640
if not detect_deprecated_keys(input_key["pkginfo"], filename):
623641
retval = 1
642+
643+
# Check for common mistakes in key names.
624644
if not detect_typoed_keys(input_key["pkginfo"], filename):
625645
retval = 1
626646

0 commit comments

Comments
 (0)