Skip to content
GitLab
Explore
Sign in
Register
nimrod
pre-commit-hooks
Compare revisions
ec2f69d0fc91ca845e8c4a8c6071f36b1d540eaf to ef8ef3d4d65202d220ecc90bc21c240427b9b156
Commits on Source (2)
pre-commit: Small update.
· fa7b5fb8
nimrod
authored
Dec 28, 2023
fa7b5fb8
Allow using a different Terraform binary.
· ef8ef3d4
nimrod
authored
Dec 28, 2023
In case you're using a different CLI, like `tofu`.
ef8ef3d4
Hide whitespace changes
Inline
Side-by-side
.pre-commit-config.yaml
View file @
ef8ef3d4
...
...
@@ -50,7 +50,7 @@ repos:
-
id
:
mdformat
-
repo
:
https://github.com/ambv/black.git
rev
:
2
1.8b0
rev
:
2
3.12.1
hooks
:
-
id
:
black
args
:
...
...
@@ -58,7 +58,7 @@ repos:
--line-length=79
-
repo
:
https://github.com/PyCQA/prospector.git
rev
:
1.
5
.3
rev
:
v
1.
10
.3
hooks
:
-
id
:
prospector
args
:
...
...
@@ -81,7 +81,7 @@ repos:
additional_dependencies
:
-
bandit
-
repo
:
https://git
la
b.com/pycqa/flake8.git
-
repo
:
https://git
hu
b.com/pycqa/flake8.git
rev
:
3.9.2
hooks
:
-
id
:
flake8
...
...
hooks/terraform_fmt.py
View file @
ef8ef3d4
...
...
@@ -7,16 +7,19 @@ import sys
import
hooks.utils
TF_CLI
=
os
.
getenv
(
"
TF_CLI
"
,
"
terraform
"
)
def
main
():
"""
Main entrypoint.
"""
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
)
parser
.
add_argument
(
"
file
"
,
nargs
=
"
+
"
,
type
=
pathlib
.
Path
)
args
=
parser
.
parse_args
()
hooks
.
utils
.
check_executable
(
"
terraform
"
)
hooks
.
utils
.
check_executable
(
TF_CLI
)
os
.
putenv
(
"
TF_INPUT
"
,
"
0
"
)
os
.
putenv
(
"
TF_IN_AUTOMATION
"
,
"
1
"
)
return
hooks
.
utils
.
bulk_check
(
lambda
x
:
hooks
.
utils
.
check_file
([
"
terraform
"
,
"
fmt
"
,
"
-diff
"
,
x
]),
lambda
x
:
hooks
.
utils
.
check_file
([
TF_CLI
,
"
fmt
"
,
"
-diff
"
,
x
]),
hooks
.
utils
.
unique_directories
(
args
.
file
),
)
...
...
hooks/terraform_validate.py
View file @
ef8ef3d4
...
...
@@ -7,18 +7,23 @@ import sys
import
hooks.utils
def
tf_validate
(
directory
):
TF_CLI
=
os
.
getenv
(
"
TF_CLI
"
,
"
terraform
"
)
def
tf_validate
(
directory
):
# noqa: D213
"""
Validate Terraform modules.
Also runs init -backend=false to install the providers.
"""
if
(
hooks
.
utils
.
check_directory
(
[
"
terraform
"
,
"
init
"
,
"
-backend=false
"
],
directory
=
directory
[
TF_CLI
,
"
init
"
,
"
-backend=false
"
],
directory
=
directory
)
>
0
):
return
1
if
(
hooks
.
utils
.
check_directory
(
[
"
terraform
"
,
"
validate
"
],
directory
=
directory
)
hooks
.
utils
.
check_directory
([
TF_CLI
,
"
validate
"
],
directory
=
directory
)
>
0
):
return
1
...
...