3
0

Add support for labels on automation functions

Idea for these labels is to give instructions which labels to copy
on step and on workflow when function step is added to the graph.

Labels are defined with "step,workflow", "workflow" or "step" for value.
UI should follow these instructions when copying labels to workflow
and/or step.
This commit is contained in:
Denis Arh
2021-02-12 07:20:16 +01:00
parent a0ecf0537f
commit cfe02be081
20 changed files with 208 additions and 75 deletions
@@ -98,8 +98,9 @@ func (a httpRequestSendArgs) GetBody() (bool, string, io.Reader, interface{}) {
// }
func (h httpRequestHandler) Send() *atypes.Function {
return &atypes.Function{
Ref: "httpRequestSend",
Kind: "function",
Ref: "httpRequestSend",
Kind: "function",
Labels: map[string]string{"http request": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Sends HTTP request",
},
@@ -67,10 +67,13 @@ results:
body: &rBody
wf: Reader
functions:
send:
meta:
short: Sends HTTP request
labels:
"http request": "step,workflow"
params:
url: *url
method: *method
+12 -8
View File
@@ -51,8 +51,9 @@ type (
// }
func (h logHandler) Debug() *atypes.Function {
return &atypes.Function{
Ref: "logDebug",
Kind: "function",
Ref: "logDebug",
Kind: "function",
Labels: map[string]string{"debug": "step", "logger": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Writes debug log message",
},
@@ -103,8 +104,9 @@ type (
// }
func (h logHandler) Info() *atypes.Function {
return &atypes.Function{
Ref: "logInfo",
Kind: "function",
Ref: "logInfo",
Kind: "function",
Labels: map[string]string{"debug": "step", "logger": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Writes info log message",
},
@@ -155,8 +157,9 @@ type (
// }
func (h logHandler) Warn() *atypes.Function {
return &atypes.Function{
Ref: "logWarn",
Kind: "function",
Ref: "logWarn",
Kind: "function",
Labels: map[string]string{"debug": "step", "logger": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Writes warn log message",
},
@@ -207,8 +210,9 @@ type (
// }
func (h logHandler) Error() *atypes.Function {
return &atypes.Function{
Ref: "logError",
Kind: "function",
Ref: "logError",
Kind: "function",
Labels: map[string]string{"debug": "step", "logger": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Writes error log message",
},
+7
View File
@@ -7,11 +7,15 @@ params:
types:
- { wf: KV }
labels: &labels
debug: "step"
logger: "step,workflow"
functions:
debug:
meta:
short: Writes debug log message
labels: *labels
params:
message: *message
fields: *fields
@@ -19,6 +23,7 @@ functions:
info:
meta:
short: Writes info log message
labels: *labels
params:
message: *message
fields: *fields
@@ -26,6 +31,7 @@ functions:
warn:
meta:
short: Writes warn log message
labels: *labels
params:
message: *message
fields: *fields
@@ -33,6 +39,7 @@ functions:
error:
meta:
short: Writes error log message
labels: *labels
params:
message: *message
fields: *fields
+12 -8
View File
@@ -61,8 +61,9 @@ type (
// }
func (h loopHandler) Sequence() *atypes.Function {
return &atypes.Function{
Ref: "loopSequence",
Kind: "iterator",
Ref: "loopSequence",
Kind: "iterator",
Labels: map[string]string(nil),
Meta: &atypes.FunctionMeta{
Short: "Iterates over sequence of numbers",
},
@@ -133,8 +134,9 @@ type (
// }
func (h loopHandler) Do() *atypes.Function {
return &atypes.Function{
Ref: "loopDo",
Kind: "iterator",
Ref: "loopDo",
Kind: "iterator",
Labels: map[string]string(nil),
Meta: &atypes.FunctionMeta{
Short: "Iterates while condition is true",
},
@@ -185,8 +187,9 @@ type (
// }
func (h loopHandler) Each() *atypes.Function {
return &atypes.Function{
Ref: "loopEach",
Kind: "iterator",
Ref: "loopEach",
Kind: "iterator",
Labels: map[string]string(nil),
Meta: &atypes.FunctionMeta{
Short: "Iterates over set of items",
},
@@ -241,8 +244,9 @@ type (
// }
func (h loopHandler) Lines() *atypes.Function {
return &atypes.Function{
Ref: "loopLines",
Kind: "iterator",
Ref: "loopLines",
Kind: "iterator",
Labels: map[string]string(nil),
Meta: &atypes.FunctionMeta{
Short: "Iterates over lines from stream",
},
-1
View File
@@ -3,7 +3,6 @@ name: loop
imports:
- io
functions:
sequence:
kind: iterator
+2
View File
@@ -24,6 +24,8 @@ type (
Handler FunctionHandler `json:"-"`
Iterator IteratorHandler `json:"-"`
Labels map[string]string `json:"labels,omitempty"`
}
FunctionMeta struct {
+2
View File
@@ -95,6 +95,8 @@ type (
Results []*Expr `json:"results"`
Meta WorkflowStepMeta `json:"meta,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
}
WorkflowStepMeta struct {
+3 -2
View File
@@ -67,8 +67,9 @@ func (a modulesLookupArgs) GetNamespace() (bool, uint64, string, *types.Namespac
// }
func (h modulesHandler) Lookup() *atypes.Function {
return &atypes.Function{
Ref: "composeModulesLookup",
Kind: "function",
Ref: "composeModulesLookup",
Kind: "function",
Labels: map[string]string{"compose": "step,workflow", "lookup": "step", "module": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Lookup for compose Lookup by ID",
},
+4
View File
@@ -28,5 +28,9 @@ functions:
params:
module: *moduleLookup
namespace: *namespaceLookup
labels:
lookup: "step"
module: "step,workflow"
compose: "step,workflow"
results:
module: *rvModule
+3 -2
View File
@@ -57,8 +57,9 @@ func (a namespacesLookupArgs) GetNamespace() (bool, uint64, string, *types.Names
// }
func (h namespacesHandler) Lookup() *atypes.Function {
return &atypes.Function{
Ref: "composeNamespacesLookup",
Kind: "function",
Ref: "composeNamespacesLookup",
Kind: "function",
Labels: map[string]string{"compose": "step,workflow", "lookup": "step", "namespace": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Lookup for compose namespace by ID",
},
@@ -18,6 +18,10 @@ functions:
lookup:
meta:
short: Lookup for compose namespace by ID
labels:
lookup: "step"
namespace: "step,workflow"
compose: "step,workflow"
params:
namespace: *namespaceLookup
results:
+24 -16
View File
@@ -83,8 +83,9 @@ func (a recordsLookupArgs) GetRecord() (bool, uint64, *types.Record) {
// }
func (h recordsHandler) Lookup() *atypes.Function {
return &atypes.Function{
Ref: "composeRecordsLookup",
Kind: "function",
Ref: "composeRecordsLookup",
Kind: "function",
Labels: map[string]string{"compose": "step,workflow", "record": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Lookup for compose record by ID",
},
@@ -253,8 +254,9 @@ func (a recordsSearchArgs) GetNamespace() (bool, uint64, string, *types.Namespac
// }
func (h recordsHandler) Search() *atypes.Function {
return &atypes.Function{
Ref: "composeRecordsSearch",
Kind: "function",
Ref: "composeRecordsSearch",
Kind: "function",
Labels: map[string]string{"compose": "step,workflow", "record": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Searches for records and returns them",
},
@@ -495,8 +497,9 @@ func (a recordsEachArgs) GetNamespace() (bool, uint64, string, *types.Namespace)
// }
func (h recordsHandler) Each() *atypes.Function {
return &atypes.Function{
Ref: "composeRecordsEach",
Kind: "iterator",
Ref: "composeRecordsEach",
Kind: "iterator",
Labels: map[string]string{"compose": "step,workflow", "record": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Searches for records and iterates over results",
},
@@ -661,8 +664,9 @@ func (a recordsNewArgs) GetNamespace() (bool, uint64, string, *types.Namespace)
// }
func (h recordsHandler) New() *atypes.Function {
return &atypes.Function{
Ref: "composeRecordsNew",
Kind: "function",
Ref: "composeRecordsNew",
Kind: "function",
Labels: map[string]string{"compose": "step,workflow", "record": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Make a new record",
},
@@ -772,8 +776,9 @@ type (
// }
func (h recordsHandler) Validate() *atypes.Function {
return &atypes.Function{
Ref: "composeRecordsValidate",
Kind: "function",
Ref: "composeRecordsValidate",
Kind: "function",
Labels: map[string]string{"compose": "step,workflow", "record": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Validate record",
},
@@ -851,8 +856,9 @@ type (
// }
func (h recordsHandler) Create() *atypes.Function {
return &atypes.Function{
Ref: "composeRecordsCreate",
Kind: "function",
Ref: "composeRecordsCreate",
Kind: "function",
Labels: map[string]string{"compose": "step,workflow", "create": "step", "record": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Creates and stores a new record",
},
@@ -927,8 +933,9 @@ type (
// }
func (h recordsHandler) Update() *atypes.Function {
return &atypes.Function{
Ref: "composeRecordsUpdate",
Kind: "function",
Ref: "composeRecordsUpdate",
Kind: "function",
Labels: map[string]string{"compose": "step,workflow", "record": "step,workflow", "update": "step"},
Meta: &atypes.FunctionMeta{
Short: "Updates an existing record",
},
@@ -1005,8 +1012,9 @@ func (a recordsDeleteArgs) GetRecord() (bool, uint64, *types.Record) {
// }
func (h recordsHandler) Delete() *atypes.Function {
return &atypes.Function{
Ref: "composeRecordsDelete",
Kind: "function",
Ref: "composeRecordsDelete",
Kind: "function",
Labels: map[string]string{"compose": "step,workflow", "delete": "step", "record": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Soft deletes compose record by ID",
},
+23
View File
@@ -85,10 +85,16 @@ params:
types:
- { wf: String }
labels: &labels
record: "step,workflow"
compose: "step,workflow"
functions:
lookup:
meta:
short: Lookup for compose record by ID
labels:
<<: *labels
params:
module: *moduleLookup
namespace: *namespaceLookup
@@ -99,6 +105,8 @@ functions:
search:
meta:
short: Searches for records and returns them
labels:
<<: *labels
params: *filterParams
results:
records:
@@ -111,6 +119,8 @@ functions:
kind: iterator
meta:
short: Searches for records and iterates over results
labels:
<<: *labels
params: *filterParams
results:
record: *rvRecord
@@ -120,6 +130,8 @@ functions:
new:
meta:
short: Make a new record
labels:
<<: *labels
params:
module: *moduleLookup
namespace: *namespaceLookup
@@ -129,6 +141,8 @@ functions:
validate:
meta:
short: Validate record
labels:
<<: *labels
params:
record: *record
results:
@@ -140,6 +154,9 @@ functions:
create:
meta:
short: Creates and stores a new record
labels:
<<: *labels
create: "step"
params:
record:
<<: *record
@@ -150,6 +167,9 @@ functions:
update:
meta:
short: Updates an existing record
labels:
<<: *labels
update: "step"
params:
record:
<<: *record
@@ -160,6 +180,9 @@ functions:
delete:
meta:
short: Soft deletes compose record by ID
labels:
<<: *labels
delete: "step"
params:
record: *recordLookup
+1
View File
@@ -32,6 +32,7 @@ type (
aFuncDef struct {
Name string
Kind string
Labels map[string]string
Meta *aFuncMetaDef
Params aFuncParamSet
Results aFuncResultSet
+1
View File
@@ -92,6 +92,7 @@ func (h {{ $.Name }}Handler) {{ export .Name }}() *atypes.Function {
return &atypes.Function{
Ref: {{ printf "%q" ( $REF ) }},
Kind: {{ printf "%q" .Kind }},
Labels: {{ printf "%#v" .Labels }},
{{- if .Meta }}
Meta: &atypes.FunctionMeta{
{{- if .Meta.Short }}
+27 -18
View File
@@ -65,8 +65,9 @@ func (a rolesLookupArgs) GetLookup() (bool, uint64, string, *types.Role) {
// }
func (h rolesHandler) Lookup() *atypes.Function {
return &atypes.Function{
Ref: "rolesLookup",
Kind: "function",
Ref: "rolesLookup",
Kind: "function",
Labels: map[string]string{"users": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Looks-up for role by ID",
},
@@ -189,8 +190,9 @@ type (
// }
func (h rolesHandler) Search() *atypes.Function {
return &atypes.Function{
Ref: "rolesSearch",
Kind: "function",
Ref: "rolesSearch",
Kind: "function",
Labels: map[string]string{"users": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Searches for roles and returns them",
},
@@ -398,8 +400,9 @@ type (
// }
func (h rolesHandler) Each() *atypes.Function {
return &atypes.Function{
Ref: "rolesEach",
Kind: "iterator",
Ref: "rolesEach",
Kind: "iterator",
Labels: map[string]string(nil),
Meta: &atypes.FunctionMeta{
Short: "Searches for roles and iterates over results",
},
@@ -514,8 +517,9 @@ type (
// }
func (h rolesHandler) Create() *atypes.Function {
return &atypes.Function{
Ref: "rolesCreate",
Kind: "function",
Ref: "rolesCreate",
Kind: "function",
Labels: map[string]string{"create": "step", "users": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Creates new role",
},
@@ -590,8 +594,9 @@ type (
// }
func (h rolesHandler) Update() *atypes.Function {
return &atypes.Function{
Ref: "rolesUpdate",
Kind: "function",
Ref: "rolesUpdate",
Kind: "function",
Labels: map[string]string{"update": "step", "users": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Updates exiting role",
},
@@ -669,8 +674,9 @@ func (a rolesDeleteArgs) GetLookup() (bool, uint64, string, *types.Role) {
// }
func (h rolesHandler) Delete() *atypes.Function {
return &atypes.Function{
Ref: "rolesDelete",
Kind: "function",
Ref: "rolesDelete",
Kind: "function",
Labels: map[string]string{"delete": "step", "users": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Deletes the role",
},
@@ -733,8 +739,9 @@ func (a rolesRecoverArgs) GetLookup() (bool, uint64, string, *types.Role) {
// }
func (h rolesHandler) Recover() *atypes.Function {
return &atypes.Function{
Ref: "rolesRecover",
Kind: "function",
Ref: "rolesRecover",
Kind: "function",
Labels: map[string]string{"recover": "step", "users": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Recovers deleted role",
},
@@ -797,8 +804,9 @@ func (a rolesArchiveArgs) GetLookup() (bool, uint64, string, *types.Role) {
// }
func (h rolesHandler) Archive() *atypes.Function {
return &atypes.Function{
Ref: "rolesArchive",
Kind: "function",
Ref: "rolesArchive",
Kind: "function",
Labels: map[string]string{"archive": "step", "users": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Archives the role",
},
@@ -861,8 +869,9 @@ func (a rolesUnarchiveArgs) GetLookup() (bool, uint64, string, *types.Role) {
// }
func (h rolesHandler) Unarchive() *atypes.Function {
return &atypes.Function{
Ref: "rolesUnarchive",
Kind: "function",
Ref: "rolesUnarchive",
Kind: "function",
Labels: map[string]string{"unarchive": "step", "users": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Unarchives the role",
},
+25
View File
@@ -61,10 +61,15 @@ params:
types:
- { wf: String }
labels: &labels
users: "step,workflow"
functions:
lookup:
meta:
short: Looks-up for role by ID
labels:
<<: *labels
params:
lookup: *lookup
results:
@@ -73,6 +78,8 @@ functions:
search:
meta:
short: Searches for roles and returns them
labels:
<<: *labels
params: *filterParams
results:
roles:
@@ -93,6 +100,9 @@ functions:
create:
meta:
short: Creates new role
labels:
<<: *labels
create: "step"
params:
role:
<<: *role
@@ -103,6 +113,9 @@ functions:
update:
meta:
short: Updates exiting role
labels:
<<: *labels
update: "step"
params:
role:
<<: *role
@@ -113,23 +126,35 @@ functions:
delete:
meta:
short: Deletes the role
labels:
<<: *labels
delete: "step"
params:
lookup: *lookup
recover:
meta:
short: Recovers deleted role
labels:
<<: *labels
recover: "step"
params:
lookup: *lookup
archive:
meta:
short: Archives the role
labels:
<<: *labels
archive: "step"
params:
lookup: *lookup
unarchive:
meta:
short: Unarchives the role
labels:
<<: *labels
unarchive: "step"
params:
lookup: *lookup
+27 -18
View File
@@ -66,8 +66,9 @@ func (a usersLookupArgs) GetLookup() (bool, uint64, string, string, *types.User)
// }
func (h usersHandler) Lookup() *atypes.Function {
return &atypes.Function{
Ref: "usersLookup",
Kind: "function",
Ref: "usersLookup",
Kind: "function",
Labels: map[string]string{"users": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Looks-up for user by ID",
},
@@ -189,8 +190,9 @@ type (
// }
func (h usersHandler) Search() *atypes.Function {
return &atypes.Function{
Ref: "usersSearch",
Kind: "function",
Ref: "usersSearch",
Kind: "function",
Labels: map[string]string{"users": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Searches for users and returns them",
},
@@ -390,8 +392,9 @@ type (
// }
func (h usersHandler) Each() *atypes.Function {
return &atypes.Function{
Ref: "usersEach",
Kind: "iterator",
Ref: "usersEach",
Kind: "iterator",
Labels: map[string]string{"users": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Searches for users and iterates over results",
},
@@ -501,8 +504,9 @@ type (
// }
func (h usersHandler) Create() *atypes.Function {
return &atypes.Function{
Ref: "usersCreate",
Kind: "function",
Ref: "usersCreate",
Kind: "function",
Labels: map[string]string{"users": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Creates new user",
},
@@ -577,8 +581,9 @@ type (
// }
func (h usersHandler) Update() *atypes.Function {
return &atypes.Function{
Ref: "usersUpdate",
Kind: "function",
Ref: "usersUpdate",
Kind: "function",
Labels: map[string]string{"users": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Updates exiting user",
},
@@ -657,8 +662,9 @@ func (a usersDeleteArgs) GetLookup() (bool, uint64, string, string, *types.User)
// }
func (h usersHandler) Delete() *atypes.Function {
return &atypes.Function{
Ref: "usersDelete",
Kind: "function",
Ref: "usersDelete",
Kind: "function",
Labels: map[string]string{"delete": "step", "users": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Deletes user",
},
@@ -724,8 +730,9 @@ func (a usersRecoverArgs) GetLookup() (bool, uint64, string, string, *types.User
// }
func (h usersHandler) Recover() *atypes.Function {
return &atypes.Function{
Ref: "usersRecover",
Kind: "function",
Ref: "usersRecover",
Kind: "function",
Labels: map[string]string{"recover": "step", "users": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Recovers deleted user",
},
@@ -791,8 +798,9 @@ func (a usersSuspendArgs) GetLookup() (bool, uint64, string, string, *types.User
// }
func (h usersHandler) Suspend() *atypes.Function {
return &atypes.Function{
Ref: "usersSuspend",
Kind: "function",
Ref: "usersSuspend",
Kind: "function",
Labels: map[string]string{"suspend": "step", "users": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Suspends user",
},
@@ -858,8 +866,9 @@ func (a usersUnsuspendArgs) GetLookup() (bool, uint64, string, string, *types.Us
// }
func (h usersHandler) Unsuspend() *atypes.Function {
return &atypes.Function{
Ref: "usersUnsuspend",
Kind: "function",
Ref: "usersUnsuspend",
Kind: "function",
Labels: map[string]string{"unsuspend": "step", "users": "step,workflow"},
Meta: &atypes.FunctionMeta{
Short: "Unsuspends user",
},
+25
View File
@@ -58,12 +58,17 @@ snippets:
types:
- { wf: String }
labels: &labels
users: "step,workflow"
functions:
lookup:
meta:
short: Looks-up for user by ID
params:
lookup: *lookup
labels:
<<: *labels
results:
user: *rvUser
@@ -71,6 +76,8 @@ functions:
meta:
short: Searches for users and returns them
params: *filterParams
labels:
<<: *labels
results:
users:
<<: *rvUser
@@ -83,6 +90,8 @@ functions:
meta:
short: Searches for users and iterates over results
params: *filterParams
labels:
<<: *labels
results:
user: *rvUser
total: *rvTotal
@@ -90,6 +99,8 @@ functions:
create:
meta:
short: Creates new user
labels:
<<: *labels
params:
user:
<<: *user
@@ -100,6 +111,8 @@ functions:
update:
meta:
short: Updates exiting user
labels:
<<: *labels
params:
user:
<<: *user
@@ -108,24 +121,36 @@ functions:
user: *rvUser
delete:
labels:
<<: *labels
delete: "step"
meta:
short: Deletes user
params:
lookup: *lookup
recover:
labels:
<<: *labels
recover: "step"
meta:
short: Recovers deleted user
params:
lookup: *lookup
suspend:
labels:
<<: *labels
suspend: "step"
meta:
short: Suspends user
params:
lookup: *lookup
unsuspend:
labels:
<<: *labels
unsuspend: "step"
meta:
short: Unsuspends user
params: