You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by wa...@apache.org on 2022/09/22 06:06:30 UTC

[incubator-devlake] branch main updated (343fceb4 -> 1e765514)

This is an automated email from the ASF dual-hosted git repository.

warren pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


    from 343fceb4 fix(plugins): add plan
     new 6098a5a1 fix: update strategy environtment
     new 1e765514 fix: update strategy environtment

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 plugins/dora/dora.go                         |  2 +-
 plugins/dora/tasks/cicd_task_env_enricher.go |  8 ++++++--
 plugins/dora/tasks/task_data.go              | 10 +---------
 plugins/github/models/connection.go          |  2 +-
 plugins/github/tasks/cicd_job_convertor.go   | 13 +++++++------
 plugins/github/tasks/task_data.go            |  4 ++--
 plugins/gitlab/models/connection.go          |  2 +-
 plugins/gitlab/tasks/job_convertor.go        |  8 ++++----
 plugins/gitlab/tasks/task_data.go            |  8 ++++----
 plugins/jenkins/models/connection.go         |  2 +-
 plugins/jenkins/tasks/stage_convertor.go     |  8 ++++----
 plugins/jenkins/tasks/task_data.go           |  4 ++--
 12 files changed, 34 insertions(+), 37 deletions(-)


[incubator-devlake] 02/02: fix: update strategy environtment

Posted by wa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

warren pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit 1e76551496a197a0d21f6dbde373642a5e2f034b
Author: abeizn <zi...@merico.dev>
AuthorDate: Thu Sep 22 13:27:13 2022 +0800

    fix: update strategy environtment
---
 plugins/gitlab/tasks/task_data.go | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/plugins/gitlab/tasks/task_data.go b/plugins/gitlab/tasks/task_data.go
index edd8a35d..a76a2f28 100644
--- a/plugins/gitlab/tasks/task_data.go
+++ b/plugins/gitlab/tasks/task_data.go
@@ -77,7 +77,9 @@ func DecodeAndValidateTaskOptions(options map[string]interface{}) (*GitlabOption
 	if op.IssueTypeRequirement == "" {
 		op.IssueTypeRequirement = "^(feat|feature|proposal|requirement)$"
 	}
-
+	if op.DeploymentPattern == "" {
+		op.DeploymentPattern = "(?i)deploy"
+	}
 	// find the needed GitHub now
 	if op.ConnectionId == 0 {
 		return nil, errors.BadInput.New("connectionId is invalid")


[incubator-devlake] 01/02: fix: update strategy environtment

Posted by wa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

warren pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit 6098a5a1dd08366a6973d07341b5e076f1a84a33
Author: abeizn <zi...@merico.dev>
AuthorDate: Thu Sep 22 13:22:22 2022 +0800

    fix: update strategy environtment
---
 plugins/dora/dora.go                         |  2 +-
 plugins/dora/tasks/cicd_task_env_enricher.go |  8 ++++++--
 plugins/dora/tasks/task_data.go              | 10 +---------
 plugins/github/models/connection.go          |  2 +-
 plugins/github/tasks/cicd_job_convertor.go   | 13 +++++++------
 plugins/github/tasks/task_data.go            |  4 ++--
 plugins/gitlab/models/connection.go          |  2 +-
 plugins/gitlab/tasks/job_convertor.go        |  8 ++++----
 plugins/gitlab/tasks/task_data.go            |  6 ++----
 plugins/jenkins/models/connection.go         |  2 +-
 plugins/jenkins/tasks/stage_convertor.go     |  8 ++++----
 plugins/jenkins/tasks/task_data.go           |  4 ++--
 12 files changed, 32 insertions(+), 37 deletions(-)

diff --git a/plugins/dora/dora.go b/plugins/dora/dora.go
index 744e8f4c..6c98f3c2 100644
--- a/plugins/dora/dora.go
+++ b/plugins/dora/dora.go
@@ -32,7 +32,7 @@ func main() {
 
 	repoId := cmd.Flags().StringP("repoId", "r", "", "repo id")
 	_ = cmd.MarkFlagRequired("repoId")
-	productionPattern := cmd.Flags().String("productionPattern", "(?i)deploy", "environment production name")
+	productionPattern := cmd.Flags().String("productionPattern", "(?i)production", "environment production name")
 	stagingPattern := cmd.Flags().String("stagingPattern", "(?i)stag", "environment stag name")
 	testingPattern := cmd.Flags().String("testingPattern", "(?i)test", "environment test name")
 
diff --git a/plugins/dora/tasks/cicd_task_env_enricher.go b/plugins/dora/tasks/cicd_task_env_enricher.go
index 6c812866..277972d8 100644
--- a/plugins/dora/tasks/cicd_task_env_enricher.go
+++ b/plugins/dora/tasks/cicd_task_env_enricher.go
@@ -93,10 +93,14 @@ func EnrichTasksEnv(taskCtx core.SubTaskContext) (err errors.Error) {
 			cicdTask := inputRow.(*devops.CICDTask)
 			results := make([]interface{}, 0, 1)
 			var EnvironmentVar string
-			//var EnvironmentVar = devops.PRODUCTION
-			if productEnv := productionNameRegexp.FindString(cicdTask.Name); productEnv != "" {
+			if productionNamePattern == "" {
 				EnvironmentVar = devops.PRODUCTION
+			} else {
+				if productEnv := productionNameRegexp.FindString(cicdTask.Name); productEnv != "" {
+					EnvironmentVar = devops.PRODUCTION
+				}
 			}
+
 			// TODO: STAGE 2
 			// if stagingEnv := stagingNameRegexp.FindString(cicdTask.Name); stagingEnv != "" {
 			// 	EnvironmentVar = devops.STAGING
diff --git a/plugins/dora/tasks/task_data.go b/plugins/dora/tasks/task_data.go
index 31de4300..45355986 100644
--- a/plugins/dora/tasks/task_data.go
+++ b/plugins/dora/tasks/task_data.go
@@ -49,14 +49,6 @@ func DecodeAndValidateTaskOptions(options map[string]interface{}) (*DoraOptions,
 	if err != nil {
 		return nil, errors.Default.Wrap(err, "error decoding DORA task options")
 	}
-	if op.ProductionPattern == "" {
-		op.ProductionPattern = "(?i)deploy"
-	}
-	if op.StagingPattern == "" {
-		op.StagingPattern = "(?i)stag"
-	}
-	if op.TestingPattern == "" {
-		op.TestingPattern = "(?i)test"
-	}
+
 	return &op, nil
 }
diff --git a/plugins/github/models/connection.go b/plugins/github/models/connection.go
index d182dce8..35ba3a56 100644
--- a/plugins/github/models/connection.go
+++ b/plugins/github/models/connection.go
@@ -42,7 +42,7 @@ type TransformationRules struct {
 	IssueTypeBug         string `mapstructure:"issueTypeBug" json:"issueTypeBug"`
 	IssueTypeIncident    string `mapstructure:"issueTypeIncident" json:"issueTypeIncident"`
 	IssueTypeRequirement string `mapstructure:"issueTypeRequirement" json:"issueTypeRequirement"`
-	DeployTagPattern     string `mapstructure:"deployTagPattern" json:"deployTagPattern"`
+	DeploymentPattern    string `mapstructure:"deploymentPattern" json:"deploymentPattern"`
 }
 
 func (GithubConnection) TableName() string {
diff --git a/plugins/github/tasks/cicd_job_convertor.go b/plugins/github/tasks/cicd_job_convertor.go
index 4e67ef68..2b9f031a 100644
--- a/plugins/github/tasks/cicd_job_convertor.go
+++ b/plugins/github/tasks/cicd_job_convertor.go
@@ -18,11 +18,12 @@ limitations under the License.
 package tasks
 
 import (
-	"github.com/apache/incubator-devlake/errors"
-	"github.com/apache/incubator-devlake/models/domainlayer/didgen"
 	"reflect"
 	"regexp"
 
+	"github.com/apache/incubator-devlake/errors"
+	"github.com/apache/incubator-devlake/models/domainlayer/didgen"
+
 	"github.com/apache/incubator-devlake/plugins/core/dal"
 
 	"github.com/apache/incubator-devlake/plugins/core"
@@ -51,11 +52,11 @@ func ConvertTasks(taskCtx core.SubTaskContext) (err errors.Error) {
 	repoId := data.Repo.GithubId
 
 	var deployTagRegexp *regexp.Regexp
-	deployTagPattern := data.Options.DeployTagPattern
-	if len(deployTagPattern) > 0 {
-		deployTagRegexp, err = errors.Convert01(regexp.Compile(deployTagPattern))
+	deploymentPattern := data.Options.DeploymentPattern
+	if len(deploymentPattern) > 0 {
+		deployTagRegexp, err = errors.Convert01(regexp.Compile(deploymentPattern))
 		if err != nil {
-			return errors.Default.Wrap(err, "regexp compile deployTagPattern failed")
+			return errors.Default.Wrap(err, "regexp compile deploymentPattern failed")
 		}
 	}
 
diff --git a/plugins/github/tasks/task_data.go b/plugins/github/tasks/task_data.go
index 60350d1c..728f2283 100644
--- a/plugins/github/tasks/task_data.go
+++ b/plugins/github/tasks/task_data.go
@@ -82,8 +82,8 @@ func DecodeAndValidateTaskOptions(options map[string]interface{}) (*GithubOption
 	if op.IssueTypeRequirement == "" {
 		op.IssueTypeRequirement = "^(feat|feature|proposal|requirement)$"
 	}
-	if op.DeployTagPattern == "" {
-		op.DeployTagPattern = "(?i)deploy"
+	if op.DeploymentPattern == "" {
+		op.DeploymentPattern = "(?i)deploy"
 	}
 
 	// find the needed GitHub now
diff --git a/plugins/gitlab/models/connection.go b/plugins/gitlab/models/connection.go
index 8fbac80f..6fd3db1e 100644
--- a/plugins/gitlab/models/connection.go
+++ b/plugins/gitlab/models/connection.go
@@ -54,7 +54,7 @@ type TransformationRules struct {
 	IssueTypeBug         string `mapstructure:"issueTypeBug" json:"issueTypeBug"`
 	IssueTypeIncident    string `mapstructure:"issueTypeIncident" json:"issueTypeIncident"`
 	IssueTypeRequirement string `mapstructure:"issueTypeRequirement" json:"issueTypeRequirement"`
-	DeployTagPattern     string `mapstructure:"deployTagPattern" json:"deployTagPattern"`
+	DeploymentPattern    string `mapstructure:"deploymentPattern" json:"deploymentPattern"`
 }
 
 func (GitlabConnection) TableName() string {
diff --git a/plugins/gitlab/tasks/job_convertor.go b/plugins/gitlab/tasks/job_convertor.go
index 10dd2124..d2dc53f2 100644
--- a/plugins/gitlab/tasks/job_convertor.go
+++ b/plugins/gitlab/tasks/job_convertor.go
@@ -44,11 +44,11 @@ func ConvertJobs(taskCtx core.SubTaskContext) (err errors.Error) {
 	data := taskCtx.GetData().(*GitlabTaskData)
 
 	var deployTagRegexp *regexp.Regexp
-	deployTagPattern := data.Options.DeployTagPattern
-	if len(deployTagPattern) > 0 {
-		deployTagRegexp, err = errors.Convert01(regexp.Compile(deployTagPattern))
+	deploymentPattern := data.Options.DeploymentPattern
+	if len(deploymentPattern) > 0 {
+		deployTagRegexp, err = errors.Convert01(regexp.Compile(deploymentPattern))
 		if err != nil {
-			return errors.Default.Wrap(err, "regexp compile deployTagPattern failed")
+			return errors.Default.Wrap(err, "regexp compile deploymentPattern failed")
 		}
 	}
 
diff --git a/plugins/gitlab/tasks/task_data.go b/plugins/gitlab/tasks/task_data.go
index 0095507a..edd8a35d 100644
--- a/plugins/gitlab/tasks/task_data.go
+++ b/plugins/gitlab/tasks/task_data.go
@@ -18,9 +18,10 @@ limitations under the License.
 package tasks
 
 import (
-	"github.com/apache/incubator-devlake/errors"
 	"time"
 
+	"github.com/apache/incubator-devlake/errors"
+
 	"github.com/apache/incubator-devlake/plugins/gitlab/models"
 	"github.com/apache/incubator-devlake/plugins/helper"
 )
@@ -76,9 +77,6 @@ func DecodeAndValidateTaskOptions(options map[string]interface{}) (*GitlabOption
 	if op.IssueTypeRequirement == "" {
 		op.IssueTypeRequirement = "^(feat|feature|proposal|requirement)$"
 	}
-	if op.DeployTagPattern == "" {
-		op.DeployTagPattern = "(?i)deploy"
-	}
 
 	// find the needed GitHub now
 	if op.ConnectionId == 0 {
diff --git a/plugins/jenkins/models/connection.go b/plugins/jenkins/models/connection.go
index 3f0d42c6..7caab22b 100644
--- a/plugins/jenkins/models/connection.go
+++ b/plugins/jenkins/models/connection.go
@@ -39,7 +39,7 @@ type TestConnectionRequest struct {
 }
 
 type TransformationRules struct {
-	DeployTagPattern string `mapstructure:"deployTagPattern" json:"deployTagPattern"`
+	DeploymentPattern string `mapstructure:"deploymentPattern" json:"deploymentPattern"`
 }
 
 func (JenkinsConnection) TableName() string {
diff --git a/plugins/jenkins/tasks/stage_convertor.go b/plugins/jenkins/tasks/stage_convertor.go
index d0159068..75461f49 100644
--- a/plugins/jenkins/tasks/stage_convertor.go
+++ b/plugins/jenkins/tasks/stage_convertor.go
@@ -65,11 +65,11 @@ func ConvertStages(taskCtx core.SubTaskContext) (err errors.Error) {
 	db := taskCtx.GetDal()
 	data := taskCtx.GetData().(*JenkinsTaskData)
 	var deployTagRegexp *regexp.Regexp
-	deployTagPattern := data.Options.DeployTagPattern
-	if len(deployTagPattern) > 0 {
-		deployTagRegexp, err = errors.Convert01(regexp.Compile(deployTagPattern))
+	deploymentPattern := data.Options.DeploymentPattern
+	if len(deploymentPattern) > 0 {
+		deployTagRegexp, err = errors.Convert01(regexp.Compile(deploymentPattern))
 		if err != nil {
-			return errors.Default.Wrap(err, "regexp compile deployTagPattern failed")
+			return errors.Default.Wrap(err, "regexp compile deploymentPattern failed")
 		}
 	}
 
diff --git a/plugins/jenkins/tasks/task_data.go b/plugins/jenkins/tasks/task_data.go
index 9014ce0f..1a775706 100644
--- a/plugins/jenkins/tasks/task_data.go
+++ b/plugins/jenkins/tasks/task_data.go
@@ -49,8 +49,8 @@ func DecodeAndValidateTaskOptions(options map[string]interface{}) (*JenkinsOptio
 	if err != nil {
 		return nil, errors.BadInput.Wrap(err, "could not decode request parameters")
 	}
-	if op.DeployTagPattern == "" {
-		op.DeployTagPattern = "(?i)deploy"
+	if op.DeploymentPattern == "" {
+		op.DeploymentPattern = "(?i)deploy"
 	}
 	// find the needed Jenkins now
 	if op.ConnectionId == 0 {