* Fix bug #38237.
This commit is contained in:
@@ -422,15 +422,14 @@ class install extends control
|
||||
$components = json_decode($solution->components);
|
||||
foreach($components as $categorty => $componentApp)
|
||||
{
|
||||
if($componentApp->status == 'installing')
|
||||
$instance = $this->loadModel('instance')->instanceOfSolution($solution, $componentApp->chart);
|
||||
if($instance && $componentApp->status == 'installing')
|
||||
{
|
||||
$instance = $this->loadModel('instance')->instanceOfSolution($solution, $componentApp->chart);
|
||||
if($instance)
|
||||
{
|
||||
$chartLogs = $this->loadModel('cne')->getAppLogs($instance);
|
||||
$logs[$componentApp->chart] = !empty($chartLogs->data) ? $chartLogs->data : array();
|
||||
}
|
||||
$chartLogs = $this->loadModel('cne')->getAppLogs($instance);
|
||||
$logs[$componentApp->chart] = !empty($chartLogs->data) ? $chartLogs->data : array();
|
||||
}
|
||||
|
||||
if($instance && $componentApp->status === 'installed') $this->instance->saveAuthInfo($instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ class instance extends control
|
||||
$currentResource = $this->cne->getAppConfig($instance);
|
||||
$customItems = $this->cne->getCustomItems($instance);
|
||||
|
||||
if($instance->status == 'running') $this->instanceZen->saveAuthInfo($instance);
|
||||
if($instance->status == 'running') $this->instance->saveAuthInfo($instance);
|
||||
if(in_array($instance->chart, $this->config->instance->devopsApps))
|
||||
{
|
||||
$url = strstr(getWebRoot(true), ':', true) . '://' . $instance->domain;
|
||||
|
||||
@@ -2103,4 +2103,62 @@ class InstanceModel extends model
|
||||
|
||||
return ($existInstance || $existExternal) ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动保存devops应用授权信息。
|
||||
* Auto save auth info of devops.
|
||||
*
|
||||
* @param object $instance
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
public function saveAuthInfo(object $instance): void
|
||||
{
|
||||
if(!in_array($instance->chart, $this->config->instance->devopsApps)) return;
|
||||
|
||||
$url = strstr(getWebRoot(true), ':', true) . '://' . $instance->domain;
|
||||
$pipeline = $this->loadModel('pipeline')->getByUrl($url);
|
||||
if(!empty($pipeline)) return;
|
||||
|
||||
$tempMappings = $this->loadModel('cne')->getSettingsMapping($instance);
|
||||
if(empty($tempMappings)) return;
|
||||
|
||||
$pipeline = new stdclass();
|
||||
$instance->type = $instance->chart;
|
||||
$pipeline->type = $instance->type;
|
||||
$pipeline->private = md5(strval(rand(10,113450)));
|
||||
$pipeline->createdBy = 'system';
|
||||
$pipeline->createdDate = helper::now();
|
||||
$pipeline->url = $url;
|
||||
$pipeline->name = $this->generatePipelineName($instance);
|
||||
$pipeline->token = zget($tempMappings, 'api_token', '');
|
||||
$pipeline->account = zget($tempMappings, 'z_username', '');
|
||||
$pipeline->password = zget($tempMappings, 'z_password', '');
|
||||
if($instance->chart == 'sonarqube') $pipeline->token = base64_encode($pipeline->token . ':');
|
||||
if(empty($pipeline->account)) $pipeline->account = zget($tempMappings, 'admin_username', '');
|
||||
|
||||
$this->pipeline->create($pipeline);
|
||||
if(dao::isError()) dao::getError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动生成pipline表name字段。
|
||||
* Auto generate name of pipline table.
|
||||
*
|
||||
* @param object $instance
|
||||
* @access protected
|
||||
* @return string
|
||||
*/
|
||||
public function generatePipelineName(object $instance): string
|
||||
{
|
||||
$name = $instance->name;
|
||||
$type = $instance->type;
|
||||
if(empty($this->loadModel('pipeline')->getByNameAndType($name, $type))) return $name;
|
||||
if(empty($this->loadModel('pipeline')->getByNameAndType($name . '-' . $instance->appVersion, $type))) return $name . '-' . $instance->appVersion;
|
||||
|
||||
for($times = 1; $times < 5; $times ++)
|
||||
{
|
||||
if(empty($this->loadModel('pipeline')->getByNameAndType($name . '-' . $times, $name))) return $name . '-' . $times;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* The zen file of instance module of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
|
||||
* @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
|
||||
* @author Ke Zhao<zhaoke@easycorp.ltd>
|
||||
* @package instance
|
||||
* @link https://www.zentao.net
|
||||
*/
|
||||
class instanceZen extends instance
|
||||
{
|
||||
/**
|
||||
* 自动保存devops应用授权信息。
|
||||
* Auto save auth info of devops.
|
||||
*
|
||||
* @param object $instance
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
protected function saveAuthInfo(object $instance): void
|
||||
{
|
||||
if(!in_array($instance->chart, $this->config->instance->devopsApps)) return;
|
||||
|
||||
$url = strstr(getWebRoot(true), ':', true) . '://' . $instance->domain;
|
||||
$pipeline = $this->loadModel('pipeline')->getByUrl($url);
|
||||
if(!empty($pipeline)) return;
|
||||
|
||||
$tempMappings = $this->loadModel('cne')->getSettingsMapping($instance);
|
||||
if(empty($tempMappings)) return;
|
||||
|
||||
$pipeline = new stdclass();
|
||||
$instance->type = $instance->chart;
|
||||
$pipeline->type = $instance->type;
|
||||
$pipeline->private = md5(strval(rand(10,113450)));
|
||||
$pipeline->createdBy = 'system';
|
||||
$pipeline->createdDate = helper::now();
|
||||
$pipeline->url = $url;
|
||||
$pipeline->name = $this->generatePipelineName($instance);
|
||||
$pipeline->token = zget($tempMappings, 'api_token', '');
|
||||
$pipeline->account = zget($tempMappings, 'z_username', '');
|
||||
$pipeline->password = zget($tempMappings, 'z_password', '');
|
||||
if($instance->appID == 60) $pipeline->token = base64_encode($pipeline->token . ':');
|
||||
if(empty($pipeline->account)) $pipeline->account = zget($tempMappings, 'admin_username', '');
|
||||
|
||||
$this->pipeline->create($pipeline);
|
||||
if(dao::isError()) dao::getError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动保存devops应用授权信息。
|
||||
* Auto save auth info of devops.
|
||||
*
|
||||
* @param object $instance
|
||||
* @access protected
|
||||
* @return string
|
||||
*/
|
||||
protected function generatePipelineName(object $instance): string
|
||||
{
|
||||
$name = $instance->name;
|
||||
$type = $instance->type;
|
||||
if(empty($this->loadModel('pipeline')->getByNameAndType($name, $type))) return $name;
|
||||
if(empty($this->loadModel('pipeline')->getByNameAndType($name . '-' . $instance->appVersion, $type))) return $name . '-' . $instance->appVersion;
|
||||
|
||||
for($times = 1; $times < 5; $times ++)
|
||||
{
|
||||
if(empty($this->loadModel('pipeline')->getByNameAndType($name . '-' . $times, $name))) return $name . '-' . $times;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,11 @@ if($viewType == 'doc' or $viewType == 'api')
|
||||
$editTitle = $lang->doc->editType;
|
||||
$deleteTitle = $lang->doc->deleteType;
|
||||
}
|
||||
if($viewType == 'host')
|
||||
{
|
||||
$deleteTitle = $lang->tree->deleteHost;
|
||||
$editTitle = $lang->tree->editHost;
|
||||
}
|
||||
?>
|
||||
<!--div id="mainMenu" class="clearfix">
|
||||
<div class="btn-toolbar pull-left">
|
||||
|
||||
@@ -30,6 +30,7 @@ if(isset($pageCSS)) css::internal($pageCSS);
|
||||
$required = 'root,name';
|
||||
}
|
||||
if($type == 'line') $lblEditTree = $lang->tree->manageLine;
|
||||
if($type == 'host') $lblEditTree = $lang->tree->editHost;
|
||||
echo $lblEditTree;
|
||||
?>
|
||||
</strong>
|
||||
@@ -62,7 +63,12 @@ if(isset($pageCSS)) css::internal($pageCSS);
|
||||
<?php endif;?>
|
||||
<?php if($module->type != 'line'):?>
|
||||
<tr <?php if($hidden) echo "style='display:none'";?>>
|
||||
<th class='thWidth'><?php echo ($type == 'doc' or $type == 'api') ? $lang->tree->parentCate : $lang->tree->parent;?></th>
|
||||
<?php
|
||||
$parentName = $lang->tree->parent;
|
||||
if($type == 'doc' or $type == 'api') $parentName = $lang->tree->parentCate;
|
||||
if($type == 'host') $parentName = $lang->tree->parentGroup;
|
||||
?>
|
||||
<th class='thWidth'><?php echo $parentName;?></th>
|
||||
<td>
|
||||
<div class='input-group' id='moduleIdBox'>
|
||||
<?php echo html::select('parent', $optionMenu, $module->parent, "class='form-control chosen'");?>
|
||||
@@ -76,6 +82,7 @@ if(isset($pageCSS)) css::internal($pageCSS);
|
||||
$lblTreeName = $lang->tree->name;
|
||||
if($type == 'doc' or $type == 'api') $lblTreeName = $lang->tree->dir;
|
||||
if($type == 'line') $lblTreeName = $lang->tree->line;
|
||||
if($type == 'host') $lblTreeName = $lang->tree->groupName;
|
||||
echo $lblTreeName;
|
||||
?>
|
||||
</th>
|
||||
|
||||
Reference in New Issue
Block a user