From 9810aef49d7d8080e8b0b59bf994268366ad57e2 Mon Sep 17 00:00:00 2001 From: Marvin Zhang Date: Fri, 3 Jun 2022 19:48:54 +0800 Subject: [PATCH] fixed unable to start plugins issue --- entity/public_plugin.go | 1 - models/models/plugin.go | 1 + plugin/service.go | 7 +++---- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/entity/public_plugin.go b/entity/public_plugin.go index 91669e0..3f6fe0c 100644 --- a/entity/public_plugin.go +++ b/entity/public_plugin.go @@ -3,7 +3,6 @@ package entity type PublicPlugin struct { Id int `json:"id"` Name string `json:"name"` - ShortName string `json:"short_name"` FullName string `json:"full_name"` Description string `json:"description"` HtmlUrl string `json:"html_url"` diff --git a/models/models/plugin.go b/models/models/plugin.go index 87bf32e..eb1f53a 100644 --- a/models/models/plugin.go +++ b/models/models/plugin.go @@ -17,6 +17,7 @@ type Plugin struct { Endpoint string `json:"endpoint" bson:"endpoint"` Cmd string `json:"cmd" bson:"cmd"` DockerCmd string `json:"docker_cmd" bson:"docker_cmd"` + DockerDir string `json:"docker_dir" bson:"docker_dir"` EventKey entity.PluginEventKey `json:"event_key" bson:"event_key"` InstallType string `json:"install_type" bson:"install_type"` InstallUrl string `json:"install_url" bson:"install_url"` diff --git a/plugin/service.go b/plugin/service.go index 9f8dc5c..bc6c3ec 100644 --- a/plugin/service.go +++ b/plugin/service.go @@ -354,7 +354,7 @@ func (svc *Service) GetPublicPluginInfo(fullName string) (res interface{}, err e func (svc *Service) installPublic(p interfaces.Plugin) (err error) { if utils.IsDocker() { - p.SetInstallUrl(fmt.Sprintf("%s/%s", constants.DefaultSettingPluginBaseUrl, p.GetShortName())) + p.SetInstallUrl(fmt.Sprintf("%s/%s", constants.DefaultSettingPluginBaseUrl, p.GetName())) return svc.installRemote(p) } else { p.SetInstallUrl(fmt.Sprintf("%s/%s", svc.ps.PluginBaseUrl, p.GetFullName())) @@ -527,13 +527,12 @@ func (svc *Service) getNewCmdFn(p *models.Plugin, fsSvc interfaces.PluginFsServi // command if utils.IsDocker() { cmd = sys_exec.BuildCmd(p.DockerCmd) + cmd.Dir = p.DockerDir } else { cmd = sys_exec.BuildCmd(p.Cmd) + cmd.Dir = fsSvc.GetWorkspacePath() } - // working directory - cmd.Dir = fsSvc.GetWorkspacePath() - // inherit system envs for _, env := range os.Environ() { cmd.Env = append(cmd.Env, env)