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/12/09 02:35:42 UTC
[GitHub] [incubator-devlake] warren830 opened a new pull request, #3892: fix(github): modify bp v200
warren830 opened a new pull request, #3892:
URL: https://github.com/apache/incubator-devlake/pull/3892
### Summary
Change the way to set options in plugin GitHub.
Before, we set all values to tasks.GithubOptions when making plan, right now, we just pass scopeId to options, and set other values when preparing plugin data
### Does this close any open issues?
relate to #3468
### 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] likyh commented on a diff in pull request #3892: fix(github): modify bp v200
Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #3892:
URL: https://github.com/apache/incubator-devlake/pull/3892#discussion_r1044146229
##########
plugins/github_graphql/impl/impl.go:
##########
@@ -137,6 +133,41 @@ func (plugin GithubGraphql) PrepareTaskData(taskCtx core.TaskContext, options ma
return nil, errors.Default.Wrap(err, "unable to get github connection by the given connection ID: %v")
}
+ var githubRepo models.GithubRepo
+ // for advanced mode or others which we already set value to onwer/repo
+ if op.Owner != "" && op.Repo != "" {
+ err = taskCtx.GetDal().First(&githubRepo, dal.Where(
+ "connection_id = ? AND name = ? AND owner_login = ",
Review Comment:
=?
--
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 #3892: fix(github): modify bp v200
Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #3892:
URL: https://github.com/apache/incubator-devlake/pull/3892#discussion_r1044145451
##########
plugins/github/impl/impl.go:
##########
@@ -159,6 +161,32 @@ func (plugin Github) PrepareTaskData(taskCtx core.TaskContext, options map[strin
if err != nil {
return nil, errors.Default.Wrap(err, "unable to get github connection by the given connection ID")
}
+ var githubRepo models.GithubRepo
+ // for advanced mode which we already set value to onwer/repo
+ if op.Owner != "" && op.Repo != "" {
+ err = taskCtx.GetDal().First(&githubRepo, dal.Where(
+ "connection_id = ? AND name = ? AND owner_login = ",
Review Comment:
it should be "owner_login = ?"
--
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 #3892: fix(github): modify bp v200
Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #3892:
URL: https://github.com/apache/incubator-devlake/pull/3892#discussion_r1044189322
##########
plugins/github_graphql/impl/impl.go:
##########
@@ -178,6 +178,49 @@ func (plugin GithubGraphql) PrepareTaskData(taskCtx core.TaskContext, options ma
}, nil
}
+func EnrichOptions(taskCtx core.TaskContext,
Review Comment:
Defined in github_graphql?
##########
plugins/github/api/blueprint_v200.go:
##########
@@ -86,9 +85,12 @@ func makeDataSourcePipelinePlanV200(
apiClient helper.ApiClientGetter,
) (core.PipelinePlan, errors.Error) {
var err errors.Error
- var stage core.PipelineStage
- var repo *tasks.GithubApiRepo
+ var repoRes *tasks.GithubApiRepo
for i, bpScope := range bpScopes {
+ stage := plan[i]
Review Comment:
plan and bpScopes have the same order and count?
--
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 #3892: fix(github): modify bp v200
Posted by GitBox <gi...@apache.org>.
warren830 commented on code in PR #3892:
URL: https://github.com/apache/incubator-devlake/pull/3892#discussion_r1044195376
##########
plugins/github_graphql/impl/impl.go:
##########
@@ -178,6 +178,49 @@ func (plugin GithubGraphql) PrepareTaskData(taskCtx core.TaskContext, options ma
}, nil
}
+func EnrichOptions(taskCtx core.TaskContext,
+ op *githubTasks.GithubOptions,
+ connection *models.GithubConnection) (*models.GithubRepo, errors.Error) {
+ var githubRepo models.GithubRepo
+ var err errors.Error
+ log := taskCtx.GetLogger()
+ // for advanced mode or others which we already set value to onwer/repo
+ if op.Owner != "" && op.Repo != "" {
+ err := taskCtx.GetDal().First(&githubRepo, dal.Where(
+ "connection_id = ? AND name = ? AND owner_login = ?",
+ op.ConnectionId, op.Repo, op.Owner))
+ if err != nil {
+ return nil, errors.Default.Wrap(err, fmt.Sprintf("fail to find repo %s/%s", op.Owner, op.Repo))
+ }
+ op.TransformationRuleId = githubRepo.TransformationRuleId
+ }
+ // for bp v200 which we only set ScopeId for options
+ if &githubRepo == nil && op.ScopeId != "" {
Review Comment:
> It looks like `&githubRepo == nil` always true.
yes, already fixed
--
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 #3892: fix(github): modify bp v200
Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #3892:
URL: https://github.com/apache/incubator-devlake/pull/3892#discussion_r1044190661
##########
plugins/github_graphql/impl/impl.go:
##########
@@ -178,6 +178,49 @@ func (plugin GithubGraphql) PrepareTaskData(taskCtx core.TaskContext, options ma
}, nil
}
+func EnrichOptions(taskCtx core.TaskContext,
+ op *githubTasks.GithubOptions,
+ connection *models.GithubConnection) (*models.GithubRepo, errors.Error) {
+ var githubRepo models.GithubRepo
+ var err errors.Error
+ log := taskCtx.GetLogger()
+ // for advanced mode or others which we already set value to onwer/repo
+ if op.Owner != "" && op.Repo != "" {
+ err := taskCtx.GetDal().First(&githubRepo, dal.Where(
+ "connection_id = ? AND name = ? AND owner_login = ?",
+ op.ConnectionId, op.Repo, op.Owner))
+ if err != nil {
+ return nil, errors.Default.Wrap(err, fmt.Sprintf("fail to find repo %s/%s", op.Owner, op.Repo))
+ }
+ op.TransformationRuleId = githubRepo.TransformationRuleId
+ }
+ // for bp v200 which we only set ScopeId for options
+ if &githubRepo == nil && op.ScopeId != "" {
Review Comment:
It looks like `&githubRepo == nil` always true.
##########
plugins/github_graphql/impl/impl.go:
##########
@@ -178,6 +178,49 @@ func (plugin GithubGraphql) PrepareTaskData(taskCtx core.TaskContext, options ma
}, nil
}
+func EnrichOptions(taskCtx core.TaskContext,
+ op *githubTasks.GithubOptions,
+ connection *models.GithubConnection) (*models.GithubRepo, errors.Error) {
+ var githubRepo models.GithubRepo
+ var err errors.Error
+ log := taskCtx.GetLogger()
+ // for advanced mode or others which we already set value to onwer/repo
+ if op.Owner != "" && op.Repo != "" {
+ err := taskCtx.GetDal().First(&githubRepo, dal.Where(
+ "connection_id = ? AND name = ? AND owner_login = ?",
+ op.ConnectionId, op.Repo, op.Owner))
+ if err != nil {
+ return nil, errors.Default.Wrap(err, fmt.Sprintf("fail to find repo %s/%s", op.Owner, op.Repo))
+ }
+ op.TransformationRuleId = githubRepo.TransformationRuleId
+ }
+ // for bp v200 which we only set ScopeId for options
+ if &githubRepo == nil && op.ScopeId != "" {
Review Comment:
It looks like `&githubRepo == nil` is always true.
--
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 #3892: fix(github): modify bp v200
Posted by GitBox <gi...@apache.org>.
warren830 commented on code in PR #3892:
URL: https://github.com/apache/incubator-devlake/pull/3892#discussion_r1044166565
##########
plugins/github_graphql/impl/impl.go:
##########
@@ -137,6 +133,41 @@ func (plugin GithubGraphql) PrepareTaskData(taskCtx core.TaskContext, options ma
return nil, errors.Default.Wrap(err, "unable to get github connection by the given connection ID: %v")
}
+ var githubRepo models.GithubRepo
+ // for advanced mode or others which we already set value to onwer/repo
+ if op.Owner != "" && op.Repo != "" {
+ err = taskCtx.GetDal().First(&githubRepo, dal.Where(
+ "connection_id = ? AND name = ? AND owner_login = ",
Review Comment:
fixed
##########
plugins/github/impl/impl.go:
##########
@@ -159,6 +161,32 @@ func (plugin Github) PrepareTaskData(taskCtx core.TaskContext, options map[strin
if err != nil {
return nil, errors.Default.Wrap(err, "unable to get github connection by the given connection ID")
}
+ var githubRepo models.GithubRepo
+ // for advanced mode which we already set value to onwer/repo
+ if op.Owner != "" && op.Repo != "" {
+ err = taskCtx.GetDal().First(&githubRepo, dal.Where(
+ "connection_id = ? AND name = ? AND owner_login = ",
Review Comment:
fixed
--
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 #3892: fix(github): modify bp v200
Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #3892:
URL: https://github.com/apache/incubator-devlake/pull/3892#discussion_r1044139668
##########
plugins/github/api/blueprint_v200.go:
##########
@@ -123,39 +125,37 @@ func makeDataSourcePipelinePlanV200(
// construct task options for github
op := &tasks.GithubOptions{
- ConnectionId: githubRepo.ConnectionId,
- TransformationRuleId: githubRepo.TransformationRuleId,
- Owner: githubRepo.OwnerLogin,
- Repo: githubRepo.Name,
- }
- options, err := tasks.ValidateAndEncodeTaskOptions(op)
- if err != nil {
- return nil, err
+ ConnectionId: githubRepo.ConnectionId,
+ ScopeId: bpScope.Id,
}
-
- var transformationRuleMap map[string]interface{}
- err = errors.Convert(mapstructure.Decode(transformationRule, &transformationRuleMap))
+ options, err := tasks.EncodeTaskOptions(op)
if err != nil {
return nil, err
}
- options["transformationRules"] = transformationRuleMap
stage, err = addGithub(subtaskMetas, connection, bpScope.Entities, stage, options)
if err != nil {
return nil, err
}
+ ownerRepo := strings.Split(githubRepo.Name, "/")
+ if len(ownerRepo) != 2 {
+ return nil, errors.Default.New("Fail to parse githubRepo.Name")
+ }
+ op.Owner = ownerRepo[0]
+ op.Repo = ownerRepo[1]
// add gitex stage and add repo to scopes
if utils.StringsContains(bpScope.Entities, core.DOMAIN_TYPE_CODE) {
- repo, err = memorizedGetApiRepo(repo, op, apiClient)
+ repoRes, err = memorizedGetApiRepo(repoRes, op, apiClient)
if err != nil {
return nil, err
}
- stage, err = addGitex(bpScope.Entities, connection, repo, stage)
+ stage, err = addGitex(bpScope.Entities, connection, repoRes, stage)
if err != nil {
return nil, err
}
}
plan[i] = stage
}
+ fmt.Println(plan)
Review Comment:
delete debug code
--
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 merged pull request #3892: fix(github): modify bp v200
Posted by GitBox <gi...@apache.org>.
warren830 merged PR #3892:
URL: https://github.com/apache/incubator-devlake/pull/3892
--
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