Prevent wf exec if wf/trigger are disabled (when not tracing)
This commit is contained in:
@@ -506,6 +506,10 @@ func (svc *workflow) Exec(ctx context.Context, workflowID uint64, p types.Workfl
|
||||
return WorkflowErrNotAllowedToExecute()
|
||||
}
|
||||
|
||||
if !wf.Enabled && !p.Trace {
|
||||
return WorkflowErrDisabled()
|
||||
}
|
||||
|
||||
g, convErr := Convert(svc, wf)
|
||||
if len(convErr) > 0 {
|
||||
return convErr
|
||||
@@ -532,6 +536,10 @@ func (svc *workflow) Exec(ctx context.Context, workflowID uint64, p types.Workfl
|
||||
return nil, nil
|
||||
}()
|
||||
|
||||
if !t.Enabled && !p.Trace {
|
||||
return WorkflowErrDisabled()
|
||||
}
|
||||
|
||||
// Start with workflow scope
|
||||
scope := wf.Scope.Merge()
|
||||
|
||||
|
||||
@@ -504,6 +504,36 @@ func WorkflowErrInvalidID(mm ...*workflowActionProps) *errors.Error {
|
||||
return e
|
||||
}
|
||||
|
||||
// WorkflowErrDisabled returns "automation:workflow.disabled" as *errors.Error
|
||||
//
|
||||
//
|
||||
// This function is auto-generated.
|
||||
//
|
||||
func WorkflowErrDisabled(mm ...*workflowActionProps) *errors.Error {
|
||||
var p = &workflowActionProps{}
|
||||
if len(mm) > 0 {
|
||||
p = mm[0]
|
||||
}
|
||||
|
||||
var e = errors.New(
|
||||
errors.KindInternal,
|
||||
|
||||
p.Format("disabled workflow or trigger", nil),
|
||||
|
||||
errors.Meta("type", "disabled"),
|
||||
errors.Meta("resource", "automation:workflow"),
|
||||
|
||||
errors.Meta(workflowPropsMetaKey{}, p),
|
||||
|
||||
errors.StackSkip(1),
|
||||
)
|
||||
|
||||
if len(mm) > 0 {
|
||||
}
|
||||
|
||||
return e
|
||||
}
|
||||
|
||||
// WorkflowErrInvalidHandle returns "automation:workflow.invalidHandle" as *errors.Error
|
||||
//
|
||||
//
|
||||
|
||||
@@ -62,6 +62,9 @@ errors:
|
||||
- error: invalidID
|
||||
message: "invalid ID"
|
||||
|
||||
- error: disabled
|
||||
message: "disabled workflow or trigger"
|
||||
|
||||
- error: invalidHandle
|
||||
message: "invalid handle"
|
||||
|
||||
|
||||
@@ -553,10 +553,6 @@ func (t *UnsignedInteger) Assign(val interface{}) error {
|
||||
// Vars is an expression type, wrapper for map[string]TypedValue type
|
||||
type Vars struct{ value map[string]TypedValue }
|
||||
|
||||
func EmptyVars() *Vars {
|
||||
return &Vars{make(map[string]TypedValue)}
|
||||
}
|
||||
|
||||
// NewVars creates new instance of Vars expression type
|
||||
func NewVars(val interface{}) (*Vars, error) {
|
||||
if c, err := CastToVars(val); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user