未验证 提交 bd711359 编写于 作者: C colynn.liu 提交者: GitHub

Merge pull request #155 from colynn/feat-152-image-tag-tunning

feat: branch verify and message z-index updated
......@@ -99,8 +99,8 @@ func (manager *AppManager) SetArrange(
return err
}
log.Log.Debug("update app arrnage item id: %v", id)
//
validItemIDs := []int64{}
// TODO: add verify, one arrange only support add one image mapping item.
for _, imageMappingitem := range request.ImageMapings {
if imageMappingitem.ProjectAppID == 0 {
log.Log.Debug("item: %v did not join with project app: 0, skip", imageMappingitem.Name)
......
......@@ -71,43 +71,6 @@ type DeployStepReq struct {
Apps []*RunDeployAppReq `json:"apps"`
}
//PublishApplyStepReq publish apply request
type PublishApplyStepReq struct {
Approver string `json:"approver"`
Message string `json:"message"`
}
// PublishStepReq pipeline run publish
type PublishStepReq struct {
ActionName string `json:"action_name"`
Apps []*RunPublishAppReq `json:"apps"`
EnableSwitchBranch bool `json:"enable_switch_branch"`
}
// BaseStepReq [Verify Step]..
type BaseStepReq struct {
Status string `json:"status"`
}
// PublishAuditStepReq ..
type PublishAuditStepReq struct {
BaseStepReq
Message string `json:"message"`
}
// RunPublishAppReq .
type RunPublishAppReq struct {
AutoMerge bool `json:"auto_merge"`
Branch string `json:"branch_name"`
Gray bool `json:"gray"`
ImageVersion string `json:"image_version"`
Jacoco bool `json:"jacoco"`
ProjectAppID int64 `json:"project_app_id"`
StaticCheck bool `json:"static_check"`
TargetBranch string `json:"target_branch"`
UnitTest bool `json:"unit_test"`
}
// WeeklyDenyList ..
type WeeklyDenyList []*struct {
StartTime string `json:"start_time"`
......@@ -323,14 +286,6 @@ type AppParamsForHealthCheck struct {
FullName string `json:"full_name"`
}
// RunPublishAllParms there are all apps parms for jenkins pipeline job
type RunPublishAllParms struct {
*models.ProjectApp
*RunPublishAppReq
Release string `json:"release"`
MergeBranch bool `json:"merge-branch"`
}
// PublishJobBuildResult ..
type PublishJobBuildResult struct {
AppID string `json:"app_id"`
......
......@@ -579,49 +579,20 @@ func (pm *PipelineManager) renderTemplateStr(apps []*RunDeployAppReq, publishID,
log.Log.Error("get app id: %v env id: %v real arrange, occur error: %s", item.ProjectAppID, envID, err.Error())
continue
}
// TODO: write continue
imageMappings, err := pm.modelAppArrange.GetAppImageMappingByArrangeID(arrange.ID)
// replace template str
arrangeConfig := arrange.Config
publishApp, err := pm.modelPublish.GetPublishAppByPublishIDAndAppID(publishID, item.ProjectAppID)
if err != nil {
log.Log.Error("get imagemapping error: %s", err.Error())
logs.Warn("when get publish app by publishid/appid occur error:%s, did not update app arrange image info", err.Error())
continue
}
// replace template str
arrangeConfig := arrange.Config
var newImageAddr string
for _, image := range imageMappings {
switch image.ImageTagType {
// TODO: multiple imageTagType, code combine
case models.SystemDefaultTag:
publishApp, err := pm.modelPublish.GetPublishAppByPublishIDAndAppID(publishID, item.ProjectAppID)
if err != nil {
logs.Warn("when get publish app by publishid/appid occur error:%s, did not update app arrange image info", err.Error())
continue
}
imageTag, err := pm.getAppCodeCommitByBranch(item.ProjectAppID, publishApp.BranchName)
if err != nil {
logs.Warn("when get app code commit by branch error: %s, did not update app arrange image info", err.Error())
continue
}
originImageSplit := strings.Split(image.Image, ":")
imageStr := image.Image
if len(originImageSplit) == 2 {
imageStr = originImageSplit[0]
}
newImageAddr = fmt.Sprintf("%s:%s", imageStr, imageTag)
arrangeConfig = strings.Replace(arrangeConfig, image.Image, newImageAddr, -1)
case models.LatestTag:
originImageSplit := strings.Split(image.Image, ":")
imageStr := image.Image
if len(originImageSplit) == 2 {
imageStr = originImageSplit[0]
}
newImageAddr = fmt.Sprintf("%s:%s", imageStr, "latest")
arrangeConfig = strings.Replace(arrangeConfig, image.Image, newImageAddr, -1)
case models.OriginTag:
log.Log.Debug("image tag use from yaml, no need replace")
}
newImageAddr, originImage, err := pm.generateImageAddr(arrange.ID, item.ProjectAppID, publishApp.BranchName)
if err != nil {
continue
}
arrangeConfig = strings.Replace(arrangeConfig, originImage, newImageAddr, -1)
if templateStr == "" {
templateStr = arrangeConfig
} else {
......@@ -631,7 +602,42 @@ func (pm *PipelineManager) renderTemplateStr(apps []*RunDeployAppReq, publishID,
return templateStr, nil
}
func (pm *PipelineManager) getAppCodeCommitByBranch(appID int64, branchName string) (string, error) {
func (pm *PipelineManager) generateImageAddr(arrangeID, projectAppID int64, branch string) (string, string, error) {
imageMapping, err := pm.modelAppArrange.GetAppImageMappingByArrangeIDAndProjectAppID(arrangeID, projectAppID)
if err != nil {
log.Log.Error("get imagemapping error: %s", err.Error())
return "", "", err
}
newImageAddr := imageMapping.Image
switch imageMapping.ImageTagType {
case models.SystemDefaultTag:
// branch get from RunBuildAppReq.Branch
imageTag, err := pm.GetAppCodeCommitByBranch(projectAppID, branch)
if err != nil {
logs.Error("when get app code commit by branch error: %s, did not update app arrange image info", err.Error())
return "", "", err
}
originImageSplit := strings.Split(imageMapping.Image, ":")
imageStr := imageMapping.Image
if len(originImageSplit) == 2 {
imageStr = originImageSplit[0]
}
newImageAddr = fmt.Sprintf("%s:%s", imageStr, imageTag)
case models.LatestTag:
originImageSplit := strings.Split(imageMapping.Image, ":")
imageStr := imageMapping.Image
if len(originImageSplit) == 2 {
imageStr = originImageSplit[0]
}
newImageAddr = fmt.Sprintf("%s:%s", imageStr, "latest")
case models.OriginTag:
log.Log.Debug("image tag use from yaml, no need replace")
}
return newImageAddr, imageMapping.Image, nil
}
func (pm *PipelineManager) GetAppCodeCommitByBranch(appID int64, branchName string) (string, error) {
projectApp, err := pm.modelProject.GetProjectApp(appID)
if err != nil {
log.Log.Error("when get app code commit, get project ap by id: %v error:%s", appID, err.Error())
......@@ -666,8 +672,8 @@ func (pm *PipelineManager) getAppCodeCommitByBranch(appID int64, branchName stri
if len(got) > 0 {
return branchName + "-" + got[0].Sha[0:7], nil
} else {
logs.Warn("branch: %v did not include any commit, use latest tag", branchName)
return branchName + "-latest", nil
logs.Warn("branch: %v did not include any commit", branchName)
return "", fmt.Errorf("应用:%v 分支:%v 未包含任何提交, 请通过“我的应用”-“应用详情”-“同步远程分支”后重新选择", scmApp.Name, branchName)
}
}
......@@ -943,43 +949,16 @@ func (pm *PipelineManager) aggregateAppsParamsForDeploy(publishID, stageID int64
continue
}
imageMapping, err := pm.modelAppArrange.GetAppImageMappingByArrangeIDAndProjectAppID(arrange.ID, app.ProjectAppID)
publishApp, err := pm.modelPublish.GetPublishAppByPublishIDAndAppID(publishID, app.ProjectAppID)
if err != nil {
log.Log.Error("get imagemapping error: %s", err.Error())
logs.Warn("when get publish app by publishid/appid occur error:%s, did not update app arrange image info", err.Error())
continue
}
newImageAddr := imageMapping.Image
switch imageMapping.ImageTagType {
case models.SystemDefaultTag:
publishApp, err := pm.modelPublish.GetPublishAppByPublishIDAndAppID(publishID, app.ProjectAppID)
if err != nil {
logs.Warn("when get publish app by publishid/appid occur error:%s, did not update app arrange image info", err.Error())
continue
}
imageTag, err := pm.getAppCodeCommitByBranch(app.ProjectAppID, publishApp.BranchName)
if err != nil {
logs.Warn("when get app code commit by branch error: %s, did not update app arrange image info", err.Error())
continue
}
originImageSplit := strings.Split(imageMapping.Image, ":")
imageStr := imageMapping.Image
if len(originImageSplit) == 2 {
imageStr = originImageSplit[0]
}
newImageAddr = fmt.Sprintf("%s:%s", imageStr, imageTag)
case models.LatestTag:
originImageSplit := strings.Split(imageMapping.Image, ":")
imageStr := imageMapping.Image
if len(originImageSplit) == 2 {
imageStr = originImageSplit[0]
}
newImageAddr = fmt.Sprintf("%s:%s", imageStr, "latest")
case models.OriginTag:
log.Log.Debug("image tag use from yaml, no need replace")
newImageAddr, _, err := pm.generateImageAddr(arrange.ID, app.ProjectAppID, publishApp.BranchName)
if err != nil {
continue
}
log.Log.Debug("imageAddr: %s", newImageAddr)
allParm := &RunDeployAllParms{
ProjectID: projectApp.ProjectID,
......@@ -988,7 +967,6 @@ func (pm *PipelineManager) aggregateAppsParamsForDeploy(publishID, stageID int64
ImageAddr: newImageAddr,
}
allParms = append(allParms, allParm)
}
return allParms, nil
}
......@@ -1101,44 +1079,10 @@ func (pm *PipelineManager) renderAppImageitemsForBuild(projectID, publishID, sta
continue
}
imageMapping, err := pm.modelAppArrange.GetAppImageMappingByArrangeIDAndProjectAppID(arrange.ID, app.ProjectAppID)
imageURL, _, err := pm.generateImageAddr(arrange.ID, app.ProjectAppID, app.Branch)
if err != nil {
log.Log.Error("get imagemapping error: %s", err.Error())
continue
}
newImageAddr := imageMapping.Image
switch imageMapping.ImageTagType {
case models.SystemDefaultTag:
publishApp, err := pm.modelPublish.GetPublishAppByPublishIDAndAppID(publishID, app.ProjectAppID)
if err != nil {
logs.Warn("when get publish app by publishid/appid occur error:%s, did not update app arrange image info", err.Error())
continue
}
imageTag, err := pm.getAppCodeCommitByBranch(app.ProjectAppID, publishApp.BranchName)
if err != nil {
logs.Warn("when get app code commit by branch error: %s, did not update app arrange image info", err.Error())
continue
}
originImageSplit := strings.Split(imageMapping.Image, ":")
imageStr := imageMapping.Image
if len(originImageSplit) == 2 {
imageStr = originImageSplit[0]
}
newImageAddr = fmt.Sprintf("%s:%s", imageStr, imageTag)
case models.LatestTag:
originImageSplit := strings.Split(imageMapping.Image, ":")
imageStr := imageMapping.Image
if len(originImageSplit) == 2 {
imageStr = originImageSplit[0]
}
newImageAddr = fmt.Sprintf("%s:%s", imageStr, "latest")
case models.OriginTag:
log.Log.Debug("image tag use from yaml, no need replace")
}
imageURL := newImageAddr
dockerfile := app.Dockerfile
if dockerfile == "" {
dockerfile = "Dockerfile"
......
......@@ -18,6 +18,7 @@ package publish
import (
"fmt"
"strings"
"github.com/go-atomci/atomci/internal/core/pipelinemgr"
"github.com/go-atomci/atomci/internal/middleware/log"
......@@ -314,15 +315,28 @@ func (pm *PublishManager) createPublishOperationLogItem(co *CreateOperationLogRe
func (pm *PublishManager) publishCreateParamVerify(req *PublishReq) error {
// name
if len(req.Name) > 64 {
return fmt.Errorf("版本名称过长,不允许超过64个字符")
return fmt.Errorf("流水线描述过长,不允许超过64个字符")
}
// VersionNo
if len(req.VersionNo) > 64 {
return fmt.Errorf("版本号不允许超过16个字符")
return fmt.Errorf("流水线名称不允许超过64个字符")
}
// App
if len(req.Apps) == 0 {
return fmt.Errorf("请至少勾选一个代码库后,重试")
}
errs := []string{}
for _, app := range req.Apps {
if app.BranchName == "" {
errs = []string{"请确认分支选择"}
}
_, err := pm.pipelineHandler.GetAppCodeCommitByBranch(app.AppID, app.BranchName)
if err != nil {
errs = append(errs, err.Error())
}
}
if len(errs) > 0 {
return fmt.Errorf("%v", strings.Join(errs, ","))
}
return nil
}
.text {
font: 16px/24px;
}
.clearfix:before,
.clearfix:after {
display: table;
content: "";
}
.clearfix:after {
clear: both
}
#nav .box-card {
color: #606266;
width: 23.7%;
height: 60px;
float: left;
margin-left: 1%;
margin-bottom: 1%;
box-shadow: 0 1px 10px 0 rgba(50, 50, 50, 0);
}
#nav {
text-align:center;
}
#nav span{
color: #13ce66
}
#bnav span{
color: #13ce66
}
#bnav {
text-align:center;
}
#bnav .box-card {
color: #606266;
width: 32%;
height: 60px;
float: left;
margin-left:1%;
box-shadow: 0 1px 10px 0 rgba(50, 50, 50, 0);
}
......@@ -74,6 +74,7 @@
.el-row{
text-align: left;
}
/* 更加突显的外发光效果 */
/* .el-button--default:focus, .el-button--default:hover,
......
......@@ -287,7 +287,6 @@
},
methods: {
tabClick(val) {
console.info(val.name);
this.activeName = val.name;
this.getList();
},
......
......@@ -28,6 +28,7 @@
:visible.sync="dialogFormVisible"
class="arrangement"
size="40%"
z-index="1100"
:before-close="handleClose"
>
<div class="arrange-body">
......
<template>
<el-dialog top='25vh' :close-on-click-modal="false" :visible.sync="dialogFormVisible" class="createDialog" :before-close="doCancelCreate">
<el-dialog top='25vh' z-index="1100" :close-on-click-modal="false" :visible.sync="dialogFormVisible" class="createDialog" :before-close="doCancelCreate">
<el-form ref="ruleForm" :model="form" :rules="rules">
<el-form-item :label="$t('bm.add.backStage')" prop="stage">
<el-select v-model="form.stage" :placeholder="$t('bm.add.select')" filterable>
......
......@@ -36,7 +36,7 @@
}
</style>
<template>
<el-dialog top='15vh' v-if="dialogFormVisible" :close-on-click-modal="false" :show-close="false" width='70%' :title="username"
<el-dialog top='15vh' z-index="1100" v-if="dialogFormVisible" :close-on-click-modal="false" :show-close="false" width='70%' :title="username"
:visible.sync="dialogFormVisible" class="commonDialog projectPubModuleList">
<div>
<i id="color" class="el-icon-close" @click="handleClose" style="cursor:pointer;position:absolute;right:15px;top:15px;"></i>
......@@ -67,7 +67,7 @@
<el-table-column prop="build_path" label="构建目录" sortable min-width="10%" :show-overflow-tooltip="true" />
<el-table-column :label="$t('bm.deployCenter.releaseBran')" min-width="15%">
<template slot-scope="scope">
<el-select v-model.trim="scope.row.branch_name" filterable :placeholder="$t('bm.add.selectSubmitBra')">
<el-select v-model.trim="scope.row.branch_name" filterable :placeholder="$t('bm.add.selectSubmitBra')" disabled>
<el-option v-for="(item, index) in scope.row.branch_history_list" :key="index" :label="item" :value="item">
</el-option>
</el-select>
......@@ -99,8 +99,6 @@
props: ['listData', 'pubType', 'cpData'],
data() {
return {
// 是否启用切换分支
enable_switch_branch: true,
username: '',
envStageID: '',
publishid: '',
......@@ -203,7 +201,6 @@
},
doShows(publishid, envStageID, step) {
this.selectList = [];
this.enable_switch_branch = true;
this.tableList = [];
this.cpList = [];
this.username = step;
......
<template>
<el-dialog top='15vh' v-if="dialogFormVisible" :close-on-click-modal="false" width='65%' :title="title"
<el-dialog z-index="1100" top='15vh' v-if="dialogFormVisible" :close-on-click-modal="false" width='65%' :title="title"
:visible.sync="dialogFormVisible" class="createDialog">
<el-table border :data="dataList" @select-all="handleSelectAll" @select='handleSelect' ref="appDeploy">
<el-table-column type="selection" width="50" disabled='true' :show-overflow-tooltip=true />
......
<template>
<el-dialog :close-on-click-modal="false" style="width:50%;margin-left:25%" top='25vh' :visible.sync="dialogFormVisible" class="createDialog" :before-close="doCancelCreate">
<el-dialog z-index="1100" :close-on-click-modal="false" style="width:50%;margin-left:25%" top='25vh' :visible.sync="dialogFormVisible" class="createDialog" :before-close="doCancelCreate">
<el-form>
<el-form-item :label="$t('bm.add.nextStage')">
<el-select v-model="stage" :placeholder="$t('bm.add.select')" @change="change" filterable style="padding-bottom:20px">
......
......@@ -17,7 +17,7 @@
}
</style>
<template>
<el-dialog top='15vh' v-if="dialogFormVisible" :close-on-click-modal="false" width='65%' :title="setname" :visible.sync="dialogFormVisible" class="createDialog">
<el-dialog z-index="1020" top='15vh' v-if="dialogFormVisible" :close-on-click-modal="false" width='65%' :title="setname" :visible.sync="dialogFormVisible" class="createDialog">
<el-form ref="ruleForm" :model="form" :rules="rules" label-width="52px">
<div>
<el-row>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册