getTemplate() public méthode

public getTemplate ( )
Exemple #1
0
 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;
 }