Class: Heroku::Kensa::ProvisionResponseCheck
- Defined in:
- lib/heroku/kensa/check.rb
Instance Attribute Summary
Attributes inherited from Check
Instance Method Summary collapse
Methods inherited from Check
#api_requires?, #call, #check, #env, #error, #initialize, #run, #test, #to_proc, #url, #warning
Constructor Details
This class inherits a constructor from Heroku::Kensa::Check
Instance Method Details
#call! ⇒ Object
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
# File 'lib/heroku/kensa/check.rb', line 175 def call! response = data[:provision_response] test "response" check "contains an id" do response.is_a?(Hash) && response["id"] end check "id does not contain heroku_id" do if response["id"].to_s.include? data["heroku_id"].scan(/app(\d+)@/).flatten.first error "id cannot include heroku_id" else true end end screen. " (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" warning "#{difference.join(', ')} #{verb} missing from the provision response" 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 "log_drain_url is returned if required" do return true unless api_requires?("syslog_drain") drain_url = response['log_drain_url'] if !drain_url || drain_url.empty? error "must return a log_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 |