Skip to content

Commit

Permalink
Merge pull request #113 from DataDog/sam/extra_endpoints_api_url
Browse files Browse the repository at this point in the history
Using api_url for sending chef related data to extra_endpoints
  • Loading branch information
remeh authored Nov 19, 2019
2 parents f6abe03 + e99a798 commit 9457b96
Show file tree
Hide file tree
Showing 2 changed files with 26 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 @@ -159,7 +159,7 @@ def endpoints
# then add extra endpoints
extra_endpoints = @config[:extra_endpoints] || []
extra_endpoints.each do |endpoint|
url = endpoint[:url] || config_url()
url = endpoint[:api_url] || endpoint[:url] || config_url()
api_key = endpoint[:api_key]
app_key = endpoint[:application_key]
endpoints << [url, api_key, app_key] if validate_keys(api_key, app_key, false)
Expand Down
25 changes: 25 additions & 0 deletions spec/datadog_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,31 @@
expect(handler.send(:endpoints)).to eq(triplets[0..1])
end
end

context 'when using api url instead of url' do
it 'returns available triplets' do
triplets = [
['https://app.datadoghq.com', 'api_key_2' , 'app_key_2'],
['https://app.example.com', 'api_key_3', 'app_key_3'],
['https://app.example.com', 'api_key_4', 'app_key_4']
]
handler = Chef::Handler::Datadog.new api_key: triplets[0][1],
application_key: triplets[0][2],
url: triplets[0][0],
extra_endpoints: [{
api_url: triplets[1][0],
url: triplets[0][0],
api_key: triplets[1][1],
application_key: triplets[1][2]
}, {
api_url: triplets[2][0],
url:triplets[0][0],
api_key: triplets[2][1],
application_key: triplets[2][2]
}]
expect(handler.send(:endpoints)).to eq(triplets)
end
end
end

context 'when reporting to multiple endpoints' do
Expand Down

0 comments on commit 9457b96

Please sign in to comment.