klesh commented on code in PR #2128:
URL: https://github.com/apache/incubator-devlake/pull/2128#discussion_r893617864
##########
plugins/github/github.go:
##########
@@ -95,7 +96,16 @@ func (plugin Github) PrepareTaskData(taskCtx
core.TaskContext, options map[strin
if op.Repo == "" {
return nil, fmt.Errorf("repo is required for GitHub execution")
}
- apiClient, err := tasks.CreateApiClient(taskCtx)
+
+ // find the only github now
+ // FIXME to query by connection id when multi connection support
+ connection := &models.GithubConnection{}
+ err = taskCtx.GetDb().First(connection, "name = ?", `GitHub`).Error
Review Comment:
Use `GetDal` pls
##########
plugins/github/models/connection.go:
##########
@@ -17,31 +17,33 @@ limitations under the License.
package models
-type GithubConnection struct {
- Endpoint string `mapstructure:"endpoint" validate:"required"
env:"GITHUB_ENDPOINT" json:"endpoint"`
- Auth string `mapstructure:"auth" validate:"required"
env:"GITHUB_AUTH" json:"auth"`
- Proxy string `mapstructure:"proxy" env:"GITHUB_PROXY" json:"proxy"`
+import "github.com/apache/incubator-devlake/plugins/helper"
- Config `mapstructure:",squash"`
+type TestConnectionRequest struct {
+ Endpoint string `json:"endpoint" validate:"required,url"`
+ Auth string `json:"auth" validate:"required"`
+ Proxy string `json:"proxy"`
}
-type Config struct {
- PrType string `mapstructure:"prType" env:"GITHUB_PR_TYPE"
json:"prType"`
- PrComponent string `mapstructure:"prComponent"
env:"GITHUB_PR_COMPONENT" json:"prComponent"`
- IssueSeverity string `mapstructure:"issueSeverity"
env:"GITHUB_ISSUE_SEVERITY" json:"issueSeverity"`
- IssuePriority string `mapstructure:"issuePriority"
env:"GITHUB_ISSUE_PRIORITY" json:"issuePriority"`
- IssueComponent string `mapstructure:"issueComponent"
env:"GITHUB_ISSUE_COMPONENT" json:"issueComponent"`
- IssueTypeBug string `mapstructure:"issueTypeBug"
env:"GITHUB_ISSUE_TYPE_BUG" json:"issueTypeBug"`
- IssueTypeIncident string `mapstructure:"issueTypeIncident"
env:"GITHUB_ISSUE_TYPE_INCIDENT" json:"issueTypeIncident"`
- IssueTypeRequirement string `mapstructure:"issueTypeRequirement"
env:"GITHUB_ISSUE_TYPE_REQUIREMENT" json:"issueTypeRequirement"`
+type GithubConnection struct {
+ helper.RestConnection `mapstructure:",squash"`
+ Auth string `mapstructure:"auth" validate:"required"
json:"auth"`
Review Comment:
I think this one should be `helper.AccessToken` instead
##########
plugins/github/models/connection.go:
##########
@@ -17,31 +17,33 @@ limitations under the License.
package models
-type GithubConnection struct {
- Endpoint string `mapstructure:"endpoint" validate:"required"
env:"GITHUB_ENDPOINT" json:"endpoint"`
- Auth string `mapstructure:"auth" validate:"required"
env:"GITHUB_AUTH" json:"auth"`
- Proxy string `mapstructure:"proxy" env:"GITHUB_PROXY" json:"proxy"`
+import "github.com/apache/incubator-devlake/plugins/helper"
- Config `mapstructure:",squash"`
+type TestConnectionRequest struct {
+ Endpoint string `json:"endpoint" validate:"required,url"`
+ Auth string `json:"auth" validate:"required"`
+ Proxy string `json:"proxy"`
}
-type Config struct {
- PrType string `mapstructure:"prType" env:"GITHUB_PR_TYPE"
json:"prType"`
- PrComponent string `mapstructure:"prComponent"
env:"GITHUB_PR_COMPONENT" json:"prComponent"`
- IssueSeverity string `mapstructure:"issueSeverity"
env:"GITHUB_ISSUE_SEVERITY" json:"issueSeverity"`
- IssuePriority string `mapstructure:"issuePriority"
env:"GITHUB_ISSUE_PRIORITY" json:"issuePriority"`
- IssueComponent string `mapstructure:"issueComponent"
env:"GITHUB_ISSUE_COMPONENT" json:"issueComponent"`
- IssueTypeBug string `mapstructure:"issueTypeBug"
env:"GITHUB_ISSUE_TYPE_BUG" json:"issueTypeBug"`
- IssueTypeIncident string `mapstructure:"issueTypeIncident"
env:"GITHUB_ISSUE_TYPE_INCIDENT" json:"issueTypeIncident"`
- IssueTypeRequirement string `mapstructure:"issueTypeRequirement"
env:"GITHUB_ISSUE_TYPE_REQUIREMENT" json:"issueTypeRequirement"`
+type GithubConnection struct {
+ helper.RestConnection `mapstructure:",squash"`
+ Auth string `mapstructure:"auth" validate:"required"
json:"auth"`
+ Config `mapstructure:",squash"`
}
-// This object conforms to what the frontend currently expects.
-type GithubResponse struct {
- Name string `json:"name"`
- ID int `json:"id"`
+type Config struct {
Review Comment:
These are `TransformationRules` in the new user flow, we don't need to save
them with connection anymore.
They will be passed in by `task.options` in the new user flow
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]