forked from redhat-openstack/openstack-puppet-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #397 from cyberious/4.6.x
4.6.x
- Loading branch information
Showing
25 changed files
with
568 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fixtures: | ||
symlinks: | ||
stdlib: "#{source_dir}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,5 @@ spec/fixtures/ | |
.vagrant/ | ||
.bundle/ | ||
coverage/ | ||
.idea/ | ||
*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Returns the type when passed a value. | ||
# | ||
# @example how to compare values' types | ||
# # compare the types of two values | ||
# if type_of($first_value) != type_of($second_value) { fail("first_value and second_value are different types") } | ||
# @example how to compare against an abstract type | ||
# unless type_of($first_value) <= Numeric { fail("first_value must be Numeric") } | ||
# unless type_of{$first_value) <= Collection[1] { fail("first_value must be an Array or Hash, and contain at least one element") } | ||
# | ||
# See the documentation for "The Puppet Type System" for more information about types. | ||
# See the `assert_type()` function for flexible ways to assert the type of a value. | ||
# | ||
Puppet::Functions.create_function(:type_of) do | ||
def type_of(value) | ||
Puppet::Pops::Types::TypeCalculator.infer_set(value) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module Puppet::Parser::Functions | ||
newfunction(:basename, :type => :rvalue, :doc => <<-EOS | ||
Strips directory (and optional suffix) from a filename | ||
EOS | ||
) do |arguments| | ||
|
||
if arguments.size < 1 then | ||
raise(Puppet::ParseError, "basename(): No arguments given") | ||
elsif arguments.size > 2 then | ||
raise(Puppet::ParseError, "basename(): Too many arguments given (#{arguments.size})") | ||
else | ||
|
||
unless arguments[0].is_a?(String) | ||
raise(Puppet::ParseError, 'basename(): Requires string as first argument') | ||
end | ||
|
||
if arguments.size == 1 then | ||
rv = File.basename(arguments[0]) | ||
elsif arguments.size == 2 then | ||
|
||
unless arguments[1].is_a?(String) | ||
raise(Puppet::ParseError, 'basename(): Requires string as second argument') | ||
end | ||
|
||
rv = File.basename(arguments[0], arguments[1]) | ||
end | ||
|
||
end | ||
|
||
return rv | ||
end | ||
end | ||
|
||
# vim: set ts=2 sw=2 et : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# | ||
# type3x.rb | ||
# | ||
|
||
module Puppet::Parser::Functions | ||
newfunction(:type3x, :type => :rvalue, :doc => <<-EOS | ||
DEPRECATED: This function will be removed when puppet 3 support is dropped; please migrate to the new parser's typing system. | ||
Returns the type when passed a value. Type can be one of: | ||
* string | ||
* array | ||
* hash | ||
* float | ||
* integer | ||
* boolean | ||
EOS | ||
) do |args| | ||
raise(Puppet::ParseError, "type3x(): Wrong number of arguments " + | ||
"given (#{args.size} for 1)") if args.size < 1 | ||
|
||
value = args[0] | ||
|
||
klass = value.class | ||
|
||
if not [TrueClass, FalseClass, Array, Bignum, Fixnum, Float, Hash, String].include?(klass) | ||
raise(Puppet::ParseError, 'type3x(): Unknown type') | ||
end | ||
|
||
klass = klass.to_s # Ugly ... | ||
|
||
# We note that Integer is the parent to Bignum and Fixnum ... | ||
result = case klass | ||
when /^(?:Big|Fix)num$/ then 'integer' | ||
when /^(?:True|False)Class$/ then 'boolean' | ||
else klass | ||
end | ||
|
||
if result == "String" then | ||
if value == value.to_i.to_s then | ||
result = "Integer" | ||
elsif value == value.to_f.to_s then | ||
result = "Float" | ||
end | ||
end | ||
|
||
return result.downcase | ||
end | ||
end | ||
|
||
# vim: set ts=2 sw=2 et : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.