Fix shadowed variables in various places: Part 1 of 2 (#10175)
* Fix shadowed variables in cmd package * Fix shadowed variables in plugin package * Fix shadowed variables in store package * Fix shadowed variables in web package * Changes as requested Signed-off-by: Hanzei <hanzei@mailbox.org> * Fix build * Remove unnessary statements * Use require all the time * Fix build * Rename variables according to feedback * Fix NPE * Changes as requested
Этот коммит содержится в:
коммит произвёл
Jesse Hallam
родитель
2c9cf41dad
Коммит
d898787371
@@ -11,7 +11,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/go-plugin"
|
||||
plugin "github.com/hashicorp/go-plugin"
|
||||
"github.com/mattermost/mattermost-server/mlog"
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
)
|
||||
@@ -23,10 +23,10 @@ type supervisor struct {
|
||||
}
|
||||
|
||||
func newSupervisor(pluginInfo *model.BundleInfo, parentLogger *mlog.Logger, apiImpl API) (retSupervisor *supervisor, retErr error) {
|
||||
supervisor := supervisor{}
|
||||
sup := supervisor{}
|
||||
defer func() {
|
||||
if retErr != nil {
|
||||
supervisor.Shutdown()
|
||||
sup.Shutdown()
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -53,7 +53,7 @@ func newSupervisor(pluginInfo *model.BundleInfo, parentLogger *mlog.Logger, apiI
|
||||
}
|
||||
executable = filepath.Join(pluginInfo.Path, executable)
|
||||
|
||||
supervisor.client = plugin.NewClient(&plugin.ClientConfig{
|
||||
sup.client = plugin.NewClient(&plugin.ClientConfig{
|
||||
HandshakeConfig: handshake,
|
||||
Plugins: pluginMap,
|
||||
Cmd: exec.Command(executable),
|
||||
@@ -63,7 +63,7 @@ func newSupervisor(pluginInfo *model.BundleInfo, parentLogger *mlog.Logger, apiI
|
||||
StartTimeout: time.Second * 3,
|
||||
})
|
||||
|
||||
rpcClient, err := supervisor.client.Client()
|
||||
rpcClient, err := sup.client.Client()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -73,24 +73,24 @@ func newSupervisor(pluginInfo *model.BundleInfo, parentLogger *mlog.Logger, apiI
|
||||
return nil, err
|
||||
}
|
||||
|
||||
supervisor.hooks = raw.(Hooks)
|
||||
sup.hooks = raw.(Hooks)
|
||||
|
||||
if impl, err := supervisor.hooks.Implemented(); err != nil {
|
||||
impl, err := sup.hooks.Implemented()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
for _, hookName := range impl {
|
||||
if hookId, ok := hookNameToId[hookName]; ok {
|
||||
supervisor.implemented[hookId] = true
|
||||
}
|
||||
}
|
||||
for _, hookName := range impl {
|
||||
if hookId, ok := hookNameToId[hookName]; ok {
|
||||
sup.implemented[hookId] = true
|
||||
}
|
||||
}
|
||||
|
||||
err = supervisor.Hooks().OnActivate()
|
||||
err = sup.Hooks().OnActivate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &supervisor, nil
|
||||
return &sup, nil
|
||||
}
|
||||
|
||||
func (sup *supervisor) Shutdown() {
|
||||
|
||||
Ссылка в новой задаче
Block a user