Showing with 50 additions and 13 deletions.
  1. +2 −0 CHANGELOG
  2. +1 −1 Modulefile
  3. +45 −10 files/pre-commit
  4. +1 −1 manifests/config.pp
  5. +1 −1 manifests/init.pp
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
2.3.2 - Zach Leslie + misterdom
* Fix for #96
2.3.1 - Ben Ford
* Fix for #87
2.3.0 - Zack Smith
Expand Down
2 changes: 1 addition & 1 deletion Modulefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name 'zack-r10k'
version '2.3.1'
version '2.3.2'
source 'https://github.com/acidprime/r10k'
author 'zack'
license 'Apache License, Version 2.0'
Expand Down
55 changes: 45 additions & 10 deletions files/pre-commit
Original file line number Diff line number Diff line change
@@ -1,25 +1,60 @@
#!/usr/bin/ruby
# Based on an example from Jakov Sosic
#!/usr/bin/env ruby

require 'rubygems'
require 'yaml'
require 'json'

def puppet_parser_validate(file)
system('puppet parser validate ' + file)
end

def r10k_puppetfile_check(file)
system('r10k puppetfile check ' + file)
end

def bash_check(file)
system('bash -n ' + file)
end

def puppet_lint(file)
system('puppet-lint --no-80chars-check ' + file)
system('puppet-lint ' + file)
end

#def puppet_erb_check(file)
# system('erb -x -T \'-\' ' + file + ' | ruby -c')
#end
def puppet_erb_check(file)
system("erb -x -T '-' ' + #{file} + ' | ruby -c")
end

def yaml_check(file)
YAML.load_file(file)
rescue Exception => err
puts "YAML invalid: #{err}"
false
end

def json_check(file)
JSON.parse( IO.read(file) )
rescue Exception => err
puts "JSON invalid: #{err}"
false
end

# go through list of files, and call adequate checks
IO.popen('git diff --cached --name-only --diff-filter=ACM').readlines.each { |file|
file.sub!(/^\w (.*)\n/,'\1')
file.chomp! unless file.nil?
puts "Processing #{file}"
if file.match('.pp$')
exit 1 unless puppet_parser_validate file
exit 1 unless puppet_lint file
# elsif file.match('.erb$')
# exit 1 unless puppet_erb_check file
end
exit 1 unless puppet_lint file
elsif file.match('.erb$')
exit 1 unless puppet_erb_check file
elsif file.match('Puppetfile')
exit 1 unless r10k_puppetfile_check file
elsif file.match('.sh$')
exit 1 unless bash_check file
elsif file.match(/(.yaml$|.yml$|.eyaml$)/)
exit 1 unless yaml_check file
elsif file.match('.json$')
exit 1 unless json_check file
end
}
2 changes: 1 addition & 1 deletion manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

validate_bool($manage_modulepath)

if type($manage_configfile_symlink) == 'string' {
if is_string($manage_configfile_symlink) {
$manage_configfile_symlink_real = str2bool($manage_configfile_symlink)
} else {
$manage_configfile_symlink_real = $manage_configfile_symlink
Expand Down
2 changes: 1 addition & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

$ruby_dependency_options=['include','declare','ignore']
validate_re($manage_ruby_dependency,$ruby_dependency_options)
if type($include_prerun_command) == 'string' {
if is_string($include_prerun_command) {
$include_prerun_command_real = str2bool($include_prerun_command)
} else {
$include_prerun_command_real = $include_prerun_command
Expand Down