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/06/15 14:56:41 UTC

[GitHub] [incubator-devlake] warren830 opened a new pull request, #2212: refactor(gitlab): add conn id to project

warren830 opened a new pull request, #2212:
URL: https://github.com/apache/incubator-devlake/pull/2212

   # Summary
   
   Refactor gitlab project tasks with connection_id
   Add e2e test
   
   ### Does this close any open issues?
   Please mention the issues here.
   
   ### Screenshots
   Include any relevant screenshots here.
   
   ### Other Information
   Any other information that is important to this PR.
   


-- 
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] warren830 commented on a diff in pull request #2212: refactor(gitlab): add conn id to project

Posted by GitBox <gi...@apache.org>.
warren830 commented on code in PR #2212:
URL: https://github.com/apache/incubator-devlake/pull/2212#discussion_r898849388


##########
plugins/gitlab/impl/impl.go:
##########
@@ -82,8 +85,23 @@ func (plugin Gitlab) PrepareTaskData(taskCtx core.TaskContext, options map[strin
 	if err != nil {
 		return nil, err
 	}
-
+	if op.ConnectionId == 0 {
+		return nil, fmt.Errorf("connectionId is invalid")
+	}
+	connection := &models.GitlabConnection{}
+	connectionHelper := helper.NewConnectionHelper(
+		taskCtx,
+		nil,
+	)
+	if err != nil {
+		return nil, err
+	}
+	err = connectionHelper.FirstById(connection, op.ConnectionId)
+	if err != nil {
+		return nil, err
+	}
 	apiClient, err := tasks.NewGitlabApiClient(taskCtx)

Review Comment:
   I didn't see getConfig here...



-- 
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 #2212: refactor(gitlab): add conn id to project

Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #2212:
URL: https://github.com/apache/incubator-devlake/pull/2212#discussion_r898768013


##########
plugins/gitlab/impl/impl.go:
##########
@@ -82,8 +85,23 @@ func (plugin Gitlab) PrepareTaskData(taskCtx core.TaskContext, options map[strin
 	if err != nil {
 		return nil, err
 	}
-
+	if op.ConnectionId == 0 {
+		return nil, fmt.Errorf("connectionId is invalid")
+	}
+	connection := &models.GitlabConnection{}
+	connectionHelper := helper.NewConnectionHelper(
+		taskCtx,
+		nil,
+	)
+	if err != nil {
+		return nil, err
+	}
+	err = connectionHelper.FirstById(connection, op.ConnectionId)
+	if err != nil {
+		return nil, err
+	}
 	apiClient, err := tasks.NewGitlabApiClient(taskCtx)

Review Comment:
   Should use the connection to NewGitlabApiClient instead of using getConfig.



##########
config/config.go:
##########
@@ -45,13 +45,12 @@ func initConfig(v *viper.Viper) {
 	v.SetConfigType("env")
 	envPath := getEnvPath()
 	// AddConfigPath adds a path for Viper to search for the config file in.
-	if envPath == "" {

Review Comment:
   I have no idea about this 😹



##########
plugins/gitlab/gitlab.go:
##########
@@ -30,11 +30,14 @@ var PluginEntry impl.Gitlab //nolint
 func main() {
 	gitlabCmd := &cobra.Command{Use: "gitlab"}
 	projectId := gitlabCmd.Flags().IntP("project-id", "p", 0, "gitlab project id")
+	connectionId := gitlabCmd.Flags().Uint64P("connection-id", "c", 0, "gitlab connection id")

Review Comment:
   we have some different styles of cmd flags. Such as: "connectionId", "connection", "connection-id".
   Let's start a issue to talk about this.



-- 
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] warren830 commented on a diff in pull request #2212: refactor(gitlab): add conn id to project

Posted by GitBox <gi...@apache.org>.
warren830 commented on code in PR #2212:
URL: https://github.com/apache/incubator-devlake/pull/2212#discussion_r898801569


##########
plugins/gitlab/gitlab.go:
##########
@@ -30,11 +30,14 @@ var PluginEntry impl.Gitlab //nolint
 func main() {
 	gitlabCmd := &cobra.Command{Use: "gitlab"}
 	projectId := gitlabCmd.Flags().IntP("project-id", "p", 0, "gitlab project id")
+	connectionId := gitlabCmd.Flags().Uint64P("connection-id", "c", 0, "gitlab connection id")

Review Comment:
   great!



-- 
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] mindlesscloud merged pull request #2212: refactor(gitlab): add conn id to project

Posted by GitBox <gi...@apache.org>.
mindlesscloud merged PR #2212:
URL: https://github.com/apache/incubator-devlake/pull/2212


-- 
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 #2212: refactor(gitlab): add conn id to project

Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #2212:
URL: https://github.com/apache/incubator-devlake/pull/2212#discussion_r898856830


##########
plugins/gitlab/impl/impl.go:
##########
@@ -82,8 +85,23 @@ func (plugin Gitlab) PrepareTaskData(taskCtx core.TaskContext, options map[strin
 	if err != nil {
 		return nil, err
 	}
-
+	if op.ConnectionId == 0 {
+		return nil, fmt.Errorf("connectionId is invalid")
+	}
+	connection := &models.GitlabConnection{}
+	connectionHelper := helper.NewConnectionHelper(
+		taskCtx,
+		nil,
+	)
+	if err != nil {
+		return nil, err
+	}
+	err = connectionHelper.FirstById(connection, op.ConnectionId)
+	if err != nil {
+		return nil, err
+	}
 	apiClient, err := tasks.NewGitlabApiClient(taskCtx)

Review Comment:
   it's in NewGitlabApiClient. Or you can fix it in next pr.



##########
plugins/gitlab/impl/impl.go:
##########
@@ -82,8 +85,23 @@ func (plugin Gitlab) PrepareTaskData(taskCtx core.TaskContext, options map[strin
 	if err != nil {
 		return nil, err
 	}
-
+	if op.ConnectionId == 0 {
+		return nil, fmt.Errorf("connectionId is invalid")
+	}
+	connection := &models.GitlabConnection{}
+	connectionHelper := helper.NewConnectionHelper(
+		taskCtx,
+		nil,
+	)
+	if err != nil {
+		return nil, err
+	}
+	err = connectionHelper.FirstById(connection, op.ConnectionId)
+	if err != nil {
+		return nil, err
+	}
 	apiClient, err := tasks.NewGitlabApiClient(taskCtx)

Review Comment:
   it's in NewGitlabApiClient. Or you can fix it in next pr.



-- 
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