/**
  * Executes the check itselfs
  *
  * @return boolean
  */
 public function check()
 {
     $result = true;
     $configurationSettings = ['Database.Host', 'Database.Username', 'Database.Password', 'Database.Port', 'Database.Name'];
     foreach ($configurationSettings as $setting) {
         if ($this->configuration->hasConfigurationKey($setting) === false) {
             $this->missingConfiguration[] = $setting;
             $result = false;
         }
     }
     return $result;
 }
Пример #2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var InputExtendedInterface $input */
     $this->outputStartMessage($output);
     // If we enable the "setup-database-tables" setting, we will check if the necessary tables
     // are already there. If not we will try to setup / create them.
     // Try, because this process can fail due to missing access rights of the database user.
     // If the user got the needed rights, everything will work fine ;)
     if ($input->getOption('setup-database-tables') === true) {
         $databaseService = new DatabaseService($this->database, $output);
         $databaseService->setupDatabaseTables();
     }
     // Start the importer for each configured project
     $gerritSystems = $this->configuration->getConfigurationValue('Gerrit');
     $defaultSSHKeyFile = $this->configuration->getConfigurationValue('SSH.KeyFile');
     foreach ($gerritSystems as $name => $gerrieProject) {
         $gerritSystem = ['Name' => $name];
         foreach ($gerrieProject as $gerritInstance) {
             // TODO Extract this Instance Key part here. This is the same as in "ListProjectsCommand".
             // Get instance url
             // If the instance is a string, we only got a url path like scheme://user@url:port/
             if (is_string($gerritInstance)) {
                 $instanceConfig = ['Instance' => $gerritInstance, 'KeyFile' => $defaultSSHKeyFile];
                 // If the instance is an array, we get a key => value structure with an Instance key
             } elseif (is_array($gerritInstance) && isset($gerritInstance['Instance'])) {
                 $instanceConfig = ['Instance' => $gerritInstance['Instance'], 'KeyFile' => $defaultSSHKeyFile];
                 if (array_key_exists('KeyFile', $gerritInstance) === true) {
                     $instanceConfig['KeyFile'] = $gerritInstance['KeyFile'];
                 }
             } else {
                 throw new \RuntimeException('No Gerrit instance config given', 1415451921);
             }
             $dataService = DataServiceFactory::getDataService($instanceConfig);
             // Bootstrap the importer
             $gerrie = new Gerrie($this->database, $dataService, $gerritSystem);
             $gerrie->setOutput($output);
             if ($input->getOption('debug') === true) {
                 $gerrie->enableDebugFunctionality();
             } else {
                 $gerrie->disableDebugFunctionality();
             }
             // Start the crawling action
             $gerrie->crawl();
         }
     }
     $this->outputEndMessage($output);
 }
Пример #3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var InputExtendedInterface $input */
     // Start the importer for each configured project
     $gerritSystems = $this->configuration->getConfigurationValue('Gerrit');
     $defaultSSHKeyFile = $this->configuration->getConfigurationValue('SSH.KeyFile');
     $i = 0;
     foreach ($gerritSystems as $name => $gerrieProject) {
         foreach ($gerrieProject as $gerritInstance) {
             $path = parse_url($gerritInstance);
             // TODO Extract this Instance Key part here. This is the same as in "CrawlCommand".
             // Get instance url
             // If the instance is a string, we only got a url path like scheme://user@url:port/
             if (is_string($gerritInstance)) {
                 $instanceConfig = ['Instance' => $gerritInstance, 'KeyFile' => $defaultSSHKeyFile];
                 // If the instance is an array, we get a key => value structure with an Instance key
             } elseif (is_array($gerritInstance) && isset($gerritInstance['Instance'])) {
                 $instanceConfig = ['Instance' => $gerritInstance['Instance'], 'KeyFile' => $defaultSSHKeyFile];
                 if (array_key_exists('KeyFile', $gerritInstance) === true) {
                     $instanceConfig['KeyFile'] = $gerritInstance['KeyFile'];
                 }
             } else {
                 throw new \RuntimeException('No Gerrit instance config given', 1415451921);
             }
             $dataService = DataServiceFactory::getDataService($instanceConfig);
             $projects = $dataService->getProjects();
             if (is_array($projects) === false) {
                 throw new \Exception('No projects found on "' . $path['host'] . '"!', 1363894633);
             }
             if ($i >= 1) {
                 $output->writeln('');
             }
             $headline = '<comment>Instance: %s (via %s)</comment>';
             $headline = sprintf($headline, $path['host'], $dataService->getName());
             $output->writeln($headline);
             $output->writeln('<comment>' . str_repeat('=', 40) . '</comment>');
             foreach ($projects as $name => $project) {
                 $message = '<info>%s</info>';
                 $message = sprintf($message, $name);
                 $output->writeln($message);
             }
             $i++;
         }
     }
 }
Пример #4
0
 /**
  * Merges the command line arguments into a existing configuration.
  *
  * E.g.
  *  * Instances
  *
  * @param Configuration $config
  * @param InputExtendedInterface $input
  * @return Configuration
  */
 protected static function mergeCommandArgumentsIntoConfiguration(Configuration $config, InputExtendedInterface $input)
 {
     if ($input->hasArgument('instances') === false) {
         return $config;
     }
     $argumentInstances = $input->getArgument('instances');
     if (count($argumentInstances) === 0) {
         return $config;
     }
     // Gerrie is a reserved keyword for project names
     $config->setConfigurationValue('Gerrit.Gerrie', $argumentInstances);
     return $config;
 }
Пример #5
0
 public function testHasConfigurationKey()
 {
     $dummyConfig = $this->getDummyConfig();
     $configuration = new Configuration($dummyConfig);
     $this->assertTrue($configuration->hasConfigurationKey('Foo'));
     $this->assertTrue($configuration->hasConfigurationKey('Bar.Gerrie.Nested'));
     $this->assertTrue($configuration->hasConfigurationKey('Bar.Gerrie'));
     $this->assertTrue($configuration->hasConfigurationKey('Bar.Bar'));
     $this->assertFalse($configuration->hasConfigurationKey('Baz.Foo'));
     $this->assertFalse($configuration->hasConfigurationKey('Gerrie'));
 }