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/16 07:13:42 UTC

[GitHub] [incubator-devlake] likyh commented on a diff in pull request #2212: refactor(gitlab): add conn id to project

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