mirror of
https://github.com/andres-montanez/Magallanes
synced 2024-05-18 13:46:40 +02:00
Use environment variables for changeing deployment and releases settings
This makes the deployment configurations more flexible and easier to reuse.
This commit is contained in:
parent
ac36fb29d5
commit
cbf28cc1b0
|
@ -450,6 +450,13 @@ class Config
|
|||
*/
|
||||
public function deployment($option, $default = false)
|
||||
{
|
||||
// Environment variable override
|
||||
$envValue = getenv('MAGE_DEPLOYMENT_' . strtoupper($option));
|
||||
|
||||
if ($envValue !== false) {
|
||||
return $envValue;
|
||||
}
|
||||
|
||||
// Host Config
|
||||
if (is_array($this->hostConfig) && isset($this->hostConfig['deployment'])) {
|
||||
if (isset($this->hostConfig['deployment'][$option])) {
|
||||
|
@ -484,6 +491,13 @@ class Config
|
|||
*/
|
||||
public function release($option, $default = false)
|
||||
{
|
||||
// Environment variable override
|
||||
$envValue = getenv('MAGE_RELEASE_' . strtoupper($option));
|
||||
|
||||
if ($envValue !== false) {
|
||||
return $envValue;
|
||||
}
|
||||
|
||||
// Host Config
|
||||
if (is_array($this->hostConfig) && isset($this->hostConfig['releases'])) {
|
||||
if (isset($this->hostConfig['releases'][$option])) {
|
||||
|
|
46
tests/MageTest/ConfigTest.php
Normal file
46
tests/MageTest/ConfigTest.php
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
namespace MageTest\Command;
|
||||
|
||||
use Mage\Config;
|
||||
use PHPUnit_Framework_TestCase;
|
||||
|
||||
/**
|
||||
* @group Mage_Config
|
||||
*/
|
||||
class ConfigTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testOverrideDeploymentOptionWithEnvironemntVariable()
|
||||
{
|
||||
$config = new Config();
|
||||
|
||||
$expected = 'b';
|
||||
$actual = $config->deployment('a', 'b');
|
||||
|
||||
$this->assertSame($expected, $actual);
|
||||
|
||||
putenv('MAGE_DEPLOYMENT_A=c');
|
||||
|
||||
$expected = 'c';
|
||||
$actual = $config->deployment('a', 'b');
|
||||
|
||||
$this->assertSame($expected, $actual);
|
||||
}
|
||||
|
||||
public function testOverrideReleaseOptionWithEnvironemntVariable()
|
||||
{
|
||||
$config = new Config();
|
||||
|
||||
$expected = 'b';
|
||||
$actual = $config->release('a', 'b');
|
||||
|
||||
$this->assertSame($expected, $actual);
|
||||
|
||||
putenv('MAGE_RELEASE_A=c');
|
||||
|
||||
$expected = 'c';
|
||||
$actual = $config->release('a', 'b');
|
||||
|
||||
$this->assertSame($expected, $actual);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue