Skip to content

Commit

Permalink
certs block moved to bottom on config generator output
Browse files Browse the repository at this point in the history
  • Loading branch information
EvilFreelancer committed Mar 14, 2020
1 parent de69c7d commit f68809d
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,17 @@ public function generate(): string
// Init the variable
$config = '';

// Basic parameters first
foreach ($this->config->getParameters() as $key => $value) {
$config .= $key . ($value !== '' ? ' ' . $value : '') . "\n";
}

$certs = $this->config->getCerts();
if (count($certs) > 0) {
$config .= "\n### Certificates\n";
foreach ($this->config->getCerts() as $key => $value) {
$config .= isset($value['content'])
? "<$key>\n{$value['content']}\n</$key>\n"
: "$key {$value['path']}\n";
}
}

// Get all what need for normal work
$pushes = $this->config->getPushes();
$routes = $this->config->getRoutes();
$certs = $this->config->getCerts();

// If we have routes or pushes in lists then generate it
if (count($pushes) || count($routes)) {
$config .= "\n### Networking\n";
foreach ($routes as $route) {
Expand All @@ -65,6 +60,16 @@ public function generate(): string
}
}

// Certs should be below everything, due embedded keys and certificates
if (count($certs) > 0) {
$config .= "\n### Certificates\n";
foreach ($this->config->getCerts() as $key => $value) {
$config .= isset($value['content'])
? "<$key>\n{$value['content']}\n</$key>\n"
: "$key {$value['path']}\n";
}
}

return $config;
}
}

0 comments on commit f68809d

Please sign in to comment.