Description
Hello,
I am trying to implement pre-commit-terraform tflint fmt and checkov but I am facing issues when trying to execute it when running everything on docker image.
To be a bit more specific I just build image with dependencies and created .git/hooks/pre-push script manually:
# Dockerfile
(...)
WORKDIR /pre-commit
CMD ["pre-commit", "run", "--hook-stage", "push"]
# .git/hooks/pre-push
(...)
docker run -t -v "$(pwd)":/pre-commit --name "$NAME" my-image:latest
This is how my .pre-commit-config.yamls looks like:
# .pre-commit-config.yaml
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.70.0
hooks:
- id: terraform_tflint
stages:
- push
- id: terraform_checkov
stages:
- push
This surprisingly works very well when trying same solution for commit stage, but it sees no diff when its set push and its getting always "skipped". I saw there is a dedicated docker image but if I am correct there is no easy way for implementation in pre-commit-config.yaml to do the same but via docker image to get rid off dependencies.
How could pre-commit-terraform help solve your problem?
It would be great to have possibility to have hooks preconfigured with docker image and just run following without worrying about dependencies:
#.pre-commit-config.yamls
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.70.0
hooks:
- id: terraform_tflint_docker
- id: terraform_checkov_docker