(base string, extraEnv map[string]interface{})
| 196 | } |
| 197 | |
| 198 | func ConvertExtraEnv(base string, extraEnv map[string]interface{}) map[string]string { |
| 199 | out := map[string]string{} |
| 200 | for k, v := range extraEnv { |
| 201 | if v == nil { |
| 202 | continue |
| 203 | } |
| 204 | |
| 205 | k = strings.TrimSpace(strings.ToUpper(base + "_" + k)) |
| 206 | switch t := v.(type) { |
| 207 | case string: |
| 208 | out[k] = t |
| 209 | case int: |
| 210 | out[k] = fmt.Sprintf("%d", t) |
| 211 | case error: |
| 212 | out[k] = fmt.Sprintf("%v", t) |
| 213 | default: |
| 214 | outBytes, err := json.Marshal(yamlutil.Convert(t)) |
| 215 | if err != nil { |
| 216 | logErrorf("error marshal extra env %s: %v", k, err) |
| 217 | } |
| 218 | out[k] = string(outBytes) |
| 219 | } |
| 220 | } |
| 221 | return out |
| 222 | } |
| 223 | |
| 224 | func ExecutePluginHookAt(plugin Metadata, events ...string) error { |
| 225 | for _, e := range events { |
no test coverage detected