Misc fixes related to workflows

dev
Ice3man543 2021-02-23 22:55:29 +05:30
parent 3ec3ecdd8a
commit c4843cdaf5
5 changed files with 16 additions and 15 deletions

View File

@ -71,6 +71,7 @@ func Parse(filePath string, options protocols.ExecuterOptions) (*Template, error
return nil, errors.Wrap(err, "could not compile workflow")
}
template.CompiledWorkflow = compiled
template.CompiledWorkflow.Options = &options
}
// Compile the requests found

View File

@ -10,7 +10,7 @@ import (
// Parse a yaml workflow file
func Parse(file string, options *protocols.ExecuterOptions) (*Workflow, error) {
workflow := &Workflow{options: options}
workflow := &Workflow{Options: options}
f, err := os.Open(file)
if err != nil {

View File

@ -11,7 +11,7 @@ import (
func (w *Workflow) RunWorkflow(input string) bool {
results := &atomic.Bool{}
swg := sizedwaitgroup.New(w.options.Options.TemplateThreads)
swg := sizedwaitgroup.New(w.Options.Options.TemplateThreads)
for _, template := range w.Workflows {
swg.Add()
func(template *WorkflowTemplate) {

View File

@ -12,9 +12,9 @@ import (
)
func TestWorkflowsSimple(t *testing.T) {
progress, _ := progress.NewProgress(false, false, 0)
progress, _ := progress.NewProgress(0, false, false, 0)
workflow := &Workflow{options: &protocols.ExecuterOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*WorkflowTemplate{
workflow := &Workflow{Options: &protocols.ExecuterOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*WorkflowTemplate{
{Executers: []*ProtocolExecuterPair{{
Executer: &mockExecuter{result: true}, Options: &protocols.ExecuterOptions{Progress: progress}},
}},
@ -25,10 +25,10 @@ func TestWorkflowsSimple(t *testing.T) {
}
func TestWorkflowsSimpleMultiple(t *testing.T) {
progress, _ := progress.NewProgress(false, false, 0)
progress, _ := progress.NewProgress(0, false, false, 0)
var firstInput, secondInput string
workflow := &Workflow{options: &protocols.ExecuterOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*WorkflowTemplate{
workflow := &Workflow{Options: &protocols.ExecuterOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*WorkflowTemplate{
{Executers: []*ProtocolExecuterPair{{
Executer: &mockExecuter{result: true, executeHook: func(input string) {
firstInput = input
@ -49,10 +49,10 @@ func TestWorkflowsSimpleMultiple(t *testing.T) {
}
func TestWorkflowsSubtemplates(t *testing.T) {
progress, _ := progress.NewProgress(false, false, 0)
progress, _ := progress.NewProgress(0, false, false, 0)
var firstInput, secondInput string
workflow := &Workflow{options: &protocols.ExecuterOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*WorkflowTemplate{
workflow := &Workflow{Options: &protocols.ExecuterOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*WorkflowTemplate{
{Executers: []*ProtocolExecuterPair{{
Executer: &mockExecuter{result: true, executeHook: func(input string) {
firstInput = input
@ -72,10 +72,10 @@ func TestWorkflowsSubtemplates(t *testing.T) {
}
func TestWorkflowsSubtemplatesNoMatch(t *testing.T) {
progress, _ := progress.NewProgress(false, false, 0)
progress, _ := progress.NewProgress(0, false, false, 0)
var firstInput, secondInput string
workflow := &Workflow{options: &protocols.ExecuterOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*WorkflowTemplate{
workflow := &Workflow{Options: &protocols.ExecuterOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*WorkflowTemplate{
{Executers: []*ProtocolExecuterPair{{
Executer: &mockExecuter{result: false, executeHook: func(input string) {
firstInput = input
@ -95,10 +95,10 @@ func TestWorkflowsSubtemplatesNoMatch(t *testing.T) {
}
func TestWorkflowsSubtemplatesWithMatcher(t *testing.T) {
progress, _ := progress.NewProgress(false, false, 0)
progress, _ := progress.NewProgress(0, false, false, 0)
var firstInput, secondInput string
workflow := &Workflow{options: &protocols.ExecuterOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*WorkflowTemplate{
workflow := &Workflow{Options: &protocols.ExecuterOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*WorkflowTemplate{
{Executers: []*ProtocolExecuterPair{{
Executer: &mockExecuter{result: true, executeHook: func(input string) {
firstInput = input
@ -123,10 +123,10 @@ func TestWorkflowsSubtemplatesWithMatcher(t *testing.T) {
}
func TestWorkflowsSubtemplatesWithMatcherNoMatch(t *testing.T) {
progress, _ := progress.NewProgress(false, false, 0)
progress, _ := progress.NewProgress(0, false, false, 0)
var firstInput, secondInput string
workflow := &Workflow{options: &protocols.ExecuterOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*WorkflowTemplate{
workflow := &Workflow{Options: &protocols.ExecuterOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*WorkflowTemplate{
{Executers: []*ProtocolExecuterPair{{
Executer: &mockExecuter{result: true, executeHook: func(input string) {
firstInput = input

View File

@ -7,7 +7,7 @@ type Workflow struct {
// Workflows is a yaml based workflow declaration code.
Workflows []*WorkflowTemplate `yaml:"workflows,omitempty"`
options *protocols.ExecuterOptions
Options *protocols.ExecuterOptions
}
// WorkflowTemplate is a template to be ran as part of a workflow