likyh commented on code in PR #3677:
URL:
https://github.com/apache/incubator-devlake/pull/3677#discussion_r1016464885
##########
services/blueprint.go:
##########
@@ -264,87 +264,37 @@ func GeneratePlanJson(settings json.RawMessage)
(json.RawMessage, errors.Error)
if err != nil {
return nil, err
}
- return errors.Convert01(json.Marshal(plan))
-}
-
-// GeneratePlanJsonV100 generates pipeline plan according v1.0.0 definition
-func GeneratePlanJsonV100(settings *models.BlueprintSettings)
(core.PipelinePlan, errors.Error) {
- connections := make([]*core.BlueprintConnectionV100, 0)
- err := errors.Convert(json.Unmarshal(settings.Connections,
&connections))
+ plan, err = WrapPipelinePlans(bpSettings.BeforePlan, plan,
bpSettings.AfterPlan)
if err != nil {
return nil, err
}
- hasDoraEnrich := false
- doraRules := make(map[string]interface{})
- plans := make([]core.PipelinePlan, len(connections))
- for i, connection := range connections {
- if len(connection.Scope) == 0 {
- return nil,
errors.Default.New(fmt.Sprintf("connections[%d].scope is empty", i))
- }
- plugin, err := core.GetPlugin(connection.Plugin)
- if err != nil {
- return nil, err
- }
- if pluginBp, ok := plugin.(core.PluginBlueprintV100); ok {
- plans[i], err =
pluginBp.MakePipelinePlan(connection.ConnectionId, connection.Scope)
- if err != nil {
- return nil, err
- }
- } else {
- return nil, errors.Default.New(fmt.Sprintf("plugin %s
does not support blueprint protocol version 1.0.0", connection.Plugin))
- }
- for _, stage := range plans[i] {
- for _, task := range stage {
- if task.Plugin == "dora" {
- hasDoraEnrich = true
- for k, v := range task.Options {
- doraRules[k] = v
- }
- }
- }
- }
- }
- mergedPipelinePlan := MergePipelinePlans(plans...)
- if hasDoraEnrich {
- plan := core.PipelineStage{
- &core.PipelineTask{
- Plugin: "dora",
- Subtasks: []string{"calculateChangeLeadTime",
"ConnectIssueDeploy"},
- Options: doraRules,
- },
- }
- mergedPipelinePlan = append(mergedPipelinePlan, plan)
- }
- return FormatPipelinePlans(settings.BeforePlan, mergedPipelinePlan,
settings.AfterPlan)
+ return errors.Convert01(json.Marshal(plan))
}
-// FormatPipelinePlans merges multiple pipelines and append before and after
pipeline
-func FormatPipelinePlans(beforePlanJson json.RawMessage, mainPlan
core.PipelinePlan, afterPlanJson json.RawMessage) (core.PipelinePlan,
errors.Error) {
- newPipelinePlan := core.PipelinePlan{}
+// WrapPipelinePlans merges multiple pipelines and append before and after
pipeline
+func WrapPipelinePlans(beforePlanJson json.RawMessage, mainPlan
core.PipelinePlan, afterPlanJson json.RawMessage) (core.PipelinePlan,
errors.Error) {
Review Comment:
Function `wrapXXX` listen like a function just for adding beforePipeline and
afterPipeline. But here is also sequencialize this plains. Let's change it to
an appropriate name .
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]