From c7c149c061a870fc47bb202e6ce941751750f5ea Mon Sep 17 00:00:00 2001
From: Ryan Kowalewski <rk725@cam.ac.uk>
Date: Wed, 1 Nov 2023 19:06:57 +0000
Subject: [PATCH] chore: add .pre-commit-config.yaml

---
 .pre-commit-config.yaml | 51 +++++++++++++++++++++++++++++++++++++++++
 .tflint.hcl             |  4 ++++
 2 files changed, 55 insertions(+)
 create mode 100644 .pre-commit-config.yaml
 create mode 100644 .tflint.hcl

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 0000000..923edf4
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,51 @@
+# See https://pre-commit.com/hooks.html for more hooks
+repos:
+  - repo: https://github.com/pre-commit/pre-commit-hooks
+    rev: v4.4.0
+    hooks:
+      - id: trailing-whitespace
+      - id: end-of-file-fixer
+      - id: check-yaml
+        args:
+          - --unsafe
+      - id: check-json
+      - id: check-toml
+      - id: check-xml
+      - id: check-added-large-files
+      - id: check-executables-have-shebangs
+      - id: check-merge-conflict
+      - id: check-symlinks
+      - id: detect-private-key
+      - id: mixed-line-ending
+      - id: pretty-format-json
+        args:
+          - --autofix
+          - --no-sort-keys
+      - id: debug-statements
+  - repo: https://github.com/DavidAnson/markdownlint-cli2
+    rev: v0.12.1
+    hooks:
+      # For rule definitions see https://github.com/markdownlint/markdownlint/blob/main/docs/RULES.md
+      - id: markdownlint-cli2
+        # Exclude README.md and CHANGELOG.md as they are auto-generated and contain a bunch of illegal HTML etc. We lint
+        # the source *.md files in ./docs though so at least our pure markdown is being checked.
+        exclude: (README|CHANGELOG).md
+  - repo: local
+    hooks:
+      - id: terraform-fmt
+        name: terraform-fmt
+        language: docker_image
+        pass_filenames: false
+        entry: registry.gitlab.developers.cam.ac.uk/uis/devops/infra/dockerimages/logan-terraform:1.6 terraform fmt
+      - id: tflint
+        name: tflint
+        language: docker_image
+        pass_filenames: false
+        entry: ghcr.io/terraform-linters/tflint:latest
+        args: []
+      - id: trivy
+        name: trivy
+        language: docker_image
+        pass_filenames: false
+        entry: aquasec/trivy:latest
+        args: ["--cache-dir", "/tmp/.trivy-cache", "--skip-dirs", "tests", "config", ".", "--exit-code", "1"]
diff --git a/.tflint.hcl b/.tflint.hcl
new file mode 100644
index 0000000..b8edc99
--- /dev/null
+++ b/.tflint.hcl
@@ -0,0 +1,4 @@
+plugin "terraform" {
+  enabled = true
+  preset  = "all"
+}
-- 
GitLab