fix(framework): update code generator templates#2641
Merged
Conversation
5a869af to
ea841b3
Compare
likyh
requested changes
Aug 1, 2022
| token := taskCtx.GetConfig("{{ .PLUGIN_NAME }}_TOKEN") | ||
| if token == "" { | ||
| println("invalid {{ .PLUGIN_NAME }}_TOKEN, but ignore this error now") | ||
| import ( |
Contributor
There was a problem hiding this comment.
import duplicate with Line 20~25
| "strconv" | ||
| "time" | ||
|
|
||
| "github.com/apache/incubator-devlake/plugins/{{ .pluginName }}/models" |
| "github.com/apache/incubator-devlake/plugins/helper" | ||
| ) | ||
|
|
||
| func New{{ .PluginName }}ApiClient(taskCtx core.TaskContext, connection *models.{{ .PluginName }}Connection) (*helper.ApiAsyncClient, error) { |
Contributor
There was a problem hiding this comment.
Must the new plugin use the connection? Is there any simple way to deal with it?
| // read template | ||
| templates = map[string]string{ | ||
| `plugin_main.go`: util.ReadTemplate("generator/template/plugin/plugin_main_with_api_client.go-template"), | ||
| `impl/impl.go`: util.ReadTemplate("generator/template/plugin/impl/impl.go-template"), |
Contributor
There was a problem hiding this comment.
impl_with_api_client.go-template ?
| "github.com/apache/incubator-devlake/migration" | ||
| "github.com/apache/incubator-devlake/plugins/core" | ||
| "github.com/apache/incubator-devlake/plugins/helper" | ||
| "github.com/apache/incubator-devlake/plugins/{{ .plugin_name }}/api" |
Contributor
There was a problem hiding this comment.
there is no api/models/migrationscripts package
ea841b3 to
e854832
Compare
likyh
requested changes
Aug 1, 2022
| `tasks/api_client.go`: util.ReadTemplate("generator/template/plugin/tasks/api_client.go-template"), | ||
| `tasks/task_data.go`: util.ReadTemplate("generator/template/plugin/tasks/task_data_with_api_client.go-template"), | ||
| fmt.Sprintf(`%s.go`, pluginName): util.ReadTemplate("generator/template/plugin/plugin_main_with_api_client.go-template"), | ||
| `impl/impl.go`: util.ReadTemplate("generator/template/plugin/impl/impl_with_api_client.go-template"), |
Contributor
There was a problem hiding this comment.
| "github.com/apache/incubator-devlake/plugins/core" | ||
| "github.com/apache/incubator-devlake/plugins/{{ .plugin_name }}/api" | ||
| "github.com/apache/incubator-devlake/plugins/{{ .plugin_name }}/models" | ||
| "github.com/apache/incubator-devlake/plugins/{{ .plugin_name }}/models/migrationscripts" |
Contributor
There was a problem hiding this comment.
let's use a tab instead of 4 spaces.
| } | ||
|
|
||
| func ({{ .PluginName }}Connection) TableName() string { | ||
| return "_tool_{{ .plugin-name }}_connections" |
Contributor
There was a problem hiding this comment.
Instead of plugin-name, it should be plugin_name
| import ( | ||
| "github.com/apache/incubator-devlake/plugins/core" | ||
| "github.com/apache/incubator-devlake/plugins/{{ .pluginName }}/tasks" | ||
| "github.com/apache/incubator-devlake/plugins/{{ .PluginName }}/impl" |
| } | ||
|
|
||
| func (plugin {{ .PluginName }}) MakePipelinePlan(connectionId uint64, scope []*core.BlueprintScopeV100) (core.PipelinePlan, error) { | ||
| return api.MakePipelinePlan(plugin.SubTaskMetas(), connectionId, scope) |
Contributor
There was a problem hiding this comment.
where is the MakePipelinePlan?
|
|
||
| "github.com/apache/incubator-devlake/plugins/core" | ||
| "github.com/apache/incubator-devlake/plugins/helper" | ||
| "github.com/apache/incubator-devlake/plugins/{{ .plugin-name }}/tasks" |
|
|
||
| // PkgPath information lost when compiled as plugin(.so) | ||
| func (plugin {{ .PluginName }}) RootPkgPath() string { | ||
| return "github.com/apache/incubator-devlake/plugins/{{ .plugin-name }}" |
| } | ||
| plan[i] = core.PipelineStage{ | ||
| { | ||
| Plugin: "{{ .plugin-name }}", |
| @@ -0,0 +1,69 @@ | |||
| /* | |||
| @@ -112,30 +113,21 @@ Type in what the name of plugin is, then generator will create a new plugin in p | |||
| values := map[string]string{} | |||
| templates := map[string]string{} | |||
| if withApiClient == `Yes` { | |||
Contributor
There was a problem hiding this comment.
change withApiClient to generateCompletePlugin or other appropriate name?
561116d to
2c9050e
Compare
Contributor
|
LGTM |
2c9050e to
46713da
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #2640
Summary
modify templates in package generator
Does this close any open issues?
closes #2640
Screenshots
Other Information
Any other information that is important to this PR.