summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.markdown4
-rw-r--r--lib/puppet/parser/functions/has_interface_with.rb7
-rw-r--r--lib/puppet/parser/functions/validate_slength.rb6
-rw-r--r--metadata.json3
-rwxr-xr-xspec/functions/getvar_spec.rb9
-rwxr-xr-xspec/functions/validate_slength_spec.rb2
-rwxr-xr-xspec/spec_helper_acceptance.rb4
7 files changed, 17 insertions, 18 deletions
diff --git a/README.markdown b/README.markdown
index 4fab8c8..3d1e663 100644
--- a/README.markdown
+++ b/README.markdown
@@ -938,13 +938,14 @@ test, and the second argument should be a stringified regular expression (withou
#### `validate_slength`
-Validates that the first argument is a string (or an array of strings), and is less than or equal to the length of the second argument. It fails if the first argument is not a string or array of strings, or if arg 2 is not convertable to a number.
+Validates that the first argument is a string (or an array of strings), and is less than or equal to the length of the second argument. It fails if the first argument is not a string or array of strings, or if arg 2 is not convertable to a number. Optionally, a minimum string length can be given as the third argument.
The following values pass:
~~~
validate_slength("discombobulate",17)
validate_slength(["discombobulate","moo"],17)
+ validate_slength(["discombobulate","moo"],17,3)
~~~
The following values fail:
@@ -952,6 +953,7 @@ Validates that the first argument is a string (or an array of strings), and is l
~~~
validate_slength("discombobulate",1)
validate_slength(["discombobulate","thermometer"],5)
+ validate_slength(["discombobulate","moo"],17,10)
~~~
*Type*: statement.
diff --git a/lib/puppet/parser/functions/has_interface_with.rb b/lib/puppet/parser/functions/has_interface_with.rb
index 3691524..e762798 100644
--- a/lib/puppet/parser/functions/has_interface_with.rb
+++ b/lib/puppet/parser/functions/has_interface_with.rb
@@ -38,8 +38,11 @@ has_interface_with("lo") => true
# Bug with 3.7.1 - 3.7.3 when using future parser throws :undefined_variable
# https://tickets.puppetlabs.com/browse/PUP-3597
factval = nil
- catch :undefined_variable do
- factval = lookupvar(kind)
+ begin
+ catch :undefined_variable do
+ factval = lookupvar(kind)
+ end
+ rescue Puppet::ParseError # Eat the exception if strict_variables = true is set
end
if factval == value
return true
diff --git a/lib/puppet/parser/functions/validate_slength.rb b/lib/puppet/parser/functions/validate_slength.rb
index 7d534f3..47c7d4a 100644
--- a/lib/puppet/parser/functions/validate_slength.rb
+++ b/lib/puppet/parser/functions/validate_slength.rb
@@ -3,7 +3,7 @@ module Puppet::Parser::Functions
newfunction(:validate_slength, :doc => <<-'ENDHEREDOC') do |args|
Validate that the first argument is a string (or an array of strings), and
less/equal to than the length of the second argument. An optional third
- parameter can be given a the minimum length. It fails if the first
+ parameter can be given the minimum length. It fails if the first
argument is not a string or array of strings, and if arg 2 and arg 3 are
not convertable to a number.
@@ -43,9 +43,7 @@ module Puppet::Parser::Functions
min_length = 0
end
- if min_length > max_length
- raise Puppet::ParseError, "validate_slength(): Expected second argument to be larger than third argument"
- end
+ raise Puppet::ParseError, "validate_slength(): Expected second argument to be equal to or larger than third argument" unless max_length >= min_length
validator = lambda do |str|
unless str.length <= max_length and str.length >= min_length
diff --git a/metadata.json b/metadata.json
index 21e063f..3254497 100644
--- a/metadata.json
+++ b/metadata.json
@@ -71,7 +71,8 @@
"operatingsystem": "Solaris",
"operatingsystemrelease": [
"10",
- "11"
+ "11",
+ "12"
]
},
{
diff --git a/spec/functions/getvar_spec.rb b/spec/functions/getvar_spec.rb
index 37125d1..6ab137e 100755
--- a/spec/functions/getvar_spec.rb
+++ b/spec/functions/getvar_spec.rb
@@ -16,13 +16,6 @@ describe 'getvar' do
it { is_expected.to run.with_params('site::data::foo').and_return('baz') }
it { is_expected.to run.with_params('::site::data::foo').and_return('baz') }
-
- context 'with strict variable checking', :if => RSpec.configuration.strict_variables do
- it { is_expected.to run.with_params('::site::data::bar').and_raise_error(ArgumentError, /undefined_variable/) }
- end
-
- context 'without strict variable checking', :unless => RSpec.configuration.strict_variables do
- it { is_expected.to run.with_params('::site::data::bar').and_return(nil) }
- end
+ it { is_expected.to run.with_params('::site::data::bar').and_return(nil) }
end
end
diff --git a/spec/functions/validate_slength_spec.rb b/spec/functions/validate_slength_spec.rb
index 391f83a..5a8fa6a 100755
--- a/spec/functions/validate_slength_spec.rb
+++ b/spec/functions/validate_slength_spec.rb
@@ -10,7 +10,7 @@ describe 'validate_slength' do
it { is_expected.to run.with_params('', -1).and_raise_error(Puppet::ParseError, /second argument to be a positive Numeric/) }
it { is_expected.to run.with_params('', 1, '').and_raise_error(Puppet::ParseError, /third argument to be unset or a positive Numeric/) }
it { is_expected.to run.with_params('', 1, -1).and_raise_error(Puppet::ParseError, /third argument to be unset or a positive Numeric/) }
- it { is_expected.to run.with_params('', 1, 2).and_raise_error(Puppet::ParseError, /argument to be larger than third argument/) }
+ it { is_expected.to run.with_params('', 1, 2).and_raise_error(Puppet::ParseError, /argument to be equal to or larger than third argument/) }
end
context "with a maximum length of 10" do
diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb
index 3d9574b..39d2d52 100755
--- a/spec/spec_helper_acceptance.rb
+++ b/spec/spec_helper_acceptance.rb
@@ -43,7 +43,9 @@ RSpec.configure do |c|
end
def is_future_parser_enabled?
- if default[:default_apply_opts]
+ if default[:type] == 'aio'
+ return true
+ elsif default[:default_apply_opts]
return default[:default_apply_opts][:parser] == 'future'
end
return false