-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: add stepGroupName to process.Context
Signed-off-by: yangsoon <songyang.song@alibaba-inc.com>
- Loading branch information
yangsoon
committed
Apr 6, 2023
1 parent
c730c05
commit 329a305
Showing
11 changed files
with
294 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
apiVersion: core.oam.dev/v1beta1 | ||
kind: WorkflowStepDefinition | ||
metadata: | ||
name: save-process-context | ||
namespace: vela-system | ||
spec: | ||
schematic: | ||
cue: | ||
template: | | ||
import "vela/op" | ||
cm: op.#Apply & { | ||
value: { | ||
apiVersion: "v1" | ||
kind: "ConfigMap" | ||
metadata: { | ||
name: parameter.name | ||
labels: { | ||
"process.context.data": "true" | ||
} | ||
} | ||
data: context | ||
} | ||
} | ||
parameter: name: string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package process | ||
|
||
import "github.com/kubevela/workflow/pkg/cue/model" | ||
|
||
// DataManager is in charge of injecting and removing runtime context for ContextData | ||
type DataManager interface { | ||
Fill(ctx Context, kvs []StepMetaKV) | ||
Remove(ctx Context, keys []string) | ||
} | ||
|
||
// StepRunTimeMeta manage step runtime metadata | ||
type StepRunTimeMeta struct{} | ||
|
||
// StepMetaKV store the key and value of step runtime metadata | ||
type StepMetaKV struct { | ||
Key string | ||
Value interface{} | ||
} | ||
|
||
// WithSessionID return stepSessionID of the step | ||
func WithSessionID(id string) StepMetaKV { | ||
return StepMetaKV{ | ||
Key: model.ContextStepSessionID, | ||
Value: id, | ||
} | ||
} | ||
|
||
// WithName return stepName of the step | ||
func WithName(name string) StepMetaKV { | ||
return StepMetaKV{ | ||
Key: model.ContextStepName, | ||
Value: name, | ||
} | ||
} | ||
|
||
// WithGroupName return stepGroupName of the step | ||
func WithGroupName(name string) StepMetaKV { | ||
return StepMetaKV{ | ||
Key: model.ContextStepGroupName, | ||
Value: name, | ||
} | ||
} | ||
|
||
// WithSpanID return spanID of the step | ||
func WithSpanID(id string) StepMetaKV { | ||
return StepMetaKV{ | ||
Key: model.ContextSpanID, | ||
Value: id, | ||
} | ||
} | ||
|
||
// NewStepRunTimeMeta create step runtime metadata manager | ||
func NewStepRunTimeMeta() DataManager { | ||
return &StepRunTimeMeta{} | ||
} | ||
|
||
// Fill will fill step runtime metadata for ContextData | ||
func (s *StepRunTimeMeta) Fill(ctx Context, kvs []StepMetaKV) { | ||
for _, kv := range kvs { | ||
ctx.PushData(kv.Key, kv.Value) | ||
} | ||
} | ||
|
||
// Remove remove step runtime metadata of ContextData | ||
func (s *StepRunTimeMeta) Remove(ctx Context, keys []string) { | ||
for _, key := range keys { | ||
ctx.RemoveData(key) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.