Skip to content

Commit dec93c6

Browse files
committed
Add spec test for new site option
1 parent 3a8c1c3 commit dec93c6

3 files changed

Lines changed: 18 additions & 7 deletions

File tree

manifests/init.pp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# $dd_url:
77
# The host of the Datadog intake server to send agent data to.
88
# Defaults to https://app.datadoghq.com.
9-
# $site:
9+
# $datadog_site:
1010
# The site of the Datadog intake to send Agent data to. Defaults to 'datadoghq.com',
1111
# set to 'datadoghq.eu' to send data to the EU site.
1212
# This option is only available with agent version >= 6.6.0.
@@ -205,7 +205,7 @@
205205
#
206206
class datadog_agent(
207207
$dd_url = '',
208-
$site = $datadog_agent::params::default_site,
208+
$datadog_site = $datadog_agent::params::datadog_site,
209209
$host = '',
210210
$api_key = 'your_API_key',
211211
$collect_ec2_tags = false,
@@ -306,7 +306,7 @@
306306
# lint:endignore
307307

308308
validate_legacy(String, 'validate_string', $dd_url)
309-
validate_legacy(String, 'validate_string', $site)
309+
validate_legacy(String, 'validate_string', $datadog_site)
310310
validate_legacy(String, 'validate_string', $host)
311311
validate_legacy(String, 'validate_string', $api_key)
312312
validate_legacy(Array, 'validate_array', $tags)
@@ -493,7 +493,7 @@
493493
}
494494

495495
if ($dd_url == '') {
496-
$_dd_url = 'app.datadoghq.com'
496+
$_dd_url = 'https://app.datadoghq.com'
497497
} else {
498498
$_dd_url = $dd_url
499499
}
@@ -618,7 +618,7 @@
618618
$_agent_config = {
619619
'api_key' => $api_key,
620620
'dd_url' => $dd_url,
621-
'site' => $site,
621+
'site' => $datadog_site,
622622
'cmd_port' => 5001,
623623
'collect_ec2_tags' => $collect_ec2_tags,
624624
'conf_path' => $datadog_agent::params::conf6_dir,

manifests/params.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# Sample Usage:
1616
#
1717
class datadog_agent::params {
18-
$default_site = 'datadoghq.com'
18+
$datadog_site = 'datadoghq.com'
1919
$agent5_enable = false
2020
$conf_dir = '/etc/dd-agent/conf.d'
2121
$conf6_dir = '/etc/datadog-agent/conf.d'

spec/classes/datadog_agent_spec.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,10 @@
881881
'content' => /^collect_ec2_tags: false\n/,
882882
)}
883883
it { should contain_file('/etc/datadog-agent/datadog.yaml').with(
884-
'content' => /^dd_url: \"{0,1}https:\/\/app.datadoghq.com\"{0,1}\n/,
884+
'content' => /^dd_url: ''\n/,
885+
)}
886+
it { should contain_file('/etc/datadog-agent/datadog.yaml').with(
887+
'content' => /^site: datadoghq.com\n/,
885888
)}
886889
it { should contain_file('/etc/datadog-agent/datadog.yaml').with(
887890
'content' => /^enable_metadata_collection: true\n/,
@@ -947,6 +950,14 @@
947950
'content' => /^collect_ec2_tags: true\n/,
948951
)}
949952
end
953+
context 'datadog EU' do
954+
let(:params) {{
955+
:datadog_site => 'datadoghq.eu',
956+
}}
957+
it { should contain_file('/etc/datadog-agent/datadog.yaml').with(
958+
'content' => /^site: datadoghq.eu\n/,
959+
)}
960+
end
950961
context 'forward statsd settings set' do
951962
let(:params) {{
952963
:statsd_forward_host => 'foo',

0 commit comments

Comments
 (0)