Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type WorkflowV4 struct {
HookPayload *HookPayload `bson:"hook_payload" yaml:"-" json:"hook_payload,omitempty"`
BaseName string `bson:"base_name" yaml:"-" json:"base_name"`
Remark string `bson:"remark" yaml:"-" json:"remark"`
RemarkRequired bool `bson:"remark_required" yaml:"remark_required" json:"remark_required"`
IgnoreCache bool `bson:"ignore_cache,omitempty" yaml:"ignore_cache,omitempty" json:"ignore_cache,omitempty"`
ShareStorages []*ShareStorage `bson:"share_storages" yaml:"share_storages" json:"share_storages"`
Hash string `bson:"hash" yaml:"hash" json:"hash"`
Expand Down Expand Up @@ -548,13 +549,13 @@ type DeployHelmChart struct {
}

type DeployBasicInfo struct {
ServiceName string `bson:"service_name" yaml:"service_name" json:"service_name"`
ServiceName string `bson:"service_name" yaml:"service_name" json:"service_name"`
DeployStrategy setting.ServiceDeployStrategy `bson:"deploy_strategy" yaml:"deploy_strategy" json:"deploy_strategy"`
Modules []*DeployModuleInfo `bson:"modules" yaml:"modules" json:"modules"`
Deployed bool `bson:"deployed" yaml:"deployed" json:"deployed"`
AutoSync bool `bson:"-" yaml:"auto_sync" json:"auto_sync"`
UpdateConfig bool `bson:"update_config" yaml:"update_config" json:"update_config"`
Updatable bool `bson:"-" yaml:"updatable" json:"updatable"`
Modules []*DeployModuleInfo `bson:"modules" yaml:"modules" json:"modules"`
Deployed bool `bson:"deployed" yaml:"deployed" json:"deployed"`
AutoSync bool `bson:"-" yaml:"auto_sync" json:"auto_sync"`
UpdateConfig bool `bson:"update_config" yaml:"update_config" json:"update_config"`
Updatable bool `bson:"-" yaml:"updatable" json:"updatable"`
}

type DeployOptionInfo struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,11 @@ func CreateWorkflowTaskV4(c *gin.Context) {
}

ctx.Resp, ctx.RespErr = workflow.CreateWorkflowTaskV4(&workflow.CreateWorkflowTaskV4Args{
Name: ctx.UserName,
Account: ctx.Account,
UserID: ctx.UserID,
ApprovalTicketID: ticketID,
Name: ctx.UserName,
Account: ctx.Account,
UserID: ctx.UserID,
ApprovalTicketID: ticketID,
ValidateRemarkRequired: true,
}, args, ctx.Logger)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,10 @@ func (w *Workflow) Validate(isExecution bool) error {
if err != nil {
return e.ErrFindWorkflow.AddDesc(fmt.Sprintf("cannot find workflow [%s]'s latest setting, error: %s", w.Name, err))
}
w.RemarkRequired = latestWorkflowSettings.RemarkRequired
if latestWorkflowSettings.RemarkRequired && strings.TrimSpace(w.Remark) == "" {
return e.ErrLintWorkflow.AddDesc("workflow remark is required.")
}
}

for _, stage := range w.Stages {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type Workflow struct {
BaseName string `json:"base_name"`
BaseRefs []string `json:"base_refs"`
NeverRun bool `json:"never_run"`
RemarkRequired bool `json:"remark_required"`
EnableApprovalTicket bool `json:"enable_approval_ticket"`
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,19 +447,20 @@ func CheckWorkflowV4ApprovalInitiator(workflowName, uid string, log *zap.Sugared
}

type CreateWorkflowTaskV4Args struct {
Name string
Account string
UserID string
Type config.CustomWorkflowTaskType
ApprovalTicketID string
SkipWorkflowUpdate bool
NotifyInput []*CreateCustomTaskNotifyInput
LarkProjectKey string
LarkProjectSimpleName string
LarkWorkItemTypeKey string
LarkWorkItemAPIName string
LarkWorkItemID string
ReleasePlan *commonmodels.ReleasePlanRef
Name string
Account string
UserID string
Type config.CustomWorkflowTaskType
ValidateRemarkRequired bool
ApprovalTicketID string
SkipWorkflowUpdate bool
NotifyInput []*CreateCustomTaskNotifyInput
LarkProjectKey string
LarkProjectSimpleName string
LarkWorkItemTypeKey string
LarkWorkItemAPIName string
LarkWorkItemID string
ReleasePlan *commonmodels.ReleasePlanRef
}

func CreateWorkflowTaskV4ByBuildInTrigger(triggerName string, args *commonmodels.WorkflowV4, log *zap.SugaredLogger) (*CreateTaskV4Resp, error) {
Expand Down Expand Up @@ -511,9 +512,13 @@ func CreateWorkflowTaskV4(args *CreateWorkflowTaskV4Args, workflow *commonmodels
if err != nil {
return resp, e.ErrCreateTask.AddErr(fmt.Errorf("cannot find workflow %s, error: %v", workflow.Name, err))
}
workflow.RemarkRequired = originalWorkflow.RemarkRequired
if originalWorkflow.Disabled {
return resp, e.ErrCreateTask.AddDesc("workflow is disabled")
}
if args.ValidateRemarkRequired && originalWorkflow.RemarkRequired && strings.TrimSpace(workflow.Remark) == "" {
return resp, e.ErrCreateTask.AddDesc("workflow task creation denied: remark is required.")
}

// do approval ticket check
if originalWorkflow.EnableApprovalTicket {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ import (
commonservice "github.com/koderover/zadig/v2/pkg/microservice/aslan/core/common/service"
"github.com/koderover/zadig/v2/pkg/microservice/aslan/core/common/service/collaboration"
helmservice "github.com/koderover/zadig/v2/pkg/microservice/aslan/core/common/service/helm"
runtimeWorkflowController "github.com/koderover/zadig/v2/pkg/microservice/aslan/core/common/service/workflowcontroller"
"github.com/koderover/zadig/v2/pkg/microservice/aslan/core/common/service/kube"
larkservice "github.com/koderover/zadig/v2/pkg/microservice/aslan/core/common/service/lark"
"github.com/koderover/zadig/v2/pkg/microservice/aslan/core/common/service/s3"
commomtemplate "github.com/koderover/zadig/v2/pkg/microservice/aslan/core/common/service/template"
"github.com/koderover/zadig/v2/pkg/microservice/aslan/core/common/service/webhook"
runtimeWorkflowController "github.com/koderover/zadig/v2/pkg/microservice/aslan/core/common/service/workflowcontroller"
"github.com/koderover/zadig/v2/pkg/microservice/aslan/core/common/util"
commonutil "github.com/koderover/zadig/v2/pkg/microservice/aslan/core/common/util"
"github.com/koderover/zadig/v2/pkg/microservice/aslan/core/workflow/service/workflow/controller"
Expand Down Expand Up @@ -428,6 +428,7 @@ func ListWorkflowV4(projectName, viewName, userID string, names, v4Names []strin
Description: workflowModel.Description,
BaseRefs: baseRefs,
BaseName: workflowModel.BaseName,
RemarkRequired: workflowModel.RemarkRequired,
EnableApprovalTicket: workflowModel.EnableApprovalTicket,
}
if workflowModel.Category == setting.ReleaseWorkflow {
Expand Down Expand Up @@ -582,6 +583,7 @@ func ListWorkflowV4InGlobal(ctx *internalhandler.Context, query *ListGlobalWorkf
WorkflowType: setting.CustomWorkflowType,
Description: workflowModel.Description,
BaseName: workflowModel.BaseName,
RemarkRequired: workflowModel.RemarkRequired,
EnableApprovalTicket: workflowModel.EnableApprovalTicket,
}

Expand Down
Loading