Commit 0c83218e authored by nimrod's avatar nimrod
Browse files

A few fixes from the improved tests.

- Add the hooks package.
- Refactor and fix the bulk_check function.
parent 313d052e
Loading
Loading
Loading
Loading
Loading
+18 −19
Original line number Diff line number Diff line
@@ -7,25 +7,24 @@ import sys
import hooks.utils


def checker():
    def check(directory):
def tf_validate(directory):
    if (
            hooks.utils.check(
        hooks.utils.check_directory(
            ["terraform", "init", "-backend=false"], directory=directory
        )
        > 0
    ):
        return 1
    if (
            hooks.utils.check(["terraform", "validate"], directory=directory)
        hooks.utils.check_directory(
            ["terraform", "validate"], directory=directory
        )
        > 0
    ):
        return 1

    return 0

    return check


def main():
    """Main entrypoint."""
@@ -36,7 +35,7 @@ def main():
    os.putenv("TF_INPUT", "0")
    os.putenv("TF_IN_AUTOMATION", "1")
    return hooks.utils.bulk_check(
        checker, hooks.utils.unique_directories(args.file)
        tf_validate, hooks.utils.unique_directories(args.file)
    )


+1 −1
Original line number Diff line number Diff line
@@ -85,6 +85,6 @@ def bulk_check(checker, items):
    returncode = 0
    for item in items:
        check = checker(item)
        if check() > 0:
        if check > 0:
            returncode = 1
    return returncode
+2 −1
Original line number Diff line number Diff line
from setuptools import setup
from setuptools import setup, find_packages

with open("VERSION", "r", encoding="utf-8") as fh:
    VERSION = fh.read().strip()
@@ -23,4 +23,5 @@ setup(
            "poetry-check=hook.poetry_check:main",
        ]
    },
    packages=find_packages(),
)