public function compare() { if (empty($this->stack)) { throw new \InvalidArgumentException('Stack not set'); } if (empty($this->blueprint)) { throw new \InvalidArgumentException('Blueprint not set'); } $tmp = []; try { // parameters if ($this->output->isVerbose()) { $this->output->writeln($this->stack->getName() . ': Comparing parameters'); } $parametersStack = $this->stack->getParameters(); $parametersBlueprint = $this->blueprint->getParameters(true); $parametersBlueprint = Div::flatten($parametersBlueprint, 'ParameterKey', 'ParameterValue'); if ($this->parametersAreEqual($parametersStack, $parametersBlueprint)) { $tmp['parameters'] = "<fg=green>equal</>"; } else { $tmp['parameters'] = "<fg=red>different</>"; $tmp['error'] = true; } // template if ($this->output->isVerbose()) { $this->output->writeln($this->stack->getName() . ': Comparing template'); } $templateStack = trim($this->stack->getTemplate()); $templateBlueprint = trim($this->blueprint->getPreprocessedTemplate()); $templateStack = $this->normalizeJson($templateStack); $templateBlueprint = $this->normalizeJson($templateBlueprint); if ($templateStack === $templateBlueprint) { $tmp['template'] = "<fg=green>equal</>"; } else { $tmp['template'] = "<fg=red>different</>"; $tmp['error'] = true; } } catch (CloudFormationException $e) { $tmp['parameters'] = 'Stack not found'; $tmp['template'] = 'Stack not found'; $tmp['error'] = true; } catch (\Exception $e) { $tmp['parameters'] = '<fg=red>EXCEPTION: ' . $e->getMessage() . '</>'; $tmp['template'] = 'EXCEPTION'; $tmp['error'] = true; } return $tmp; }
protected function executeWithBlueprint(Blueprint $blueprint, InputInterface $input, OutputInterface $output) { $unresolved = $input->getOption('unresolved'); $output->writeln("Blueprint '{$blueprint->getName()}':"); $parameters = $blueprint->getParameters(!$unresolved); $output->writeln('== PARAMETERS =='); $table = new Table($output); $table->setHeaders(['Key', 'Value'])->setRows($parameters); $table->render(); $output->writeln('== TAGS =='); $table = new Table($output); $table->setHeaders(['Key', 'Value'])->setRows($blueprint->getTags(!$unresolved)); $table->render(); }