Skip to content

Commit

Permalink
feat(templates): impl Template.hasMultipleProtocols check
Browse files Browse the repository at this point in the history
Signed-off-by: Dwi Siswanto <[email protected]>
  • Loading branch information
dwisiswant0 committed Oct 21, 2024
1 parent ec4a77e commit e945ac1
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pkg/templates/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ func (template *Template) parseSelfContainedRequests() {
for _, request := range template.RequestsHeadless {
request.SelfContained = true
}
for _, request := range template.RequestsCode {
request.SelfContained = true
}
}

// Requests returns the total request count for the template
Expand Down Expand Up @@ -178,11 +181,12 @@ func (template *Template) compileProtocolRequests(options *protocols.ExecutorOpt

var requests []protocols.Request

if template.hasMultipleRequests() {
// when multiple requests are present preserve the order of requests and protocols
// which is already done during unmarshalling
// when multiple requests or protocols are present, preserve the
// order of requests and protocols which already done during the
// unmarshalling process or else.
if template.hasMultipleRequests() || template.hasMultipleProtocols() {
requests = template.RequestsQueue
if options.Flow == "" {
if template.hasMultipleProtocols() && options.Flow == "" {
options.IsMultiProtocol = true
}
} else {
Expand Down Expand Up @@ -430,6 +434,8 @@ func parseTemplate(data []byte, options protocols.ExecutorOptions) (*Template, e
return nil, err
}

template.parseSelfContainedRequests()

if template.Executer != nil {
if err := template.Executer.Compile(); err != nil {
return nil, errors.Wrap(err, "could not compile request")
Expand All @@ -439,7 +445,6 @@ func parseTemplate(data []byte, options protocols.ExecutorOptions) (*Template, e
if template.Executer == nil && template.CompiledWorkflow == nil {
return nil, ErrCreateTemplateExecutor
}
template.parseSelfContainedRequests()

// check if the template is verified
// only valid templates can be verified or signed
Expand Down

0 comments on commit e945ac1

Please sign in to comment.