Skip to content

Commit

Permalink
Merge pull request #186 from DataDog/jaime/httpcheck_name
Browse files Browse the repository at this point in the history
[http_check] name is a compulsory element, adding to manifest.
  • Loading branch information
truthbk authored Jun 22, 2016
2 parents 088b061 + 77f5ca9 commit 35926eb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
13 changes: 9 additions & 4 deletions manifests/integrations/http_check.pp
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,19 @@
# Sample Usage:
#
# class { 'datadog_agent::integrations::http_check':
# url => 'http://www.google.com/',
# sitename => 'google',
# url => 'http://www.google.com/',
# }
#
# class { 'datadog_agent::integrations::http_check':
# url => 'http://localhost/',
# headers => ['Host: stan.borbat.com', 'DNT: true'],
# tags => ['production', 'wordpress'],
# sitename => 'local',
# url => 'http://localhost/',
# headers => ['Host: stan.borbat.com', 'DNT: true'],
# tags => ['production', 'wordpress'],
# }
#
# class { 'datadog_agent::integrations::http_check':
# sitename => 'localhost-9001',
# url => 'http://localhost:9001/',
# timeout => 5,
# threshold => 1,
Expand All @@ -74,6 +77,7 @@
#
#
class datadog_agent::integrations::http_check (
$sitename = undef,
$url = undef,
$username = undef,
$password = undef,
Expand All @@ -92,6 +96,7 @@

if !$instances and $url {
$_instances = [{
'sitename' => $sitename,
'url' => $url,
'username' => $username,
'password' => $password,
Expand Down
7 changes: 7 additions & 0 deletions spec/classes/datadog_agent_integrations_http_check_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") }

context 'with default parameters' do
it { should contain_file(conf_file).without_content(%r{name: }) }
it { should contain_file(conf_file).without_content(%r{url: }) }
it { should contain_file(conf_file).without_content(%r{username: }) }
it { should contain_file(conf_file).without_content(%r{password: }) }
Expand All @@ -36,6 +37,7 @@

context 'with parameters set' do
let(:params) {{
sitename: 'foo.bar.baz',
url: 'http://foo.bar.baz:4096',
username: 'foouser',
password: 'barpassword',
Expand All @@ -47,6 +49,7 @@
disable_ssl_validation: true,
}}

it { should contain_file(conf_file).with_content(%r{name: foo.bar.baz}) }
it { should contain_file(conf_file).with_content(%r{url: http://foo.bar.baz:4096}) }
it { should contain_file(conf_file).with_content(%r{username: foouser}) }
it { should contain_file(conf_file).with_content(%r{password: barpassword}) }
Expand All @@ -60,6 +63,7 @@

context 'with headers parameter array' do
let(:params) {{
sitename: 'foo.bar.baz',
url: 'http://foo.bar.baz:4096',
headers: %w{ foo bar baz },
}}
Expand All @@ -69,6 +73,7 @@
context 'with headers parameter empty values' do
context 'mixed in with other headers' do
let(:params) {{
sitename: 'foo.bar.baz',
url: 'http://foo.bar.baz:4096',
headers: [ 'foo', '', 'baz' ]
}}
Expand Down Expand Up @@ -96,6 +101,7 @@

context 'with tags parameter array' do
let(:params) {{
sitename: 'foo.bar.baz',
url: 'http://foo.bar.baz:4096',
tags: %w{ foo bar baz },
}}
Expand All @@ -105,6 +111,7 @@
context 'with tags parameter empty values' do
context 'mixed in with other tags' do
let(:params) {{
sitename: 'foo.bar.baz',
url: 'http://foo.bar.baz:4096',
tags: [ 'foo', '', 'baz' ]
}}
Expand Down
2 changes: 1 addition & 1 deletion templates/agent-conf.d/http_check.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ init_config:

instances:
<%- (Array(@_instances)).each do |instance| -%>
- name: <%= instance['name'] %>
- name: <%= instance['sitename'] %>
url: <%= instance['url'] %>
<% if instance['timeout'] -%>
timeout: <%= instance['timeout'] %>
Expand Down

0 comments on commit 35926eb

Please sign in to comment.