Skip to content

Commit

Permalink
only prepend simple tags with tag:
Browse files Browse the repository at this point in the history
When a user sets a tag like `service:mysql` as a Chef tag, don't add
another `tag:` in front of that string, rather pass it along as is.

Fixes #58
  • Loading branch information
miketheman committed Apr 5, 2015
1 parent 51f3df7 commit 9b7f660
Show file tree
Hide file tree
Showing 3 changed files with 220 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/chef/handler/datadog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def get_node_env(node)
end

def get_node_tags(node)
node.tags.map! { |tag| 'tag:' + tag }
node.tags.map! { |tag| tag.match(/:/) ? tag.to_s : 'tag:' + tag }
end

def pluralize(number, noun)
Expand Down
14 changes: 14 additions & 0 deletions spec/datadog_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,20 @@
]),
)).to have_been_made.times(1)
end

it 'prepends tags correctly' do
@node.normal.tags = ['the_one_and_only', 'service:test']
@handler.run_report_unsafe(@run_status)

expect(a_request(:put, HOST_TAG_ENDPOINT + @node.name).with(
:query => { 'api_key' => @handler.config[:api_key],
'application_key' => @handler.config[:application_key],
'source' => 'chef' },
:body => hash_including(:tags => [
'env:hostile', 'role:highlander', 'tag:the_one_and_only', 'service:test'
]),
)).to have_been_made.times(1)
end
end

describe 'when unspecified' do
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9b7f660

Please sign in to comment.