Skip to content

Commit d9f6538

Browse files
author
Helen
committed
Merge pull request #595 from tphoney/4.12.0_release
master to 4.12.x
2 parents 2996121 + 085035d commit d9f6538

27 files changed

+237
-171
lines changed

.sync.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sudo: false
44
language: ruby
55
cache: bundler
66
bundler_args: --without system_tests
7-
script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--color --format documentation'"
7+
script: "bundle exec rake validate lint spec"
88
matrix:
99
fast_finish: true
1010
include:

Gemfile

Lines changed: 25 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,39 @@
1-
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
1+
#This file is generated by ModuleSync, do not edit.
22

3-
def location_for(place, fake_version = nil)
3+
source ENV['GEM_SOURCE'] || "https://rubygems.org"
4+
5+
def location_for(place, version = nil)
46
if place =~ /^(git[:@][^#]*)#(.*)/
5-
[fake_version, { :git => $1, :branch => $2, :require => false }].compact
7+
[version, { :git => $1, :branch => $2, :require => false}].compact
68
elsif place =~ /^file:\/\/(.*)/
7-
['>= 0', { :path => File.expand_path($1), :require => false }]
9+
['>= 0', { :path => File.expand_path($1), :require => false}]
810
else
9-
[place, { :require => false }]
11+
[place, version, { :require => false}].compact
1012
end
1113
end
1214

1315
group :development, :unit_tests do
14-
# rspec must be v2 for ruby 1.8.7
15-
if RUBY_VERSION >= '1.8.7' and RUBY_VERSION < '1.9'
16-
gem 'rspec', '~> 2.0'
17-
else
18-
gem 'rspec', '~> 3.1.0', :require => false
19-
end
20-
21-
gem 'rake', '~> 10.1.0', :require => false
22-
gem 'rspec-puppet', '~> 2.2', :require => false
23-
gem 'mocha', :require => false
24-
# keep for its rake task for now
25-
gem 'puppetlabs_spec_helper', :require => false
26-
gem 'puppet-lint', :require => false
27-
gem 'metadata-json-lint', :require => false
28-
gem 'pry', :require => false
29-
gem 'simplecov', :require => false
16+
gem 'json', :require => false
17+
gem 'metadata-json-lint', :require => false
18+
gem 'puppet_facts', :require => false
19+
gem 'puppet-blacksmith', :require => false
20+
gem 'puppetlabs_spec_helper', :require => false
21+
gem 'rspec-puppet', '>= 2.3.2', :require => false
22+
gem 'simplecov', :require => false
3023
end
31-
32-
beaker_version = ENV['BEAKER_VERSION']
33-
beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION']
3424
group :system_tests do
35-
if beaker_version
36-
gem 'beaker', *location_for(beaker_version)
37-
end
38-
if beaker_rspec_version
39-
gem 'beaker-rspec', *location_for(beaker_rspec_version)
40-
else
41-
gem 'beaker-rspec', :require => false
42-
end
43-
gem 'serverspec', :require => false
44-
gem 'beaker-puppet_install_helper', :require => false
25+
gem 'beaker-rspec', *location_for(ENV['BEAKER_RSPEC_VERSION'] || '>= 3.4')
26+
gem 'beaker', *location_for(ENV['BEAKER_VERSION'])
27+
gem 'serverspec', :require => false
28+
gem 'beaker-puppet_install_helper', :require => false
29+
gem 'master_manipulator', :require => false
30+
gem 'beaker-hostgenerator', *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION'])
4531
end
4632

47-
facterversion = ENV['GEM_FACTER_VERSION'] || ENV['FACTER_GEM_VERSION']
48-
if facterversion
49-
gem 'facter', *location_for(facterversion)
50-
else
51-
gem 'facter', :require => false
52-
end
33+
gem 'facter', *location_for(ENV['FACTER_GEM_VERSION'])
34+
gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION'])
5335

54-
puppetversion = ENV['GEM_PUPPET_VERSION'] || ENV['PUPPET_GEM_VERSION']
55-
if puppetversion
56-
gem 'puppet', *location_for(puppetversion)
57-
else
58-
gem 'puppet', :require => false
59-
end
6036

61-
# vim:ft=ruby
37+
if File.exists? "#{__FILE__}.local"
38+
eval(File.read("#{__FILE__}.local"), binding)
39+
end

README.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ Takes a resource reference and an optional hash of attributes. Returns 'true' if
265265

266266
#### `delete`
267267

268-
Deletes all instances of a given element from an array, substring from a string, or key from a hash. For example, `delete(['a','b','c','b'], 'b')` returns ['a','c']; `delete('abracadabra', 'bra')` returns 'acada'. `delete({'a' => 1,'b' => 2,'c' => 3},['b','c'])` returns {'a'=> 1}. *Type*: rvalue.
268+
Deletes all instances of a given element from an array, substring from a string, or key from a hash. Arrays and hashes may also match on regular expressions. For example, `delete(['a','b','c','b'], 'b')` returns ['a','c']; `delete('abracadabra', 'bra')` returns 'acada'. `delete({'a' => 1,'b' => 2,'c' => 3},['b','c'])` returns {'a'=> 1}, `delete(['abf', 'ab', 'ac'], '^ab.*')` returns ['ac']. *Type*: rvalue.
269269

270270
#### `delete_at`
271271

Rakefile

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,42 @@
1-
require 'rubygems'
2-
# keep for compatibility for now
3-
require 'puppetlabs_spec_helper/rake_tasks'
1+
require 'puppet_blacksmith/rake_tasks'
42
require 'puppet-lint/tasks/puppet-lint'
3+
require 'puppetlabs_spec_helper/rake_tasks'
4+
5+
PuppetLint.configuration.fail_on_warnings = true
6+
PuppetLint.configuration.send('relative')
57
PuppetLint.configuration.send('disable_80chars')
8+
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
9+
PuppetLint.configuration.send('disable_documentation')
10+
PuppetLint.configuration.send('disable_single_quote_string_with_variables')
611
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
712

13+
desc 'Generate pooler nodesets'
14+
task :gen_nodeset do
15+
require 'beaker-hostgenerator'
16+
require 'securerandom'
17+
require 'fileutils'
18+
19+
agent_target = ENV['TEST_TARGET']
20+
if ! agent_target
21+
STDERR.puts 'TEST_TARGET environment variable is not set'
22+
STDERR.puts 'setting to default value of "redhat-64default."'
23+
agent_target = 'redhat-64default.'
24+
end
25+
26+
master_target = ENV['MASTER_TEST_TARGET']
27+
if ! master_target
28+
STDERR.puts 'MASTER_TEST_TARGET environment variable is not set'
29+
STDERR.puts 'setting to default value of "redhat7-64mdcl"'
30+
master_target = 'redhat7-64mdcl'
31+
end
32+
33+
targets = "#{master_target}-#{agent_target}"
34+
cli = BeakerHostGenerator::CLI.new([targets])
35+
nodeset_dir = "tmp/nodesets"
36+
nodeset = "#{nodeset_dir}/#{targets}-#{SecureRandom.uuid}.yaml"
37+
FileUtils.mkdir_p(nodeset_dir)
38+
File.open(nodeset, 'w') do |fh|
39+
fh.print(cli.execute)
40+
end
41+
puts nodeset
42+
end

lib/facter/facter_dot_d.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def txt_parser(file)
4848
end
4949
end
5050
end
51-
rescue Exception => e
51+
rescue StandardError => e
5252
Facter.warn("Failed to handle #{file} as text facts: #{e.class}: #{e}")
5353
end
5454

@@ -65,7 +65,7 @@ def json_parser(file)
6565
setcode { v }
6666
end
6767
end
68-
rescue Exception => e
68+
rescue StandardError => e
6969
Facter.warn("Failed to handle #{file} as json facts: #{e.class}: #{e}")
7070
end
7171

@@ -77,7 +77,7 @@ def yaml_parser(file)
7777
setcode { v }
7878
end
7979
end
80-
rescue Exception => e
80+
rescue StandardError => e
8181
Facter.warn("Failed to handle #{file} as yaml facts: #{e.class}: #{e}")
8282
end
8383

@@ -106,7 +106,7 @@ def script_parser(file)
106106
end
107107
end
108108
end
109-
rescue Exception => e
109+
rescue StandardError => e
110110
Facter.warn("Failed to handle #{file} as script facts: #{e.class}: #{e}")
111111
Facter.debug(e.backtrace.join("\n\t"))
112112
end

lib/puppet/parser/functions/concat.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module Puppet::Parser::Functions
3131
arguments.shift
3232

3333
arguments.each do |x|
34-
result = result + Array(x)
34+
result = result + (x.is_a?(Array) ? x : [x])
3535
end
3636

3737
return result

lib/puppet/parser/functions/delete.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
# delete.rb
33
#
44

5-
# TODO(Krzysztof Wilczynski): We need to add support for regular expression ...
6-
75
module Puppet::Parser::Functions
86
newfunction(:delete, :type => :rvalue, :doc => <<-EOS
97
Deletes all instances of a given element from an array, substring from a
@@ -34,7 +32,7 @@ module Puppet::Parser::Functions
3432
Array(arguments[1]).each do |item|
3533
case collection
3634
when Array, Hash
37-
collection.delete item
35+
collection.delete_if { |coll_item| coll_item =~ %r{#{item}} }
3836
when String
3937
collection.gsub! item, ''
4038
else

lib/puppet/parser/functions/hash.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module Puppet::Parser::Functions
2929
# This is to make it compatible with older version of Ruby ...
3030
array = array.flatten
3131
result = Hash[*array]
32-
rescue Exception
32+
rescue StandardError
3333
raise(Puppet::ParseError, 'hash(): Unable to compute ' +
3434
'hash from array given')
3535
end
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#
2+
# is_email_address.rb
3+
#
4+
5+
module Puppet::Parser::Functions
6+
newfunction(:is_email_address, type: :rvalue, doc: <<-EOS
7+
Returns true if the string passed to this function is a valid email address.
8+
EOS
9+
) do |arguments|
10+
if arguments.size != 1
11+
raise(Puppet::ParseError, 'is_email_address(): Wrong number of arguments '\
12+
"given #{arguments.size} for 1")
13+
end
14+
15+
# Taken from http://emailregex.com/ (simpler regex)
16+
valid_email_regex = %r{\A([\w+\-].?)+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z}
17+
return (arguments[0] =~ valid_email_regex) == 0
18+
end
19+
end
20+
21+
# vim: set ts=2 sw=2 et :

0 commit comments

Comments
 (0)