Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert custom params to appropriate types #99

Merged
merged 3 commits into from
Aug 12, 2013
Merged
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
1 change: 1 addition & 0 deletions lib/puppet/provider/sensu_check/json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def custom
end

def custom=(value)
value.each { |k, v| value[k] = to_type(v) }
conf['checks'][resource[:name]].delete_if { |k,v| not check_args.include?(k) }
conf['checks'][resource[:name]].merge!(value)
end
Expand Down
25 changes: 25 additions & 0 deletions lib/puppet/type/sensu_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,31 @@ def should_to_s(hash = @should)
hash.keys.sort.map {|key| "#{key} => #{hash[key]}"}.join(", ")
end

def insync?(is)
if defined? @should[0]
if is == @should[0].each { |k, v| value[k] = to_type(v) }
true
else
false
end
else
true
end
end

def to_type(value)
case value
when true, 'true', 'True', :true
true
when false, 'false', 'False', :false
false
when /^([0-9])+$/
value.to_i
else
value
end
end

defaultto {}
end

Expand Down