Browse code

Validate toml

Docker-DCO-1.1-Signed-off-by: Jessie Frazelle <princess@docker.com> (github: jfrazelle)

Docker-DCO-1.1-Signed-off-by: Jessie Frazelle <hugs@docker.com> (github: jfrazelle)

Jessica Frazelle authored on 2015/01/31 04:45:02
Showing 5 changed files
... ...
@@ -10,5 +10,5 @@ script:
10 10
   - rm integration-cli/docker_cli_daemon_test.go
11 11
   - rm integration-cli/docker_cli_exec_test.go 
12 12
 # Validate and test.
13
-  - hack/make.sh validate-dco validate-gofmt
13
+  - hack/make.sh validate-dco validate-gofmt validate-toml
14 14
   - hack/make.sh binary cross test-unit test-integration-cli test-integration test-docker-py
... ...
@@ -155,6 +155,10 @@ RUN set -x \
155 155
 	&& git clone -b v1.2 https://github.com/russross/blackfriday.git /go/src/github.com/russross/blackfriday \
156 156
 	&& go install -v github.com/cpuguy83/go-md2man
157 157
 
158
+# install toml validator
159
+RUN git clone -b v0.1.0 https://github.com/BurntSushi/toml.git /go/src/github.com/BurntSushi/toml \
160
+    && go install -v github.com/BurntSushi/toml/cmd/tomlv
161
+
158 162
 # Wrap all commands in the "docker-in-docker" script to allow nested containers
159 163
 ENTRYPOINT ["hack/dind"]
160 164
 
... ...
@@ -74,7 +74,7 @@ test-docker-py: build
74 74
 	$(DOCKER_RUN_DOCKER) hack/make.sh binary test-docker-py
75 75
 
76 76
 validate: build
77
-	$(DOCKER_RUN_DOCKER) hack/make.sh validate-gofmt validate-dco
77
+	$(DOCKER_RUN_DOCKER) hack/make.sh validate-gofmt validate-dco validate-toml
78 78
 
79 79
 shell: build
80 80
 	$(DOCKER_RUN_DOCKER) bash
... ...
@@ -44,6 +44,7 @@ echo
44 44
 DEFAULT_BUNDLES=(
45 45
 	validate-dco
46 46
 	validate-gofmt
47
+	validate-toml
47 48
 
48 49
 	binary
49 50
 
50 51
new file mode 100644
... ...
@@ -0,0 +1,30 @@
0
+#!/bin/bash
1
+
2
+source "$(dirname "$BASH_SOURCE")/.validate"
3
+
4
+IFS=$'\n'
5
+files=( $(validate_diff --diff-filter=ACMR --name-only -- 'MAINTAINERS' || true) )
6
+unset IFS
7
+
8
+badFiles=()
9
+for f in "${files[@]}"; do
10
+	# we use "git show" here to validate that what's committed is formatted
11
+	if [ "$(git show "$VALIDATE_HEAD:$f" | tomlv)" ]; then
12
+		badFiles+=( "$f" )
13
+	fi
14
+done
15
+
16
+if [ ${#badFiles[@]} -eq 0 ]; then
17
+	echo 'Congratulations!  All toml source files have valid syntax.'
18
+else
19
+	{
20
+		echo "These files are not valid toml:"
21
+		for f in "${badFiles[@]}"; do
22
+			echo " - $f"
23
+		done
24
+		echo
25
+		echo 'Please reformat the above files as valid toml'
26
+		echo
27
+	} >&2
28
+	false
29
+fi