Skip to content

Commit 0088ee1

Browse files
committed
Validate Munki supported_architectures values
1 parent 8509f90 commit 0088ee1

4 files changed

Lines changed: 25 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ All notable changes to this project will be documented in this file. This projec
1616

1717
- `check-autopkg-recipes` requires Munki recipe `pkginfo` dicts to contain at least `name` and `description`.
1818
- `check-autopkg-recipes` now validates that `uninstall_method` and `uninstall_script` are set appropriately in Munki recipes.
19+
- `check-autopkg-recipes` and `check-munki-pkgsinfo` now validates that `supported_architectures` values are set appropriately.
1920

2021
### Changed
2122

pre_commit_hooks/check_autopkg_recipes.py

Lines changed: 5 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_supported_architectures,
1920
validate_uninstall_method,
2021
)
2122

@@ -636,6 +637,10 @@ def main(argv=None):
636637
if not validate_uninstall_method(input_key["pkginfo"], filename):
637638
retval = 1
638639

640+
# Validate supported architectures.
641+
if not validate_supported_architectures(input_key["pkginfo"], filename):
642+
retval = 1
643+
639644
# Check for deprecated pkginfo keys.
640645
if not detect_deprecated_keys(input_key["pkginfo"], filename):
641646
retval = 1

pre_commit_hooks/check_munki_pkgsinfo.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
validate_required_keys,
1515
validate_restart_action_key,
1616
validate_shebangs,
17+
validate_supported_architectures,
1718
validate_uninstall_method,
1819
)
1920

@@ -122,6 +123,10 @@ def main(argv=None):
122123
if not validate_uninstall_method(pkginfo, filename):
123124
retval = 1
124125

126+
# Validate supported architectures.
127+
if not validate_supported_architectures(pkginfo, filename):
128+
retval = 1
129+
125130
# Check for deprecated pkginfo keys.
126131
if not detect_deprecated_keys(pkginfo, filename):
127132
retval = 1

pre_commit_hooks/util.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,20 @@ def validate_uninstall_method(pkginfo, filename):
178178
return passed
179179

180180

181+
def validate_supported_architectures(pkginfo, filename):
182+
"""Verifies that supported_architectures values are valid."""
183+
passed = True
184+
allowed_values = ("arm64", "x86_64")
185+
if "supported_architectures" in pkginfo:
186+
for arch in pkginfo["supported_architectures"]:
187+
if arch not in allowed_values:
188+
print(
189+
f"{filename}: supported_architectures contains unexpected value: {arch}"
190+
)
191+
passed = False
192+
return passed
193+
194+
181195
def validate_pkginfo_key_types(pkginfo, filename):
182196
"""Validation of pkginfo key types.
183197

0 commit comments

Comments
 (0)