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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nimrod
pre-commit-hooks
Compare revisions
ec2f69d0fc91ca845e8c4a8c6071f36b1d540eaf to ef8ef3d4d65202d220ecc90bc21c240427b9b156
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
nimrod/pre-commit-hooks
Select target project
No results found
ef8ef3d4d65202d220ecc90bc21c240427b9b156
Select Git revision
Loading items
Swap
Target
nimrod/pre-commit-hooks
Select target project
nimrod/pre-commit-hooks
1 result
ec2f69d0fc91ca845e8c4a8c6071f36b1d540eaf
Select Git revision
Loading items
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (2)
pre-commit: Small update.
· fa7b5fb8
nimrod
authored
1 year ago
fa7b5fb8
Allow using a different Terraform binary.
· ef8ef3d4
nimrod
authored
1 year ago
In case you're using a different CLI, like `tofu`.
ef8ef3d4
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
.pre-commit-config.yaml
+3
-3
3 additions, 3 deletions
.pre-commit-config.yaml
hooks/terraform_fmt.py
+5
-2
5 additions, 2 deletions
hooks/terraform_fmt.py
hooks/terraform_validate.py
+10
-5
10 additions, 5 deletions
hooks/terraform_validate.py
with
18 additions
and
10 deletions
.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
...
...
This diff is collapsed.
Click to expand it.
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
),
)
...
...
This diff is collapsed.
Click to expand it.
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
...
...
This diff is collapsed.
Click to expand it.