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