Bladeren bron

plugins: fix load plugins issue (#495)

jinfahua 4 jaren geleden
bovenliggende
commit
5b607db509
2 gewijzigde bestanden met toevoegingen van 10 en 4 verwijderingen
  1. 1 1
      common/util.go
  2. 9 3
      xstream/server/server/rest.go

+ 1 - 1
common/util.go

@@ -67,7 +67,7 @@ type KuiperConf struct {
 		RestTls        *tlsConf `yaml:"restTls"`
 		Prometheus     bool     `yaml:"prometheus"`
 		PrometheusPort int      `yaml:"prometheusPort"`
-		PluginHosts    string   `yaml:pluginHosts`
+		PluginHosts    string   `yaml:"pluginHosts"`
 	}
 	Rule api.RuleOption
 	Sink struct {

+ 9 - 3
xstream/server/server/rest.go

@@ -452,7 +452,13 @@ func prebuildPluginsHandler(w http.ResponseWriter, r *http.Request, t plugins.Pl
 			return
 		}
 		prettyName := strings.ToUpper(osrelease["PRETTY_NAME"])
-		if strings.Contains(prettyName, "ALPINE") || strings.Contains(prettyName, "DEBIAN") {
+		alpine := strings.Contains(prettyName, "ALPINE")
+		debian := strings.Contains(prettyName, "DEBIAN")
+		os := "alpine"
+		if debian {
+			os = "debian"
+		}
+		if alpine || debian {
 			hosts := common.Config.Basic.PluginHosts
 			ptype := "sources"
 			if t == plugins.SINK {
@@ -460,7 +466,7 @@ func prebuildPluginsHandler(w http.ResponseWriter, r *http.Request, t plugins.Pl
 			} else if t == plugins.FUNCTION {
 				ptype = "functions"
 			}
-			if err, plugins := fetchPluginList(hosts, ptype, strings.ToLower(prettyName), runtime.GOARCH); err != nil {
+			if err, plugins := fetchPluginList(hosts, ptype, os, runtime.GOARCH); err != nil {
 				handleError(w, err, "", logger)
 			} else {
 				jsonResponse(plugins, w, logger)
@@ -476,7 +482,7 @@ func prebuildPluginsHandler(w http.ResponseWriter, r *http.Request, t plugins.Pl
 
 func fetchPluginList(hosts, ptype, os, arch string) (err error, result map[string]string) {
 	if hosts == "" || ptype == "" || os == "" {
-		return fmt.Errorf("Invalid parameter value: hosts, ptype and os value should not be empty."), nil
+		return fmt.Errorf("Invalid parameter value: hosts %s, ptype %s or os: %s should not be empty.", hosts, ptype, os), nil
 	}
 	result = make(map[string]string)
 	hostsArr := strings.Split(hosts, ",")