Skip to content

Commit 518ba94

Browse files
authored
Merge pull request DataDog#256 from sethcleveland/support_cassandra_integration_tags
Support cassandra integration tags
2 parents a3f547f + dd36012 commit 518ba94

3 files changed

Lines changed: 14 additions & 8 deletions

File tree

manifests/integrations/cassandra.pp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
#
2020
# class { 'datadog_agent::integrations::cassandra' :
2121
# host => 'localhost',
22+
# tags => {
23+
# environment => "production",
24+
# },
2225
# }
2326
#
2427
#
@@ -27,10 +30,10 @@
2730
$port = 7199,
2831
$user = undef,
2932
$password = undef,
30-
$tags = [],
33+
$tags = {},
3134
) inherits datadog_agent::params {
3235
require ::datadog_agent
33-
validate_array($tags)
36+
validate_hash($tags)
3437

3538
file { "${datadog_agent::params::conf_dir}/cassandra.yaml":
3639
ensure => file,

spec/classes/datadog_agent_integrations_cassandra_spec.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,18 @@
4646
it { should contain_file(conf_file).with_content(%r{user: baz}) }
4747
end
4848

49-
context 'with tags parameter array' do
49+
context 'with tags parameter hash' do
5050
let(:params) {{
5151
password: 'foobar',
52-
tags: %w{ foo bar baz },
52+
tags: {
53+
'foo'=> 'bar',
54+
'baz'=> 'ama',
55+
}
5356
}}
54-
it { should contain_file(conf_file).with_content(/tags:[^-]+- foo\s+- bar\s+- baz\s*?[^-]/m) }
57+
it { should contain_file(conf_file).with_content(/tags:\s+foo: bar\s+baz: ama\s*?[^-]/m) }
5558
end
5659

57-
context 'tags not array' do
60+
context 'tags not hash' do
5861
let(:params) {{
5962
password: 'foobar',
6063
tags: 'aoeu',

templates/agent-conf.d/cassandra.yaml.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ instances:
1212
<% end -%>
1313
<% if @tags.length > 0 -%>
1414
tags:
15-
<% @tags.each do |tag| -%>
16-
- <%= tag %>
15+
<%- @tags.each do |tag_name, tag_value| -%>
16+
<%= tag_name %>: <%= tag_value %>
1717
<% end -%>
1818
<% end -%>
1919

0 commit comments

Comments
 (0)