mirror of
				https://github.com/hauke68/Magallanes.git
				synced 2025-11-04 00:50:18 +01:00 
			
		
		
		
	Allow override parameters in Host configuration.
This commit is contained in:
		
							parent
							
								
									80e0a283ff
								
							
						
					
					
						commit
						46d00e2f08
					
				@ -37,8 +37,20 @@ class Mage_Command_BuiltIn_Deploy
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            $this->_startTimeHosts = time();
 | 
					            $this->_startTimeHosts = time();
 | 
				
			||||||
            foreach ($hosts as $host) {
 | 
					            foreach ($hosts as $_hostKey => $host) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            	// Check if Host has specific configuration
 | 
				
			||||||
 | 
					            	$hostConfig = null;
 | 
				
			||||||
 | 
					            	if (is_array($host)) {
 | 
				
			||||||
 | 
					            		$hostConfig = $host;
 | 
				
			||||||
 | 
					                    $host = $_hostKey;
 | 
				
			||||||
 | 
					            	}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            	// Set Host and Host Specific Config
 | 
				
			||||||
                $this->getConfig()->setHost($host);
 | 
					                $this->getConfig()->setHost($host);
 | 
				
			||||||
 | 
					                $this->getConfig()->setHostConfig($hostConfig);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // Prepare Tasks
 | 
				
			||||||
                $tasks = 0;
 | 
					                $tasks = 0;
 | 
				
			||||||
                $completedTasks = 0;
 | 
					                $completedTasks = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -71,6 +83,9 @@ class Mage_Command_BuiltIn_Deploy
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                    Mage_Console::output('Deployment to <dark_gray>' . $this->getConfig()->getHost() . '</dark_gray> completed: <' . $tasksColor . '>' . $completedTasks . '/' . $tasks . '</' . $tasksColor . '> tasks done.', 1, 3);
 | 
					                    Mage_Console::output('Deployment to <dark_gray>' . $this->getConfig()->getHost() . '</dark_gray> completed: <' . $tasksColor . '>' . $completedTasks . '/' . $tasks . '</' . $tasksColor . '> tasks done.', 1, 3);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // Reset Host Config
 | 
				
			||||||
 | 
					                $this->getConfig()->setHostConfig(null);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            $this->_endTimeHosts = time();
 | 
					            $this->_endTimeHosts = time();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -5,6 +5,7 @@ class Mage_Config
 | 
				
			|||||||
    private $_parameters  = array();
 | 
					    private $_parameters  = array();
 | 
				
			||||||
    private $_environment = false;
 | 
					    private $_environment = false;
 | 
				
			||||||
    private $_host = null;
 | 
					    private $_host = null;
 | 
				
			||||||
 | 
					    private $_hostConfig = null;
 | 
				
			||||||
    private $_releaseId = null;
 | 
					    private $_releaseId = null;
 | 
				
			||||||
    private $_config = array(
 | 
					    private $_config = array(
 | 
				
			||||||
        'general'     => array(),
 | 
					        'general'     => array(),
 | 
				
			||||||
@ -115,6 +116,14 @@ class Mage_Config
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        $tasks = array();
 | 
					        $tasks = array();
 | 
				
			||||||
        $config = $this->_getEnvironmentOption('tasks', array());
 | 
					        $config = $this->_getEnvironmentOption('tasks', array());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Host Config
 | 
				
			||||||
 | 
					        if (is_array($this->_hostConfig) && isset($this->_hostConfig['tasks'])) {
 | 
				
			||||||
 | 
					        	if (isset($this->_hostConfig['tasks'][$stage])) {
 | 
				
			||||||
 | 
					        		$config[$stage] = $this->_hostConfig['tasks'][$stage];
 | 
				
			||||||
 | 
					        	}
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (isset($config[$stage])) {
 | 
					        if (isset($config[$stage])) {
 | 
				
			||||||
            $tasksData = ($config[$stage] ? (array) $config[$stage] : array());
 | 
					            $tasksData = ($config[$stage] ? (array) $config[$stage] : array());
 | 
				
			||||||
            foreach ($tasksData as $taskName => $taskData) {
 | 
					            foreach ($tasksData as $taskName => $taskData) {
 | 
				
			||||||
@ -171,6 +180,18 @@ class Mage_Config
 | 
				
			|||||||
        return $this;
 | 
					        return $this;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Set the host specific configuration
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param array $hostConfig
 | 
				
			||||||
 | 
					     * @return Mage_Config
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function setHostConfig($hostConfig = null)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					    	$this->_hostConfig = $hostConfig;
 | 
				
			||||||
 | 
					    	return $this;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Get the current host name
 | 
					     * Get the current host name
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
@ -234,6 +255,14 @@ class Mage_Config
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public function deployment($option, $default = false)
 | 
					    public function deployment($option, $default = false)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					    	// Host Config
 | 
				
			||||||
 | 
					    	if (is_array($this->_hostConfig) && isset($this->_hostConfig['deployment'])) {
 | 
				
			||||||
 | 
					    		if (isset($this->_hostConfig['deployment'][$option])) {
 | 
				
			||||||
 | 
					    			return $this->_hostConfig['deployment'][$option];
 | 
				
			||||||
 | 
					    		}
 | 
				
			||||||
 | 
					    	}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    	// Global Config
 | 
				
			||||||
        $config = $this->_getEnvironmentOption('deployment', array());
 | 
					        $config = $this->_getEnvironmentOption('deployment', array());
 | 
				
			||||||
        if (isset($config[$option])) {
 | 
					        if (isset($config[$option])) {
 | 
				
			||||||
            if (is_array($default) && ($config[$option] == '')) {
 | 
					            if (is_array($default) && ($config[$option] == '')) {
 | 
				
			||||||
@ -254,7 +283,14 @@ class Mage_Config
 | 
				
			|||||||
     * @return mixed
 | 
					     * @return mixed
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public function release($option, $default = false)
 | 
					    public function release($option, $default = false)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					    	// Host Config
 | 
				
			||||||
 | 
					    	if (is_array($this->_hostConfig) && isset($this->_hostConfig['releases'])) {
 | 
				
			||||||
 | 
					    		if (isset($this->_hostConfig['releases'][$option])) {
 | 
				
			||||||
 | 
					    			return $this->_hostConfig['releases'][$option];
 | 
				
			||||||
 | 
					    		}
 | 
				
			||||||
 | 
					    	}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $config = $this->_getEnvironmentOption('releases', array());
 | 
					        $config = $this->_getEnvironmentOption('releases', array());
 | 
				
			||||||
        if (isset($config[$option])) {
 | 
					        if (isset($config[$option])) {
 | 
				
			||||||
            if (is_array($default) && ($config[$option] == '')) {
 | 
					            if (is_array($default) && ($config[$option] == '')) {
 | 
				
			||||||
 | 
				
			|||||||
@ -1,12 +1,12 @@
 | 
				
			|||||||
#production
 | 
					#production
 | 
				
			||||||
deployment:
 | 
					deployment:
 | 
				
			||||||
  user: root
 | 
					  user: root
 | 
				
			||||||
#  from: ./
 | 
					  from: ./
 | 
				
			||||||
  source:
 | 
					#  source:
 | 
				
			||||||
    type: git
 | 
					#    type: git
 | 
				
			||||||
    repository: git://github.com/andres-montanez/Zend-Framework-Twig-example-app.git
 | 
					#    repository: git://github.com/andres-montanez/Zend-Framework-Twig-example-app.git
 | 
				
			||||||
    from: production
 | 
					#    from: production
 | 
				
			||||||
    temporal: /tmp/myAppClone
 | 
					#    temporal: /tmp/myAppClone
 | 
				
			||||||
  to: /var/www/vhosts/example.com/www
 | 
					  to: /var/www/vhosts/example.com/www
 | 
				
			||||||
  excludes:
 | 
					  excludes:
 | 
				
			||||||
    - application/data/cache/twig/*
 | 
					    - application/data/cache/twig/*
 | 
				
			||||||
@ -16,8 +16,19 @@ releases:
 | 
				
			|||||||
  symlink: current
 | 
					  symlink: current
 | 
				
			||||||
  directory: releases
 | 
					  directory: releases
 | 
				
			||||||
hosts:
 | 
					hosts:
 | 
				
			||||||
  - s01.example.com:22
 | 
					  s01.example.com:22:
 | 
				
			||||||
  - s02.example.com
 | 
					    deployment:
 | 
				
			||||||
 | 
					      user: nobody
 | 
				
			||||||
 | 
					  s02.example.com:
 | 
				
			||||||
 | 
					    deployment:
 | 
				
			||||||
 | 
					      user: toor
 | 
				
			||||||
 | 
					      to: /home/web/public
 | 
				
			||||||
 | 
					    releases:
 | 
				
			||||||
 | 
					      max: 10
 | 
				
			||||||
 | 
					    tasks:
 | 
				
			||||||
 | 
					      on-deploy:
 | 
				
			||||||
 | 
					        - privileges
 | 
				
			||||||
 | 
					  - s03.example.com
 | 
				
			||||||
tasks:
 | 
					tasks:
 | 
				
			||||||
  pre-deploy:
 | 
					  pre-deploy:
 | 
				
			||||||
    - scm/update
 | 
					    - scm/update
 | 
				
			||||||
 | 
				
			|||||||
@ -3,3 +3,6 @@ name: My fantastic App
 | 
				
			|||||||
email: andresmontanez@gmail.com
 | 
					email: andresmontanez@gmail.com
 | 
				
			||||||
notifications: true
 | 
					notifications: true
 | 
				
			||||||
logging: true
 | 
					logging: true
 | 
				
			||||||
 | 
					scm:
 | 
				
			||||||
 | 
					  type: git
 | 
				
			||||||
 | 
					  url:  git://github.com/andres-montanez/Zend-Framework-Twig-example-app.git 
 | 
				
			||||||
@ -1,3 +0,0 @@
 | 
				
			|||||||
#scm settings
 | 
					 | 
				
			||||||
type: git
 | 
					 | 
				
			||||||
uri: git://github.com/andres-montanez/Zend-Framework-Twig-example-app.git
 | 
					 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user