Skip to content
Commits on Source (2)
...@@ -50,7 +50,7 @@ repos: ...@@ -50,7 +50,7 @@ repos:
- id: mdformat - id: mdformat
- repo: https://github.com/ambv/black.git - repo: https://github.com/ambv/black.git
rev: 21.8b0 rev: 23.12.1
hooks: hooks:
- id: black - id: black
args: args:
...@@ -58,7 +58,7 @@ repos: ...@@ -58,7 +58,7 @@ repos:
--line-length=79 --line-length=79
- repo: https://github.com/PyCQA/prospector.git - repo: https://github.com/PyCQA/prospector.git
rev: 1.5.3 rev: v1.10.3
hooks: hooks:
- id: prospector - id: prospector
args: args:
...@@ -81,7 +81,7 @@ repos: ...@@ -81,7 +81,7 @@ repos:
additional_dependencies: additional_dependencies:
- bandit - bandit
- repo: https://gitlab.com/pycqa/flake8.git - repo: https://github.com/pycqa/flake8.git
rev: 3.9.2 rev: 3.9.2
hooks: hooks:
- id: flake8 - id: flake8
......
...@@ -7,16 +7,19 @@ import sys ...@@ -7,16 +7,19 @@ import sys
import hooks.utils import hooks.utils
TF_CLI = os.getenv("TF_CLI", "terraform")
def main(): def main():
"""Main entrypoint.""" """Main entrypoint."""
parser = argparse.ArgumentParser(description=__doc__) parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("file", nargs="+", type=pathlib.Path) parser.add_argument("file", nargs="+", type=pathlib.Path)
args = parser.parse_args() args = parser.parse_args()
hooks.utils.check_executable("terraform") hooks.utils.check_executable(TF_CLI)
os.putenv("TF_INPUT", "0") os.putenv("TF_INPUT", "0")
os.putenv("TF_IN_AUTOMATION", "1") os.putenv("TF_IN_AUTOMATION", "1")
return hooks.utils.bulk_check( 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.utils.unique_directories(args.file),
) )
......
...@@ -7,18 +7,23 @@ import sys ...@@ -7,18 +7,23 @@ import sys
import hooks.utils 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 ( if (
hooks.utils.check_directory( hooks.utils.check_directory(
["terraform", "init", "-backend=false"], directory=directory [TF_CLI, "init", "-backend=false"], directory=directory
) )
> 0 > 0
): ):
return 1 return 1
if ( if (
hooks.utils.check_directory( hooks.utils.check_directory([TF_CLI, "validate"], directory=directory)
["terraform", "validate"], directory=directory
)
> 0 > 0
): ):
return 1 return 1
......