module Terraformer module Credentials class DatadogMissingCredentals < RuntimeError attr_reader :key def initialize(key) @key = key super(message) end def message "'#{key}' not being passed. set it via CLI --#{key} or #{key.upcase} enviroment variable." end end class Datadog KEYS = %w(datadog_api_key datadog_app_key).freeze 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 end end end