Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pre-commit-hooks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nimrod
pre-commit-hooks
Commits
2f72a978
Commit
2f72a978
authored
3 years ago
by
nimrod
Browse files
Options
Downloads
Patches
Plain Diff
fixup! Packer hooks.
parent
1d2851f1
No related branches found
No related tags found
No related merge requests found
Pipeline
#2491
passed
3 years ago
Stage: .pre
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.pre-commit-hooks.yaml
+1
-1
1 addition, 1 deletion
.pre-commit-hooks.yaml
README.md
+2
-1
2 additions, 1 deletion
README.md
hooks/packer_validate.py
+12
-1
12 additions, 1 deletion
hooks/packer_validate.py
with
15 additions
and
3 deletions
.pre-commit-hooks.yaml
+
1
−
1
View file @
2f72a978
...
@@ -42,7 +42,7 @@
...
@@ -42,7 +42,7 @@
description
:
Fix known backwards incompatibilities in Packer templates
description
:
Fix known backwards incompatibilities in Packer templates
language
:
python
language
:
python
entry
:
packer-fix
entry
:
packer-fix
types_or
:
[
json
,
hcl
]
types_or
:
[
json
]
-
id
:
packer-fmt
-
id
:
packer-fmt
name
:
Format Packer templates
name
:
Format Packer templates
...
...
This diff is collapsed.
Click to expand it.
README.md
+
2
−
1
View file @
2f72a978
...
@@ -55,7 +55,8 @@ Requires an installed `terraform`.
...
@@ -55,7 +55,8 @@ Requires an installed `terraform`.
### `packer-fix`
### `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`
### `packer-fmt`
...
...
This diff is collapsed.
Click to expand it.
hooks/packer_validate.py
+
12
−
1
View file @
2f72a978
...
@@ -6,6 +6,17 @@ import sys
...
@@ -6,6 +6,17 @@ import sys
import
hooks.utils
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
():
def
main
():
"""
Main entrypoint.
"""
"""
Main entrypoint.
"""
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
)
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
)
...
@@ -13,7 +24,7 @@ def main():
...
@@ -13,7 +24,7 @@ def main():
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
hooks
.
utils
.
check_executable
(
"
packer
"
)
hooks
.
utils
.
check_executable
(
"
packer
"
)
return
hooks
.
utils
.
bulk_check
(
return
hooks
.
utils
.
bulk_check
(
lambda
x
:
hooks
.
utils
.
check_file
([
"
packer
"
,
"
validate
"
,
x
])
,
packer
_
validate
,
args
.
file
,
args
.
file
,
)
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment