Loading .pre-commit-hooks.yaml +1 −1 Original line number Diff line number Diff line Loading @@ -42,7 +42,7 @@ description: Fix known backwards incompatibilities in Packer templates language: python entry: packer-fix types_or: [json, hcl] types_or: [json] - id: packer-fmt name: Format Packer templates Loading README.md +2 −1 Original line number Diff line number Diff line Loading @@ -55,7 +55,8 @@ Requires an installed `terraform`. ### `packer-fix` Fix known backwards incompatibilities in Packer templates. Fix known backwards incompatibilities in Packer templates (just JSON files, until support for HCL files is added in Packer). ### `packer-fmt` Loading hooks/packer_validate.py +12 −1 Original line number Diff line number Diff line Loading @@ -6,6 +6,17 @@ import sys import hooks.utils def packer_validate(file): """Validate a Packer template. Run init when needed. """ if str(file).endswith(".pkr.hcl") or str(file).endswith(".pkr.json"): if hooks.utils.check_file(["packer", "init", file]) > 0: return 1 return hooks.utils.check_file(["packer", "validate", file]) def main(): """Main entrypoint.""" parser = argparse.ArgumentParser(description=__doc__) Loading @@ -13,7 +24,7 @@ def main(): args = parser.parse_args() hooks.utils.check_executable("packer") return hooks.utils.bulk_check( lambda x: hooks.utils.check_file(["packer", "validate", x]), packer_validate, args.file, ) Loading Loading
.pre-commit-hooks.yaml +1 −1 Original line number Diff line number Diff line Loading @@ -42,7 +42,7 @@ description: Fix known backwards incompatibilities in Packer templates language: python entry: packer-fix types_or: [json, hcl] types_or: [json] - id: packer-fmt name: Format Packer templates Loading
README.md +2 −1 Original line number Diff line number Diff line Loading @@ -55,7 +55,8 @@ Requires an installed `terraform`. ### `packer-fix` Fix known backwards incompatibilities in Packer templates. Fix known backwards incompatibilities in Packer templates (just JSON files, until support for HCL files is added in Packer). ### `packer-fmt` Loading
hooks/packer_validate.py +12 −1 Original line number Diff line number Diff line Loading @@ -6,6 +6,17 @@ import sys import hooks.utils def packer_validate(file): """Validate a Packer template. Run init when needed. """ if str(file).endswith(".pkr.hcl") or str(file).endswith(".pkr.json"): if hooks.utils.check_file(["packer", "init", file]) > 0: return 1 return hooks.utils.check_file(["packer", "validate", file]) def main(): """Main entrypoint.""" parser = argparse.ArgumentParser(description=__doc__) Loading @@ -13,7 +24,7 @@ def main(): args = parser.parse_args() hooks.utils.check_executable("packer") return hooks.utils.bulk_check( lambda x: hooks.utils.check_file(["packer", "validate", x]), packer_validate, args.file, ) Loading