/**
  * Validate a specific alert configuration from configuration YAML is correct.
  *
  * @param string $name
  * @param array $config
  * @param DNProject $project
  * @param DeploynautLogFile $log
  * @return boolean
  */
 public function validateAlert($name, $config, $project, $log)
 {
     // validate we have an environment set for the alert
     if (!isset($config['environment'])) {
         $log->write(sprintf('WARNING: Failed to configure alert "%s". Missing "environment" key in .alerts.yml. Skipped.', $name));
         return false;
     }
     // validate we have an environmentcheck suite name to check
     if (!isset($config['check_url'])) {
         $log->write(sprintf('WARNING: Failed to configure alert "%s". Missing "check_url" key in .alerts.yml. Skipped.', $name));
         return false;
     }
     // validate we have contacts for the alert
     if (!isset($config['contacts'])) {
         $log->write(sprintf('WARNING: Failed to configure alert "%s". Missing "contacts" key in .alerts.yml. Skipped.', $name));
         return false;
     }
     // validate that each value in the config is valid, build up a list of contacts we'll use later
     foreach ($config['contacts'] as $contactEmail) {
         // special case for ops
         if ($contactEmail == 'ops') {
             continue;
         }
         $contact = $project->AlertContacts()->filter('Email', $contactEmail)->first();
         if (!($contact && $contact->exists())) {
             $log->write(sprintf('WARNING: Failed to configure alert "%s". No such contact "%s". Skipped.', $name, $contactEmail));
             return false;
         }
     }
     // validate the environment specified in the alert actually exists
     if (!DNEnvironment::get()->filter('Name', $config['environment'])->first()) {
         $log->write(sprintf('WARNING: Failed to configure alert "%s". Invalid environment "%s" in .alerts.yml. Skipped.', $name, $config['environment']));
         return false;
     }
     return true;
 }