Reading documentation to be able to define coding rules, I want to put
some SVN hooks to ensure for correct syntax and coding rules respect.
Does anybody here use such scripts ? Are some public version available ?
Or am I wrong going this way ?
Regards,
JB
We have an SVN post-commit hook that does a syntax check on manifests and
templates. It could be extended to enforce coding standards if you wanted.
The script is contained within http://forge.puppetlabs.com/ghoneycutt/svn
or grab it directly at
http://github.com/ghoneycutt/puppet-svn/raw/master/files/puppet/hooks/pre-commit
-Eric
Will try it asap,
Regards,
JB
Le 12/08/2010 11:24, Eric Heydrick a �crit :
> On Thu, 12 Aug 2010, Jean Baptiste FAVRE wrote:
>
>> Hello list,
>> I'm planning to deploy and use Puppet at work.
>> For this, I've set up a SVN server to keep track of all changes in
>> modules& manifests.
You're on a good way.
I'm using pre-commit hook to check syntax on FreeBSD, so you should to
check path
#!/bin/sh
#
# SVN pre-commit hook to check Puppet syntax for .pp files
# Modified from
http://mail.madstop.com/pipermail/puppet-users/2007-March/002034.html
#
REPOS="$1"
TXN="$2"
tmpfile=`mktemp /tmp/XXXXX`
export HOME=/
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
SVNLOOK=/usr/local/bin/svnlook
PUPPET=/usr/local/bin/puppet
$SVNLOOK changed -t "$TXN" "$REPOS" | awk '{print $2}' | grep '\.pp$' |
while read line
do
$SVNLOOK cat -t "$TXN" "$REPOS" "$line" > $tmpfile
if [ $? -ne 0 ]
then
echo "Warning: Failed to checkout $line" >&2
fi
$PUPPET --color=false --confdir=/tmp --vardir=/tmp --parseonly
--ignoreimport $tmpfile >&2
if [ $? -ne 0 ]
then
echo "Puppet syntax error in $line." >&2
exit 2
fi
done
res=$?
rm -f $tmpfile
if [ $res -ne 0 ]
then
exit $res
fi
>
> Regards,
> JB
>
--
Alexander Kriventsov
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
This is mine, it does some extra syntax checking:
#!/bin/bash
# This file is managed by Puppet
export TMPDIR="/tmp/svntmp"
if [ ! -e "TMPDIR" ]; then
mkdir -p $TMPDIR && chmod 1777 $TMPDIR
fi
export ERRCOUNT=0
export PATH="/usr/bin:/bin"
export REPOS="$1"
export TMPFILE=$(mktemp -p $TMPDIR)
export TXN="$2"
while read LINE; do
svnlook cat -t "$TXN" "$REPOS" "$LINE" > "$TMPFILE"
if [ $? -ne 0 ]; then
echo "Warning: Failed to checkout $LINE" >&2
fi
EXT=$(echo $LINE | awk -F'.' '{ print $NF }')
case "$EXT" in
"erb")
erb -x -T '-' $TMPFILE | ruby -c
if [ $? -ne 0 ]; then
echo "ERB parsing error in $LINE" >&2
let ERRCOUNT+=1
fi
;;
"pp")
/usr/bin/puppet --color=false --parseonly --ignoreimport
"$TMPFILE"
if [ $? -ne 0 ]; then
echo "Puppet syntax error in $LINE" >&2
let ERRCOUNT+=1
fi
;;
"rb")
ruby -c $TMPFILE
if [ $? -ne 0 ]; then
echo "Ruby syntax error in $LINE" >&2
let ERRCOUNT+=1
fi
;;
"sh")
bash -n $TMPFILE
if [ $? -ne 0 ]; then
echo "Bash syntax error in $LINE" >&2
let ERRCOUNT+=1
fi
;;
*)
continue
;;
esac
done < <(svnlook changed -t "$TXN" "$REPOS" | awk '{print $2}')
rm -f "$TMPFILE"
exit $ERRCOUNT
--
Joe McDonagh
AIM: YoosingYoonickz
IRC: joe-mac on freenode
"When the going gets weird, the weird turn pro."