Browse Source

Working commit

tags/v1.0.0
IamTheFij 1 year ago
parent
commit
16df7e8c2f
3 changed files with 41 additions and 0 deletions
  1. 6
    0
      .pre-commit-hooks.yaml
  2. 29
    0
      compose-check.sh
  3. 6
    0
      hooks.yaml

+ 6
- 0
.pre-commit-hooks.yaml View File

@@ -0,0 +1,6 @@
1
+- id: docker-compose-check
2
+  name: Validate docker-compose files
3
+  description: Checks that vault files are encrypted
4
+  entry: compose-check.sh
5
+  files: docker-compose.y[a]{0,1}ml$
6
+  language: script

+ 29
- 0
compose-check.sh View File

@@ -0,0 +1,29 @@
1
+#! /bin/bash
2
+# Verifies that files passed in are valid for docker-compose
3
+set -e
4
+
5
+check_file() {
6
+    local file=$1
7
+    docker-compose -f "$file" config -q 2>&1 \
8
+        | sed "/variable is not set. Defaulting/d"
9
+    return ${PIPESTATUS[0]}
10
+}
11
+
12
+check_files() {
13
+    local all_files=$@
14
+    has_error=0
15
+    for file in $all_files ; do
16
+        if [[ -f "$file" ]]; then
17
+            if ! check_file "$file" ; then
18
+                has_error=1
19
+            fi
20
+        fi
21
+    done
22
+    return $has_error
23
+}
24
+
25
+if ! check_files $@ ; then
26
+    echo "To ignore, use --no-verify"
27
+fi
28
+
29
+exit $has_error

+ 6
- 0
hooks.yaml View File

@@ -0,0 +1,6 @@
1
+- id: docker-compose-check
2
+  name: Validate docker-compose files
3
+  description: Checks that vault files are encrypted
4
+  entry: compose-check.sh
5
+  files: docker-compose.y[a]{0,1}ml$
6
+  language: script

Loading…
Cancel
Save