فهرست منبع

Arreglo en la generacion del *.host.env

Unificacion de la obtencion del dominio
gabriel 7 سال پیش
والد
کامیت
0c476424b0
1فایلهای تغییر یافته به همراه29 افزوده شده و 15 حذف شده
  1. 29 15
      tools/src/Release.php

+ 29 - 15
tools/src/Release.php

@@ -34,6 +34,10 @@ class Release extends Command
      * @var string Contiene el dominio.
      */
     private $_domain;
+    /**
+     * @var string Contiene el dominio que se agrega al final de la linea.
+     */
+    private $_domain_behind;
     /**
      * @var array Contiene la configuracion de los modulos.
      */
@@ -52,7 +56,7 @@ class Release extends Command
         $this->_mysql_root_pass = "235r2342gtfsw";
         $this->_mysql_user = "iksop";
         $this->_mysql_pass = "235r2342gtfsw";
-        $this->_domain = "fd3.flowdat.com";
+        $this->_domain_behind = "fd3.flowdat.com";
         $this->_modules = array(
             "base" => array(
                 'HOST_ENV' => true,
@@ -213,7 +217,7 @@ class Release extends Command
         $resp = array();
         foreach ($this->_modules as $key => $values) {
             if ($values['HOST_ENV']) {
-                $resp ["HOST_" . strtoupper($key)] = $key . "." . $this->_domain;
+                $resp ["HOST_" . strtoupper($key)] = $this->getDomain($key);
             }
         }
         return $resp;
@@ -224,7 +228,7 @@ class Release extends Command
         $resp = array();
         foreach ($this->_modules as $key => $values) {
             if ($values['HOST_ENV']) {
-                $resp [$key . "." . $this->_domain] = $config_ip;
+                $resp [$this->getDomain($key)] = $config_ip;
             }
         }
         return $resp;
@@ -266,7 +270,7 @@ class Release extends Command
             ->addLinks("mysql:mysql")
             ->addLinks("base")
             ->addLinks("amqp")
-            ->addLinks("base", "base." . $this->_domain)
+            ->addLinks("base", $this->getDomain("base"))
             ->addEnv_file($host_env_file)
             ->addEnv_file($module . "." . $host_env_file)
             ->addEnv_file($module . ".oauth.env")
@@ -290,7 +294,7 @@ class Release extends Command
             ->addLinks("mysql:mysql")
             ->addLinks("base")
             ->addLinks("amqp")
-            ->addLinks("base", "base." . $this->_domain)
+            ->addLinks("base", $this->getDomain("base"))
             //->addLinks("jsendpoint", "endpoint")
             //->addLinks("statsd", "statsd")
             ->addVolumes("./$module/", "/opt/$module")
@@ -316,7 +320,7 @@ class Release extends Command
             ->addLinks("mysql:mysql")
             ->addLinks("base")
             ->addLinks("amqp")
-            ->addLinks("base", "base." . $this->_domain)
+            ->addLinks("base", $this->getDomain("base"))
             ->addEnv_file($host_env_file)
             ->addEnv_file($module . "." . $host_env_file)
             ->addEnv_file("$module.oauth.env")
@@ -425,7 +429,7 @@ class Release extends Command
                 "GF_AUTH_ANONYMOUS_ORG_ROLE" => "Viewer",
                 "GF_AUTH_ANONYMOUS_ENABLED" => "true",
                 "GF_DATABASE_URL" => "mysql://root:" . $this->_mysql_root_pass . "@mysql:3306/grafana",
-                "GF_SERVER_ROOT_URL" => "http://grafana." . $this->_domain . "/"
+                "GF_SERVER_ROOT_URL" => "http://" . $this->getDomain("grafana") . "/"
             ));
     }
 
@@ -488,7 +492,7 @@ class Release extends Command
             ->addLinks("mysql")
             ->addLinks("base")
             ->addLinks("amqp")
-            ->addLinks("nginx", "base." . $this->_domain)
+            ->addLinks("nginx", $this->getDomain("base"))
             ->addVolumes("./base/", "/opt/base");
 
         $composer
@@ -500,7 +504,7 @@ class Release extends Command
             ->addLinks("mysql")
             ->addLinks("base")
             ->addLinks("amqp")
-            ->addLinks("nginx", "base." . $this->_domain)
+            ->addLinks("nginx", $this->getDomain("base"))
             ->addVolumes("./ftth/", "/opt/ftth");
 
         $composer
@@ -512,7 +516,7 @@ class Release extends Command
             ->addLinks("mysql")
             ->addLinks("base")
             ->addLinks("amqp")
-            ->addLinks("nginx", "base." . $this->_domain)
+            ->addLinks("nginx", $this->getDomain("base"))
             ->addVolumes("./ftth/", "/opt/ftth");
 
         $composer
@@ -524,7 +528,7 @@ class Release extends Command
             ->addLinks("mysql")
             ->addLinks("base")
             ->addLinks("amqp")
-            ->addLinks("nginx", "base." . $this->_domain)
+            ->addLinks("nginx", $this->getDomain("base"))
             ->addVolumes("./stats/", "/opt/stats");
     }
 
@@ -643,19 +647,20 @@ class Release extends Command
     }
 
     /**
+     * @param string $name Contiene el nombre del modulo.
      * @param string $module Contiene el nombre del modulo.
      * @param array $extras Contiene variables de entorno extra.
      * @return string|array Retorna un array con los datos de virtual host.
      */
-    function getEnviromentVarialbes($module, $extras = array())
+    function getEnviromentVarialbes($name, $module, $extras = array())
     {
         $env = "";
         if ($module != null) {
             foreach ($this->_modules as $nameApp => $app) {
-                if (isset($app['VAR_ENV'])) {
+                if (isset($app['VAR_ENV']) && $nameApp == $module) {
                     foreach ($app['VAR_ENV'] as $key => $value) {
                         if ($key == 'VIRTUAL_HOST') {
-                            $env .= "VIRTUAL_HOST=" . $module . "." . $this->_domain . "\n";
+                            $env .= "VIRTUAL_HOST=" . $this->getDomain($module) . "\n";
                         } else {
                             $env .= $key . "=" . $value . "\n";
                         }
@@ -719,7 +724,7 @@ class Release extends Command
     private function writeVariablesEnviroment($name, $module = null, $extras = array())
     {
         $this->_dObj->file($name)->content(
-            $this->getEnviromentVarialbes($module, $extras));
+            $this->getEnviromentVarialbes($name, $module, $extras));
     }
 
     /**
@@ -749,4 +754,13 @@ class Release extends Command
             $input->setOption($key, $value);
         }
     }
+
+    /**
+     * @param string $module Contiene el nombre del modulo.
+     * @return string Retorna el dominio para el modulo.
+     */
+    private function getDomain($module)
+    {
+        return $module . "." . $this->_domain . "." . $this->_domain_behind;
+    }
 }