Change plugin collect env format

This commit is contained in:
710leo 2020-05-29 16:41:33 +08:00
parent 0d2860dd8e
commit a727a7f377
1 changed files with 4 additions and 3 deletions

View File

@ -3,6 +3,7 @@ package plugins
import ( import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"strings" "strings"
@ -72,14 +73,14 @@ func PluginRun(plugin *Plugin) {
} }
if plugin.Env != "" { if plugin.Env != "" {
envs := []string{} envs := make(map[string]string)
err := json.Unmarshal([]byte(plugin.Env), &envs) err := json.Unmarshal([]byte(plugin.Env), &envs)
if err != nil { if err != nil {
logger.Errorf("plugin:%+v %v", plugin, err) logger.Errorf("plugin:%+v %v", plugin, err)
return return
} }
for _, env := range envs { for k, v := range envs {
cmd.Env = append(cmd.Env, env) cmd.Env = append(cmd.Env, fmt.Sprintf("%s=%s", k, v))
} }
} }