snapshot of https://github.com/cortezaproject/corteza.git (2024.9.x, 2026-09-18; blobs > 131072B omitted)
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
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
This commit is contained in:
498
server/compose/automation/attachment_handler.gen.go
generated
Normal file
498
server/compose/automation/attachment_handler.gen.go
generated
Normal file
@@ -0,0 +1,498 @@
|
||||
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/attachment_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"
|
||||
"io"
|
||||
)
|
||||
|
||||
var _ wfexec.ExecResponse
|
||||
|
||||
type (
|
||||
attachmentHandlerRegistry interface {
|
||||
AddFunctions(ff ...*atypes.Function)
|
||||
Type(ref string) expr.Type
|
||||
}
|
||||
)
|
||||
|
||||
func (h attachmentHandler) register() {
|
||||
h.reg.AddFunctions(
|
||||
h.Lookup(),
|
||||
h.Create(),
|
||||
h.Delete(),
|
||||
h.OpenOriginal(),
|
||||
h.OpenPreview(),
|
||||
)
|
||||
}
|
||||
|
||||
type (
|
||||
attachmentLookupArgs struct {
|
||||
hasAttachment bool
|
||||
Attachment uint64
|
||||
}
|
||||
|
||||
attachmentLookupResults struct {
|
||||
Attachment *types.Attachment
|
||||
}
|
||||
)
|
||||
|
||||
// Lookup function Attachment lookup
|
||||
//
|
||||
// expects implementation of lookup function:
|
||||
//
|
||||
// func (h attachmentHandler) lookup(ctx context.Context, args *attachmentLookupArgs) (results *attachmentLookupResults, err error) {
|
||||
// return
|
||||
// }
|
||||
func (h attachmentHandler) Lookup() *atypes.Function {
|
||||
return &atypes.Function{
|
||||
Ref: "attachmentLookup",
|
||||
Kind: "function",
|
||||
Labels: map[string]string{"attachment": "step,workflow"},
|
||||
Meta: &atypes.FunctionMeta{
|
||||
Short: "Attachment lookup",
|
||||
Description: "Find specific attachment by ID",
|
||||
},
|
||||
|
||||
Parameters: []*atypes.Param{
|
||||
{
|
||||
Name: "attachment",
|
||||
Types: []string{"ID"}, Required: true,
|
||||
Meta: &atypes.ParamMeta{
|
||||
Label: "Attachment",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Results: []*atypes.Param{
|
||||
|
||||
{
|
||||
Name: "attachment",
|
||||
Types: []string{"Attachment"},
|
||||
},
|
||||
},
|
||||
|
||||
Handler: func(ctx context.Context, in *expr.Vars) (out *expr.Vars, err error) {
|
||||
var (
|
||||
args = &attachmentLookupArgs{
|
||||
hasAttachment: in.Has("attachment"),
|
||||
}
|
||||
)
|
||||
|
||||
if err = in.Decode(args); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
var results *attachmentLookupResults
|
||||
if results, err = h.lookup(ctx, args); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
out = &expr.Vars{}
|
||||
|
||||
{
|
||||
// converting results.Attachment (*types.Attachment) to Attachment
|
||||
var (
|
||||
tval expr.TypedValue
|
||||
)
|
||||
|
||||
if tval, err = h.reg.Type("Attachment").Cast(results.Attachment); err != nil {
|
||||
return
|
||||
} else if err = expr.Assign(out, "attachment", tval); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
type (
|
||||
attachmentCreateArgs struct {
|
||||
hasName bool
|
||||
Name string
|
||||
|
||||
hasResource bool
|
||||
Resource *types.Record
|
||||
|
||||
hasFieldName bool
|
||||
FieldName string
|
||||
|
||||
hasContent bool
|
||||
Content interface{}
|
||||
contentString string
|
||||
contentStream io.Reader
|
||||
contentBytes []byte
|
||||
}
|
||||
|
||||
attachmentCreateResults struct {
|
||||
Attachment *types.Attachment
|
||||
}
|
||||
)
|
||||
|
||||
func (a attachmentCreateArgs) GetContent() (bool, string, io.Reader, []byte) {
|
||||
return a.hasContent, a.contentString, a.contentStream, a.contentBytes
|
||||
}
|
||||
|
||||
// Create function Create file and attach it to a resource
|
||||
//
|
||||
// expects implementation of create function:
|
||||
//
|
||||
// func (h attachmentHandler) create(ctx context.Context, args *attachmentCreateArgs) (results *attachmentCreateResults, err error) {
|
||||
// return
|
||||
// }
|
||||
func (h attachmentHandler) Create() *atypes.Function {
|
||||
return &atypes.Function{
|
||||
Ref: "attachmentCreate",
|
||||
Kind: "function",
|
||||
Labels: map[string]string{"attachment": "step,workflow", "create": "step"},
|
||||
Meta: &atypes.FunctionMeta{
|
||||
Short: "Create file and attach it to a resource",
|
||||
},
|
||||
|
||||
Parameters: []*atypes.Param{
|
||||
{
|
||||
Name: "name",
|
||||
Types: []string{"String"},
|
||||
Meta: &atypes.ParamMeta{
|
||||
Label: "Name",
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "resource",
|
||||
Types: []string{"ComposeRecord"}, Required: true,
|
||||
Meta: &atypes.ParamMeta{
|
||||
Label: "Resource",
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "fieldName",
|
||||
Types: []string{"String"},
|
||||
Meta: &atypes.ParamMeta{
|
||||
Label: "Field name",
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "content",
|
||||
Types: []string{"String", "Reader", "Bytes"}, Required: true,
|
||||
Meta: &atypes.ParamMeta{
|
||||
Label: "Content",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Results: []*atypes.Param{
|
||||
|
||||
{
|
||||
Name: "attachment",
|
||||
Types: []string{"Attachment"},
|
||||
},
|
||||
},
|
||||
|
||||
Handler: func(ctx context.Context, in *expr.Vars) (out *expr.Vars, err error) {
|
||||
var (
|
||||
args = &attachmentCreateArgs{
|
||||
hasName: in.Has("name"),
|
||||
hasResource: in.Has("resource"),
|
||||
hasFieldName: in.Has("fieldName"),
|
||||
hasContent: in.Has("content"),
|
||||
}
|
||||
)
|
||||
|
||||
if err = in.Decode(args); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Converting Content argument
|
||||
if args.hasContent {
|
||||
aux := expr.Must(expr.Select(in, "content"))
|
||||
switch aux.Type() {
|
||||
case h.reg.Type("String").Type():
|
||||
args.contentString = aux.Get().(string)
|
||||
case h.reg.Type("Reader").Type():
|
||||
args.contentStream = aux.Get().(io.Reader)
|
||||
case h.reg.Type("Bytes").Type():
|
||||
args.contentBytes = aux.Get().([]byte)
|
||||
}
|
||||
}
|
||||
|
||||
var results *attachmentCreateResults
|
||||
if results, err = h.create(ctx, args); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
out = &expr.Vars{}
|
||||
|
||||
{
|
||||
// converting results.Attachment (*types.Attachment) to Attachment
|
||||
var (
|
||||
tval expr.TypedValue
|
||||
)
|
||||
|
||||
if tval, err = h.reg.Type("Attachment").Cast(results.Attachment); err != nil {
|
||||
return
|
||||
} else if err = expr.Assign(out, "attachment", tval); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
type (
|
||||
attachmentDeleteArgs struct {
|
||||
hasAttachment bool
|
||||
Attachment uint64
|
||||
}
|
||||
)
|
||||
|
||||
// Delete function Delete attachment
|
||||
//
|
||||
// expects implementation of delete function:
|
||||
//
|
||||
// func (h attachmentHandler) delete(ctx context.Context, args *attachmentDeleteArgs) (err error) {
|
||||
// return
|
||||
// }
|
||||
func (h attachmentHandler) Delete() *atypes.Function {
|
||||
return &atypes.Function{
|
||||
Ref: "attachmentDelete",
|
||||
Kind: "function",
|
||||
Labels: map[string]string{"attachment": "step,workflow", "delete": "step"},
|
||||
Meta: &atypes.FunctionMeta{
|
||||
Short: "Delete attachment",
|
||||
},
|
||||
|
||||
Parameters: []*atypes.Param{
|
||||
{
|
||||
Name: "attachment",
|
||||
Types: []string{"ID"}, Required: true,
|
||||
Meta: &atypes.ParamMeta{
|
||||
Label: "Attachment",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Handler: func(ctx context.Context, in *expr.Vars) (out *expr.Vars, err error) {
|
||||
var (
|
||||
args = &attachmentDeleteArgs{
|
||||
hasAttachment: in.Has("attachment"),
|
||||
}
|
||||
)
|
||||
|
||||
if err = in.Decode(args); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
return out, h.delete(ctx, args)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
type (
|
||||
attachmentOpenOriginalArgs struct {
|
||||
hasAttachment bool
|
||||
Attachment interface{}
|
||||
attachmentID uint64
|
||||
attachmentAttachment *types.Attachment
|
||||
}
|
||||
|
||||
attachmentOpenOriginalResults struct {
|
||||
Content io.Reader
|
||||
}
|
||||
)
|
||||
|
||||
func (a attachmentOpenOriginalArgs) GetAttachment() (bool, uint64, *types.Attachment) {
|
||||
return a.hasAttachment, a.attachmentID, a.attachmentAttachment
|
||||
}
|
||||
|
||||
// OpenOriginal function Open original attachment
|
||||
//
|
||||
// expects implementation of openOriginal function:
|
||||
//
|
||||
// func (h attachmentHandler) openOriginal(ctx context.Context, args *attachmentOpenOriginalArgs) (results *attachmentOpenOriginalResults, err error) {
|
||||
// return
|
||||
// }
|
||||
func (h attachmentHandler) OpenOriginal() *atypes.Function {
|
||||
return &atypes.Function{
|
||||
Ref: "attachmentOpenOriginal",
|
||||
Kind: "function",
|
||||
Labels: map[string]string{"attachment": "step,workflow", "original-attachment": "step"},
|
||||
Meta: &atypes.FunctionMeta{
|
||||
Short: "Open original attachment",
|
||||
},
|
||||
|
||||
Parameters: []*atypes.Param{
|
||||
{
|
||||
Name: "attachment",
|
||||
Types: []string{"ID", "Attachment"}, Required: true,
|
||||
Meta: &atypes.ParamMeta{
|
||||
Label: "Attachment",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Results: []*atypes.Param{
|
||||
|
||||
{
|
||||
Name: "content",
|
||||
Types: []string{"Reader"},
|
||||
},
|
||||
},
|
||||
|
||||
Handler: func(ctx context.Context, in *expr.Vars) (out *expr.Vars, err error) {
|
||||
var (
|
||||
args = &attachmentOpenOriginalArgs{
|
||||
hasAttachment: in.Has("attachment"),
|
||||
}
|
||||
)
|
||||
|
||||
if err = in.Decode(args); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Converting Attachment argument
|
||||
if args.hasAttachment {
|
||||
aux := expr.Must(expr.Select(in, "attachment"))
|
||||
switch aux.Type() {
|
||||
case h.reg.Type("ID").Type():
|
||||
args.attachmentID = aux.Get().(uint64)
|
||||
case h.reg.Type("Attachment").Type():
|
||||
args.attachmentAttachment = aux.Get().(*types.Attachment)
|
||||
}
|
||||
}
|
||||
|
||||
var results *attachmentOpenOriginalResults
|
||||
if results, err = h.openOriginal(ctx, args); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
out = &expr.Vars{}
|
||||
|
||||
{
|
||||
// converting results.Content (io.Reader) to Reader
|
||||
var (
|
||||
tval expr.TypedValue
|
||||
)
|
||||
|
||||
if tval, err = h.reg.Type("Reader").Cast(results.Content); err != nil {
|
||||
return
|
||||
} else if err = expr.Assign(out, "content", tval); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
type (
|
||||
attachmentOpenPreviewArgs struct {
|
||||
hasAttachment bool
|
||||
Attachment interface{}
|
||||
attachmentID uint64
|
||||
attachmentAttachment *types.Attachment
|
||||
}
|
||||
|
||||
attachmentOpenPreviewResults struct {
|
||||
Content io.Reader
|
||||
}
|
||||
)
|
||||
|
||||
func (a attachmentOpenPreviewArgs) GetAttachment() (bool, uint64, *types.Attachment) {
|
||||
return a.hasAttachment, a.attachmentID, a.attachmentAttachment
|
||||
}
|
||||
|
||||
// OpenPreview function Open attachment preview
|
||||
//
|
||||
// expects implementation of openPreview function:
|
||||
//
|
||||
// func (h attachmentHandler) openPreview(ctx context.Context, args *attachmentOpenPreviewArgs) (results *attachmentOpenPreviewResults, err error) {
|
||||
// return
|
||||
// }
|
||||
func (h attachmentHandler) OpenPreview() *atypes.Function {
|
||||
return &atypes.Function{
|
||||
Ref: "attachmentOpenPreview",
|
||||
Kind: "function",
|
||||
Labels: map[string]string{"attachment": "step,workflow", "preview-attachment": "step"},
|
||||
Meta: &atypes.FunctionMeta{
|
||||
Short: "Open attachment preview",
|
||||
},
|
||||
|
||||
Parameters: []*atypes.Param{
|
||||
{
|
||||
Name: "attachment",
|
||||
Types: []string{"ID", "Attachment"}, Required: true,
|
||||
Meta: &atypes.ParamMeta{
|
||||
Label: "Attachment",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Results: []*atypes.Param{
|
||||
|
||||
{
|
||||
Name: "content",
|
||||
Types: []string{"Reader"},
|
||||
},
|
||||
},
|
||||
|
||||
Handler: func(ctx context.Context, in *expr.Vars) (out *expr.Vars, err error) {
|
||||
var (
|
||||
args = &attachmentOpenPreviewArgs{
|
||||
hasAttachment: in.Has("attachment"),
|
||||
}
|
||||
)
|
||||
|
||||
if err = in.Decode(args); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Converting Attachment argument
|
||||
if args.hasAttachment {
|
||||
aux := expr.Must(expr.Select(in, "attachment"))
|
||||
switch aux.Type() {
|
||||
case h.reg.Type("ID").Type():
|
||||
args.attachmentID = aux.Get().(uint64)
|
||||
case h.reg.Type("Attachment").Type():
|
||||
args.attachmentAttachment = aux.Get().(*types.Attachment)
|
||||
}
|
||||
}
|
||||
|
||||
var results *attachmentOpenPreviewResults
|
||||
if results, err = h.openPreview(ctx, args); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
out = &expr.Vars{}
|
||||
|
||||
{
|
||||
// converting results.Content (io.Reader) to Reader
|
||||
var (
|
||||
tval expr.TypedValue
|
||||
)
|
||||
|
||||
if tval, err = h.reg.Type("Reader").Cast(results.Content); err != nil {
|
||||
return
|
||||
} else if err = expr.Assign(out, "content", tval); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user