Class: Terraformer::Credentials::Datadog

Inherits:
Object
  • Object
show all
Defined in:
lib/terraformer/credentials/datadog.rb

Constant Summary collapse

KEYS =
%w(datadog_api_key datadog_app_key).freeze

Class Method Summary collapse

Class Method Details

.get_from_options(options) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/terraformer/credentials/datadog.rb', line 20

def self.get_from_options(options)
  KEYS.inject({}) do |credentials, key|
    datadog_key = key.sub("datadog_", "").to_sym
    credentials[datadog_key] = options[key.to_sym].nil? ? options[key] : options[key.to_sym]
    credentials[datadog_key] = ENV[key.upcase] if credentials[datadog_key].nil?
    raise DatadogMissingCredentals.new(key) if credentials[datadog_key].nil?

    credentials
  end
end