File tree Expand file tree Collapse file tree 2 files changed +26
-9
lines changed Expand file tree Collapse file tree 2 files changed +26
-9
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,14 @@ Provides the following hooks:
41
41
3 . Run ` pre-commit install ` to add pre-commit git hooks. You can also run
42
42
` pre-commit run --all-files ` , which is useful as part of your tests.
43
43
44
- Note that currently it's only possible to use the Puppet 3 parser for
45
- validation. The Puppet 4 parser has many changes, and it's planned to have a
46
- separate branch for Puppet 4 hooks in the future.
44
+ To use the future parser with validation, just pass it as an argument
45
+ to the ` puppet-validate ` hook:
46
+
47
+ - id: puppet-validate
48
+ args: [--parser=future]
49
+
50
+ This option will only work for Puppet 3. For Puppet 4, just use a
51
+ updated version of ` puppet ` to run these hooks and remove the argument.
52
+
53
+ Any other arguments to ` puppet-validate ` will be fed directly to
54
+ ` puppet parser validate ` , as long as they are in the format ` --arg=value ` .
Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bash
2
2
set -eu
3
3
4
+ options=" "
5
+ opts_regex=" ^--.+=.+$"
6
+
4
7
status=0
5
- for path in " $@ " ; do
6
- output=$( puppet parser validate -- " $path " 2>&1 ) || {
7
- echo -e " \033[31m\033[1m$path : failed Puppet validation\033[0m"
8
- echo " $output "
9
- status=1
10
- }
8
+ for arg in " $@ " ; do
9
+ # Check if the argument is a puppet validation option or a file
10
+ # The extra arguments always come first, so this will work fine
11
+ if [[ " $arg " =~ $opts_regex ]]; then
12
+ options=" $options $arg "
13
+ else
14
+ output=$( puppet parser validate $options -- " $arg " 2>&1 ) || {
15
+ echo -e " \033[31m\033[1m$arg : failed Puppet validation\033[0m"
16
+ echo " $output "
17
+ status=1
18
+ }
19
+ fi
11
20
done
12
21
13
22
exit " $status "
You can’t perform that action at this time.
0 commit comments