You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by GitBox <gi...@apache.org> on 2022/11/04 08:52:34 UTC
[GitHub] [incubator-devlake] klesh opened a new pull request, #3677: feat: added MetricPluginBlueprintV200 interface
klesh opened a new pull request, #3677:
URL: https://github.com/apache/incubator-devlake/pull/3677
# Summary
feat: added MetricPluginBlueprintV200 interface
### Does this close any open issues?
Part of #3468
--
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: commits-unsubscribe@devlake.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-devlake] likyh commented on a diff in pull request #3677: feat: added MetricPluginBlueprintV200 interface
Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #3677:
URL: https://github.com/apache/incubator-devlake/pull/3677#discussion_r1016468966
##########
services/blueprint.go:
##########
@@ -254,7 +254,7 @@ func GeneratePlanJson(settings json.RawMessage) (json.RawMessage, errors.Error)
if err != nil {
return nil, errors.Default.Wrap(err, fmt.Sprintf("settings:%s", string(settings)))
}
- var plan interface{}
+ var plan core.PipelinePlan
switch bpSettings.Version {
case "1.0.0":
Review Comment:
add a new case?
--
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: commits-unsubscribe@devlake.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-devlake] likyh commented on a diff in pull request #3677: feat: added MetricPluginBlueprintV200 interface
Posted by GitBox <gi...@apache.org>.
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: commits-unsubscribe@devlake.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-devlake] likyh commented on a diff in pull request #3677: feat: added MetricPluginBlueprintV200 interface
Posted by GitBox <gi...@apache.org>.
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` sounds 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: commits-unsubscribe@devlake.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-devlake] likyh commented on a diff in pull request #3677: feat: added MetricPluginBlueprintV200 interface
Posted by GitBox <gi...@apache.org>.
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` sounds like a function just for adding beforePipeline and afterPipeline. But there is also an operation to 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: commits-unsubscribe@devlake.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-devlake] likyh merged pull request #3677: feat: added MetricPluginBlueprintV200 interface
Posted by GitBox <gi...@apache.org>.
likyh merged PR #3677:
URL: https://github.com/apache/incubator-devlake/pull/3677
--
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: commits-unsubscribe@devlake.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-devlake] klesh commented on a diff in pull request #3677: feat: added MetricPluginBlueprintV200 interface
Posted by GitBox <gi...@apache.org>.
klesh commented on code in PR #3677:
URL: https://github.com/apache/incubator-devlake/pull/3677#discussion_r1017636472
##########
services/blueprint.go:
##########
@@ -254,7 +254,7 @@ func GeneratePlanJson(settings json.RawMessage) (json.RawMessage, errors.Error)
if err != nil {
return nil, errors.Default.Wrap(err, fmt.Sprintf("settings:%s", string(settings)))
}
- var plan interface{}
+ var plan core.PipelinePlan
switch bpSettings.Version {
case "1.0.0":
Review Comment:
`blueprint.project_name` is required in this case.
--
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: commits-unsubscribe@devlake.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org