Skip to content

Commit 9820704

Browse files
committed
Add missing license headers
Signed-off-by: Ricardo Zanini <[email protected]>
1 parent f74de33 commit 9820704

32 files changed

+497
-44
lines changed

expr/expr.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2025 The Serverless Workflow Specification Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package expr
216

317
import (

impl/context.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2025 The Serverless Workflow Specification Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package impl
216

317
import (

impl/json_schema.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2025 The Serverless Workflow Specification Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package impl
216

317
import (

impl/runner.go

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
1+
// Copyright 2025 The Serverless Workflow Specification Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package impl
216

317
import (
418
"context"
19+
"fmt"
520
"github.com/serverlessworkflow/sdk-go/v3/model"
621
)
722

@@ -53,7 +68,7 @@ func (wr *workflowRunnerImpl) Run(input interface{}) (output interface{}, err er
5368
}()
5469

5570
// Process input
56-
if input, err = wr.processWorkflowInput(input); err != nil {
71+
if input, err = wr.processInput(input); err != nil {
5772
return nil, err
5873
}
5974

@@ -70,7 +85,7 @@ func (wr *workflowRunnerImpl) Run(input interface{}) (output interface{}, err er
7085
}
7186

7287
// Process output
73-
if output, err = wr.processWorkflowOutput(output); err != nil {
88+
if output, err = wr.processOutput(output); err != nil {
7489
return nil, err
7590
}
7691

@@ -84,45 +99,25 @@ func (wr *workflowRunnerImpl) wrapWorkflowError(err error, taskName string) erro
8499
if knownErr := model.AsError(err); knownErr != nil {
85100
return knownErr.WithInstanceRef(wr.Workflow, taskName)
86101
}
87-
return model.NewErrRuntime(err, taskName)
102+
return model.NewErrRuntime(fmt.Errorf("workflow '%s', task '%s': %w", wr.Workflow.Document.Name, taskName, err), taskName)
88103
}
89104

90-
// processWorkflowInput validates and transforms input if needed.
91-
func (wr *workflowRunnerImpl) processWorkflowInput(input interface{}) (interface{}, error) {
105+
// processInput validates and transforms input if needed.
106+
func (wr *workflowRunnerImpl) processInput(input interface{}) (output interface{}, err error) {
92107
if wr.Workflow.Input != nil {
93-
var err error
94-
if err = validateSchema(input, wr.Workflow.Input.Schema, "/"); err != nil {
108+
output, err = processIO(input, wr.Workflow.Input.Schema, wr.Workflow.Input.From, "/")
109+
if err != nil {
95110
return nil, err
96111
}
97-
98-
if wr.Workflow.Input.From != nil {
99-
if input, err = traverseAndEvaluate(wr.Workflow.Input.From, input, "/"); err != nil {
100-
return nil, err
101-
}
102-
wr.RunnerCtx.SetInstanceCtx(input)
103-
}
112+
return output, nil
104113
}
105-
106-
wr.RunnerCtx.SetInput(input)
107-
wr.RunnerCtx.SetOutput(input)
108114
return input, nil
109115
}
110116

111-
// processWorkflowOutput applies output transformations.
112-
func (wr *workflowRunnerImpl) processWorkflowOutput(output interface{}) (interface{}, error) {
117+
// processOutput applies output transformations.
118+
func (wr *workflowRunnerImpl) processOutput(output interface{}) (interface{}, error) {
113119
if wr.Workflow.Output != nil {
114-
var err error
115-
if output, err = traverseAndEvaluate(wr.Workflow.Output.As, output, "/"); err != nil {
116-
return nil, err
117-
}
118-
119-
if err = validateSchema(output, wr.Workflow.Output.Schema, "/"); err != nil {
120-
return nil, err
121-
}
120+
return processIO(output, wr.Workflow.Output.Schema, wr.Workflow.Output.As, "/")
122121
}
123-
124-
wr.RunnerCtx.SetOutput(output)
125122
return output, nil
126123
}
127-
128-
// ----------------- Task funcs ------------------- //

impl/status_phase.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2025 The Serverless Workflow Specification Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package impl
216

317
import "time"

impl/task_runner.go

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2025 The Serverless Workflow Specification Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package impl
216

317
import (
@@ -34,10 +48,6 @@ func (s *SetTaskRunner) GetTaskName() string {
3448
return s.TaskName
3549
}
3650

37-
func (s *SetTaskRunner) String() string {
38-
return fmt.Sprintf("SetTaskRunner{Task: %s}", s.GetTaskName())
39-
}
40-
4151
func (s *SetTaskRunner) Run(input interface{}) (output interface{}, err error) {
4252
setObject := deepClone(s.Task.Set)
4353
result, err := expr.TraverseAndEvaluate(setObject, input)
@@ -135,19 +145,27 @@ func (r *RaiseTaskRunner) GetTaskName() string {
135145
return r.TaskName
136146
}
137147

138-
func NewForTaskRunner(taskName string, task *model.ForTask) (*ForTaskRunner, error) {
139-
if task == nil {
148+
func NewForTaskRunner(taskName string, task *model.ForTask, taskSupport TaskSupport) (*ForTaskRunner, error) {
149+
if task == nil || task.Do == nil {
140150
return nil, model.NewErrValidation(fmt.Errorf("invalid For task %s", taskName), taskName)
141151
}
152+
153+
doRunner, err := NewDoTaskRunner(task.Do, taskSupport)
154+
if err != nil {
155+
return nil, err
156+
}
157+
142158
return &ForTaskRunner{
143159
Task: task,
144160
TaskName: taskName,
161+
DoRunner: doRunner,
145162
}, nil
146163
}
147164

148165
type ForTaskRunner struct {
149166
Task *model.ForTask
150167
TaskName string
168+
DoRunner *DoTaskRunner
151169
}
152170

153171
func (f *ForTaskRunner) Run(input interface{}) (interface{}, error) {

impl/task_runner_do.go

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2025 The Serverless Workflow Specification Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package impl
216

317
import (
@@ -24,6 +38,8 @@ func NewTaskRunner(taskName string, task model.Task, taskSupport TaskSupport) (T
2438
return NewRaiseTaskRunner(taskName, t, taskSupport.GetWorkflowDef())
2539
case *model.DoTask:
2640
return NewDoTaskRunner(t.Do, taskSupport)
41+
case *model.ForTask:
42+
return NewForTaskRunner(taskName, t, taskSupport)
2743
default:
2844
return nil, fmt.Errorf("unsupported task type '%T' for task '%s'", t, taskName)
2945
}
@@ -54,7 +70,7 @@ func (d *DoTaskRunner) GetTaskName() string {
5470

5571
// executeTasks runs all defined tasks sequentially.
5672
func (d *DoTaskRunner) executeTasks(input interface{}, tasks *model.TaskList) (output interface{}, err error) {
57-
output = deepCloneValue(input)
73+
output = input
5874
if tasks == nil {
5975
return output, nil
6076
}
@@ -109,7 +125,7 @@ func (d *DoTaskRunner) runTask(input interface{}, runner TaskRunner, task *model
109125
taskName := runner.GetTaskName()
110126

111127
if task.Input != nil {
112-
if input, err = d.validateAndEvaluateTaskInput(task, input, taskName); err != nil {
128+
if input, err = d.processTaskInput(task, input, taskName); err != nil {
113129
return nil, err
114130
}
115131
}
@@ -119,15 +135,15 @@ func (d *DoTaskRunner) runTask(input interface{}, runner TaskRunner, task *model
119135
return nil, err
120136
}
121137

122-
if output, err = d.validateAndEvaluateTaskOutput(task, output, taskName); err != nil {
138+
if output, err = d.processTaskOutput(task, output, taskName); err != nil {
123139
return nil, err
124140
}
125141

126142
return output, nil
127143
}
128144

129-
// validateAndEvaluateTaskInput processes task input validation and transformation.
130-
func (d *DoTaskRunner) validateAndEvaluateTaskInput(task *model.TaskBase, taskInput interface{}, taskName string) (output interface{}, err error) {
145+
// processTaskInput processes task input validation and transformation.
146+
func (d *DoTaskRunner) processTaskInput(task *model.TaskBase, taskInput interface{}, taskName string) (output interface{}, err error) {
131147
if task.Input == nil {
132148
return taskInput, nil
133149
}
@@ -143,8 +159,8 @@ func (d *DoTaskRunner) validateAndEvaluateTaskInput(task *model.TaskBase, taskIn
143159
return output, nil
144160
}
145161

146-
// validateAndEvaluateTaskOutput processes task output validation and transformation.
147-
func (d *DoTaskRunner) validateAndEvaluateTaskOutput(task *model.TaskBase, taskOutput interface{}, taskName string) (output interface{}, err error) {
162+
// processTaskOutput processes task output validation and transformation.
163+
func (d *DoTaskRunner) processTaskOutput(task *model.TaskBase, taskOutput interface{}, taskName string) (output interface{}, err error) {
148164
if task.Output == nil {
149165
return taskOutput, nil
150166
}

impl/task_runner_raise_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2025 The Serverless Workflow Specification Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package impl
216

317
import (

impl/task_runner_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2025 The Serverless Workflow Specification Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package impl
216

317
import (

impl/task_set_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2025 The Serverless Workflow Specification Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package impl
216

317
import (

0 commit comments

Comments
 (0)