Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/puppet/type/iis/iis_file_system_path_property.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

module Puppet
class IisFileSystemPathProperty < IisProperty
munge do |value|
value.to_s.gsub("/", "\\")
end

def validate(value)
raise Puppet::Error, "Invalid value for attribute '#{name}', must use back slashes instead of forward slashes" if self.should_to_s(value).include?('/')

end

def insync?(is)
self.is_to_s(is).casecmp(self.should_to_s(@should)) == 0
self.is_to_s(is).gsub("/", "\\").casecmp(self.should_to_s(@should).gsub("/", "\\")) == 0
end
end
end
end
40 changes: 38 additions & 2 deletions lib/puppet/type/iis_site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,43 @@
desc ""
end

newproperty(:bindings, :array_matching => :all) do
desc ""
newproperty(:bindings, :array_matching => :all, :sort => :true) do
desc ""

# Array equality matching taken from https://github.com/puppetlabs/puppet/blob/master/lib/puppet/property.rb
# and modified to ignore the order of bindings
def insync?(is)
self.devfail "#{self.class.name}'s should is not array" unless @should.is_a?(Array)

# an empty array is analogous to no should values
return true if @should.empty?

# Look for a matching value, either for all the @should values, or any of
# them, depending on the configuration of this property.
if match_all? then
# Emulate Array#== using our own comparison function.
# A non-array was not equal to an array, which @should always is.
return false unless is.is_a? Array

# If they were different lengths, they are not equal.
return false unless is.length == @should.length

# Finally, are all the elements equal? In order to preserve the
# behaviour of previous 2.7.x releases, we need to impose some fun rules
# on "equality" here.
#
# Specifically, we need to implement *this* comparison: the two arrays
# are identical if the is values are == the should values, or if the is
# values are == the should values, stringified.
#
# This does mean that property equality is not commutative, and will not
# work unless the `is` value is carefully arranged to match the should.

# Sort the arrays before comparison, to avoid the issue noted above
return (is.sort == @should.sort or is == @should.map(&:to_s))
else
return @should.any? {|want| property_matches?(is, want) }
end
end
end
end