diff --git a/interfaces/model_plugin.go b/interfaces/model_plugin.go index a2d390a..438192c 100644 --- a/interfaces/model_plugin.go +++ b/interfaces/model_plugin.go @@ -4,6 +4,8 @@ type Plugin interface { Model GetName() (name string) SetName(name string) + GetShortName() (shortName string) + SetShortName(shortName string) GetFullName() (fullName string) SetFullName(fullName string) GetInstallUrl() (url string) diff --git a/models/models/plugin.go b/models/models/plugin.go index 6aa9383..87bf32e 100644 --- a/models/models/plugin.go +++ b/models/models/plugin.go @@ -9,6 +9,7 @@ import ( type Plugin struct { Id primitive.ObjectID `json:"_id" bson:"_id"` Name string `json:"name" bson:"name"` + ShortName string `json:"short_name" bson:"short_name"` FullName string `json:"full_name" bson:"full_name"` Description string `json:"description" bson:"description"` Proto string `json:"proto" bson:"proto"` @@ -45,6 +46,14 @@ func (p *Plugin) SetName(name string) { p.Name = name } +func (p *Plugin) GetShortName() (shortName string) { + return p.ShortName +} + +func (p *Plugin) SetShortName(shortName string) { + p.ShortName = shortName +} + func (p *Plugin) GetFullName() (fullName string) { return p.FullName } diff --git a/plugin/service.go b/plugin/service.go index 24d1068..2bda1e0 100644 --- a/plugin/service.go +++ b/plugin/service.go @@ -34,6 +34,7 @@ import ( "io/ioutil" "os" "os/exec" + "path" "path/filepath" "runtime" "strings" @@ -356,7 +357,7 @@ func (svc *Service) installPublic(p interfaces.Plugin) (err error) { p.SetInstallUrl(fmt.Sprintf("%s/%s", constants.DefaultSettingPluginBaseUrl, p.GetFullName())) return svc.installRemote(p) } else { - p.SetInstallUrl(fmt.Sprintf("%s/%s", svc.ps.PluginBaseUrl, p.GetFullName())) + p.SetInstallUrl(fmt.Sprintf("%s/%s", svc.ps.PluginBaseUrl, p.GetShortName())) return svc.installGit(p) } } @@ -454,7 +455,8 @@ func (svc *Service) installRemote(p interfaces.Plugin) (err error) { return trace.TraceError(err) } pluginPath := filepath.Join(os.TempDir(), uuid.New().String()) - if err := ioutil.WriteFile(pluginPath, res.Bytes(), os.FileMode(0666)); err != nil { + _ = os.MkdirAll(pluginPath, os.FileMode(0766)) + if err := ioutil.WriteFile(path.Join(pluginPath, "plugin.json"), res.Bytes(), os.FileMode(0766)); err != nil { return trace.TraceError(err) } diff --git a/utils/docker.go b/utils/docker.go index f4b26d9..cadccb6 100644 --- a/utils/docker.go +++ b/utils/docker.go @@ -3,5 +3,7 @@ package utils import "github.com/spf13/viper" func IsDocker() (ok bool) { - return viper.GetBool("docker") + isDockerBool := viper.GetBool("docker") + isDockerString := viper.GetString("docker") + return isDockerBool || isDockerString == "Y" }