This is an automated email from the ASF dual-hosted git repository.
ka94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/main by this push:
new 9cb522b09 fix: Fix wrong package name in domain ids (#4973)
9cb522b09 is described below
commit 9cb522b0955adc1623f4f089655b77d3a503ec9a
Author: Camille Teruel <[email protected]>
AuthorDate: Wed Apr 19 20:43:09 2023 +0200
fix: Fix wrong package name in domain ids (#4973)
RootPkgPath is used by DomainIdGenerator to find the name of the plugin
that defines a given type.
While remote plugins do not use the DomainIdGenerator, we still need to
implement this function.
Indeed, DomainIdGenerator uses FindPluginNameBySubPkgPath that returns the
name of the first plugin
whose RootPkgPath is a prefix of the type package path.
So remote plugin must not return an empty string as RootPkgPath, but a
string that is not a prefix
of any go plugin package path.
Co-authored-by: Camille Teruel <[email protected]>
---
backend/server/services/remote/plugin/plugin_impl.go | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/backend/server/services/remote/plugin/plugin_impl.go
b/backend/server/services/remote/plugin/plugin_impl.go
index 6b1d95390..8790bd634 100644
--- a/backend/server/services/remote/plugin/plugin_impl.go
+++ b/backend/server/services/remote/plugin/plugin_impl.go
@@ -164,11 +164,12 @@ func (p *remotePluginImpl) Description() string {
}
func (p *remotePluginImpl) RootPkgPath() string {
- // RootPkgPath is only used to find to which plugin a given type
belongs.
- // This in turn is only used by DomainIdGenerator.
- // Remote plugins define tool layer types in another language,
- // so the reflective implementation of NewDomainIdGenerator cannot work.
- return ""
+ // RootPkgPath is used by DomainIdGenerator to find the name of the
plugin that defines a given type.
+ // While remote plugins do not use the DomainIdGenerator, we still need
to implement this function.
+ // Indeed, DomainIdGenerator uses FindPluginNameBySubPkgPath that
returns the name of the first plugin
+ // whose RootPkgPath is a prefix of the type package path.
+ // So we forge a fake package path that is not a prefix of any go
plugin package path.
+ return
"github.com/apache/incubator-devlake/services/remote/fakepackages/" + p.name
}
func (p *remotePluginImpl) ApiResources()
map[string]map[string]plugin.ApiResourceHandler {