class Heroku::Kensa::ProvisionResponseCheck
Public Instance Methods
call!()
click to toggle source
# File lib/heroku/kensa/check.rb, line 168 def call! response = data[:provision_response] test "response" check "contains an id" do response.is_a?(Hash) && response.has_key?("id") end screen.message " (id #{response['id']})" if response.has_key?("config") test "config data" check "is a hash" do response["config"].is_a?(Hash) end check "all config keys were previously defined in the manifest" do response["config"].keys.each do |key| error "#{key} is not in the manifest" unless data["api"]["config_vars"].include?(key) end true end check "all keys in the manifest are present" do difference = data['api']['config_vars'] - response['config'].keys unless difference.empty? verb = (difference.size == 1) ? "is" : "are" print "\n\t", yellow( "#{difference.join(', ')} #{verb} missing from the manifest") end true end check "all config values are strings" do response["config"].each do |k, v| if v.is_a?(String) true else error "the key #{k} doesn't contain a string (#{v.inspect})" end end end check "URL configs vars" do response["config"].each do |key, value| next unless key =~ /_URL$/ begin uri = URI.parse(value) error "#{value} is not a valid URI - missing host" unless uri.host error "#{value} is not a valid URI - missing scheme" unless uri.scheme error "#{value} is not a valid URI - pointing to localhost" if env == 'production' && uri.host == 'localhost' rescue URI::Error error "#{value} is not a valid URI" end end end check "syslog_drain_url is returned if required" do return true unless data.has_key?("requires") && data["requires"].include?("syslog_drain") drain_url = response['syslog_drain_url'] if !drain_url || drain_url.empty? error "must return a syslog_drain_url" else true end unless drain_url =~ /\A(https|syslog):\/\/[\S]+\Z/ error "must return a syslog_drain_url like syslog://log.example.com:9999" else true end end end end