Skip to content

Commit

Permalink
fixed unable to start plugins issue
Browse files Browse the repository at this point in the history
  • Loading branch information
tikazyq committed Jun 2, 2022
1 parent 4e55fbf commit 3f3b40f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions interfaces/model_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions models/models/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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
}
Expand Down
6 changes: 4 additions & 2 deletions plugin/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"io/ioutil"
"os"
"os/exec"
"path"
"path/filepath"
"runtime"
"strings"
Expand Down Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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)
}

Expand Down
4 changes: 3 additions & 1 deletion utils/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 3f3b40f

Please sign in to comment.