EvanLjp commented on a change in pull request #12:
URL:
https://github.com/apache/skywalking-satellite/pull/12#discussion_r551287078
##########
File path: internal/pkg/plugin/definition.go
##########
@@ -53,14 +55,16 @@ type Config map[string]interface{}
// GetPluginName returns a plugin name generated by the packages.
// Recommended plugin directory structure:
plugins/{plugin-category}/{plugin-name}, so the generated names is
{plugin-name}-{plugin-category}.
func GetPluginName(p Plugin) string {
- nameParts := 2
t := reflect.TypeOf(p)
if t.Kind() == reflect.Ptr {
t = t.Elem()
}
- arr := strings.Split(t.PkgPath(), "/")
- if len(arr) < nameParts {
- return ""
+ path := t.PkgPath()
+ path = path[strings.LastIndex(path, PluginDir)+len(PluginDir)+1:]
+ arr := strings.Split(path, "/")
+ if len(arr) > 1 {
+ category := arr[0]
+ return strings.Join(arr[1:], "-") + "-" + category
Review comment:
The directory structure is an effective way to avoid duplication of
plug-in names, and we recommend this util, but it is not mandatory
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]