* Add auto insert pipeline data when install devops app.
This commit is contained in:
@@ -57,4 +57,6 @@ $config->instance->actionList['upgrade']['url'] = helper::createLink('in
|
||||
$config->instance->actions = new stdclass();
|
||||
$config->instance->actions->view = array();
|
||||
$config->instance->actions->view['mainActions'] = array('visit', 'start', 'stop', 'upgrade');
|
||||
$config->instance->actions->view['suffixActions'] = array('uninstall');
|
||||
$config->instance->actions->view['suffixActions'] = array('uninstall');
|
||||
|
||||
$config->instance->devopsApps = array(89 => 'gitea', 58 => 'gitlab', 57 => 'gogs', 59 => 'jenkins', 60 => 'sonarqube');
|
||||
@@ -77,13 +77,12 @@ class instance extends control
|
||||
}
|
||||
}
|
||||
|
||||
$dbList = new stdclass;
|
||||
$currentResource = new stdclass;
|
||||
$customItems = array();
|
||||
$dbList = $this->cne->appDBList($instance);
|
||||
$currentResource = $this->cne->getAppConfig($instance);
|
||||
$customItems = $this->cne->getCustomItems($instance);
|
||||
|
||||
$this->instanceZen->saveAuthInfo($instance);
|
||||
|
||||
$this->view->title = $instance->appName;
|
||||
$this->view->instance = $instance;
|
||||
$this->view->cloudApp = $this->loadModel('store')->getAppInfoByChart($instance->chart, $instance->channel, false);
|
||||
|
||||
@@ -575,6 +575,12 @@ class InstanceModel extends model
|
||||
$settingsMap->global->ingress->host = $settingsMap->ingress->host;
|
||||
}
|
||||
|
||||
if(!empty($this->config->instance->devopsApps[$instance->appID]))
|
||||
{
|
||||
$settingsMap->ci = new stdclass();
|
||||
$settingsMap->ci->enabled = true;
|
||||
}
|
||||
|
||||
if(empty($customData->dbType) || $customData->dbType == 'unsharedDB' || empty($customData->dbService)) return $settingsMap;
|
||||
|
||||
/* Set DB settings. */
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
<?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(empty($this->config->instance->devopsApps[$instance->appID])) return;
|
||||
|
||||
$url = 'https://' . $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 = $this->config->instance->devopsApps[$instance->appID];
|
||||
$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, 'admin_token', '');
|
||||
$pipeline->account = zget($tempMappings, 'admin_username', '');
|
||||
$pipeline->password = zget($tempMappings, 'admin_password', '');
|
||||
$pipeline->token = zget($tempMappings, 'admin_token', '');
|
||||
|
||||
$this->pipeline->create($pipeline);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动保存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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user