Conversation
| <% if instance['disable_ssl_validation'] -%> | ||
| disable_ssl_validation: <%= instance['disable_ssl_validation'] %> | ||
| <% else %> | ||
| disable_ssl_validation: false |
There was a problem hiding this comment.
We should just remove this.... the if here in line 31 should be enough - just check if 'disable_ssl_validation' key is defined in the hash and then drop in the value.
|
@truthbk updated with same style as other key checks for consistency. |
| collect_response_time: <%= instance['collect_response_time'] %> | ||
| <% end -%> | ||
| disable_ssl_validation: <%= instance['disable_ssl_validation'] %> | ||
| <% if instance['disable_ssl_validation'] -%> |
There was a problem hiding this comment.
I think this will fail if the key doesn't exist... can you try with has_key(instance, 'disable_ssl_validation') instead?
There was a problem hiding this comment.
I tested successfully with this config in the manifest:
node 'ip-0-0-0-0.ec2.internal' {
class { "datadog_agent":
api_key => "key"
}
class { 'datadog_agent::integrations::http_check':
instances => [{
'sitename' => 'google',
'url' => 'http://www.google.com',
'tags' => 'site:google'
},
{
'sitename' => 'datadog',
'url' => 'http://www.datadoghq.com',
'tags' => 'site:dog'
}]
}
}
We only add parameters when they are found. Another alternative would be to use:
if instance.has_key?("disable_ssl_validation") although I used the above for consistency. What do you think?
There was a problem hiding this comment.
nil evaluates as false:
irb(main):001:0> instance = {"sitename"=>"google", "url"=>"http://www.google.com", "tags"=>"site:google"}
=> {"sitename"=>"google", "url"=>"http://www.google.com", "tags"=>"site:google"}
irb(main):002:0> instance['disable_ssl_validation']
=> nil
irb(main):003:0> if instance['disable_ssl_validation']; puts 'TRUE' ; else puts 'FALSE' ; end
FALSE
=> nil
truthbk
left a comment
There was a problem hiding this comment.
I think the current template will fail in some cases...
truthbk
left a comment
There was a problem hiding this comment.
Thanks for checking it out @sjenriquez! Merging!
…-fix set disable_ssl_validation parameter
If an array of instances is declared in the main manifest
disable_ssl_validationis not set, this PR fixes that bug and adds an example.