Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s
166 lines
3.9 KiB
Go
Generated
166 lines
3.9 KiB
Go
Generated
package automation
|
|
|
|
// This file is auto-generated.
|
|
//
|
|
// Changes to this file may cause incorrect behavior and will be lost if
|
|
// the code is regenerated.
|
|
//
|
|
// Definitions file that controls how this file is generated:
|
|
// compose/automation/modules_handler.yaml
|
|
|
|
import (
|
|
"context"
|
|
atypes "github.com/cortezaproject/corteza/server/automation/types"
|
|
"github.com/cortezaproject/corteza/server/compose/types"
|
|
"github.com/cortezaproject/corteza/server/pkg/expr"
|
|
"github.com/cortezaproject/corteza/server/pkg/wfexec"
|
|
)
|
|
|
|
var _ wfexec.ExecResponse
|
|
|
|
type (
|
|
modulesHandlerRegistry interface {
|
|
AddFunctions(ff ...*atypes.Function)
|
|
Type(ref string) expr.Type
|
|
}
|
|
)
|
|
|
|
func (h modulesHandler) register() {
|
|
h.reg.AddFunctions(
|
|
h.Lookup(),
|
|
)
|
|
}
|
|
|
|
type (
|
|
modulesLookupArgs struct {
|
|
hasModule bool
|
|
Module interface{}
|
|
moduleID uint64
|
|
moduleHandle string
|
|
moduleRes *types.Module
|
|
|
|
hasNamespace bool
|
|
Namespace interface{}
|
|
namespaceID uint64
|
|
namespaceHandle string
|
|
namespaceRes *types.Namespace
|
|
}
|
|
|
|
modulesLookupResults struct {
|
|
Module *types.Module
|
|
}
|
|
)
|
|
|
|
func (a modulesLookupArgs) GetModule() (bool, uint64, string, *types.Module) {
|
|
return a.hasModule, a.moduleID, a.moduleHandle, a.moduleRes
|
|
}
|
|
|
|
func (a modulesLookupArgs) GetNamespace() (bool, uint64, string, *types.Namespace) {
|
|
return a.hasNamespace, a.namespaceID, a.namespaceHandle, a.namespaceRes
|
|
}
|
|
|
|
// Lookup function Compose module lookup
|
|
//
|
|
// expects implementation of lookup function:
|
|
//
|
|
// func (h modulesHandler) lookup(ctx context.Context, args *modulesLookupArgs) (results *modulesLookupResults, err error) {
|
|
// return
|
|
// }
|
|
func (h modulesHandler) Lookup() *atypes.Function {
|
|
return &atypes.Function{
|
|
Ref: "composeModulesLookup",
|
|
Kind: "function",
|
|
Labels: map[string]string{"compose": "step,workflow", "lookup": "step", "module": "step,workflow"},
|
|
Meta: &atypes.FunctionMeta{
|
|
Short: "Compose module lookup",
|
|
Description: "Find specific module by ID or handle",
|
|
},
|
|
|
|
Parameters: []*atypes.Param{
|
|
{
|
|
Name: "module",
|
|
Types: []string{"ID", "Handle", "ComposeModule"}, Required: true,
|
|
Meta: &atypes.ParamMeta{
|
|
Label: "Module",
|
|
},
|
|
},
|
|
{
|
|
Name: "namespace",
|
|
Types: []string{"ID", "Handle", "ComposeNamespace"}, Required: true,
|
|
Meta: &atypes.ParamMeta{
|
|
Label: "Namespace",
|
|
},
|
|
},
|
|
},
|
|
|
|
Results: []*atypes.Param{
|
|
|
|
{
|
|
Name: "module",
|
|
Types: []string{"ComposeModule"},
|
|
},
|
|
},
|
|
|
|
Handler: func(ctx context.Context, in *expr.Vars) (out *expr.Vars, err error) {
|
|
var (
|
|
args = &modulesLookupArgs{
|
|
hasModule: in.Has("module"),
|
|
hasNamespace: in.Has("namespace"),
|
|
}
|
|
)
|
|
|
|
if err = in.Decode(args); err != nil {
|
|
return
|
|
}
|
|
|
|
// Converting Module argument
|
|
if args.hasModule {
|
|
aux := expr.Must(expr.Select(in, "module"))
|
|
switch aux.Type() {
|
|
case h.reg.Type("ID").Type():
|
|
args.moduleID = aux.Get().(uint64)
|
|
case h.reg.Type("Handle").Type():
|
|
args.moduleHandle = aux.Get().(string)
|
|
case h.reg.Type("ComposeModule").Type():
|
|
args.moduleRes = aux.Get().(*types.Module)
|
|
}
|
|
}
|
|
|
|
// Converting Namespace argument
|
|
if args.hasNamespace {
|
|
aux := expr.Must(expr.Select(in, "namespace"))
|
|
switch aux.Type() {
|
|
case h.reg.Type("ID").Type():
|
|
args.namespaceID = aux.Get().(uint64)
|
|
case h.reg.Type("Handle").Type():
|
|
args.namespaceHandle = aux.Get().(string)
|
|
case h.reg.Type("ComposeNamespace").Type():
|
|
args.namespaceRes = aux.Get().(*types.Namespace)
|
|
}
|
|
}
|
|
|
|
var results *modulesLookupResults
|
|
if results, err = h.lookup(ctx, args); err != nil {
|
|
return
|
|
}
|
|
|
|
out = &expr.Vars{}
|
|
|
|
{
|
|
// converting results.Module (*types.Module) to ComposeModule
|
|
var (
|
|
tval expr.TypedValue
|
|
)
|
|
|
|
if tval, err = h.reg.Type("ComposeModule").Cast(results.Module); err != nil {
|
|
return
|
|
} else if err = expr.Assign(out, "module", tval); err != nil {
|
|
return
|
|
}
|
|
}
|
|
|
|
return
|
|
},
|
|
}
|
|
}
|