diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..64f8262 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,8 @@ +minimum_pre_commit_version: "3.6.0" + +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml new file mode 100644 index 0000000..4505faa --- /dev/null +++ b/.pre-commit-hooks.yaml @@ -0,0 +1,19 @@ +- id: terraform-fmt + name: Format Terraform files + entry: /usr/local/bin/terraform + language: docker + args: + - "fmt" + pass_filenames: false + +- id: terraform-docs + name: Genration of Terraform module documentation + entry: /usr/local/bin/terraform-docs + language: docker + args: + - "markdown" + - "table" + - "." + - "--output-file" + - "README.md" + pass_filenames: false diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3b0e8f8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM alpine:latest as build +WORKDIR /src +RUN wget -q https://releases.hashicorp.com/terraform/1.6.6/terraform_1.6.6_linux_amd64.zip && unzip *.zip +RUN wget -q https://terraform-docs.io/dl/v0.16.0/terraform-docs-v0.16.0-$(uname)-amd64.tar.gz && tar xzf *.tar.gz + +FROM scratch +COPY --from=build /src/terraform /usr/local/bin/ +COPY --from=build /src/terraform-docs /usr/local/bin/ +ENTRYPOINT ["/usr/local/bin/terraform"] diff --git a/README.md b/README.md index c0c020c..d2d8bf6 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # pre-commit-terraform -pre-commit git hooks about Terraform stacks or modules. \ No newline at end of file +pre-commit git hooks about Terraform stacks or modules.