MCPcopy Index your code
hub / github.com/devspace-sh/devspace / ConvertExtraEnv

Function ConvertExtraEnv

pkg/devspace/plugin/hook.go:198–222  ·  view source on GitHub ↗
(base string, extraEnv map[string]interface{})

Source from the content-addressed store, hash-verified

196}
197
198func 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
224func ExecutePluginHookAt(plugin Metadata, events ...string) error {
225 for _, e := range events {

Callers 3

LogExecuteHooksFunction · 0.92
ExecuteHooksFunction · 0.92

Calls 2

ConvertFunction · 0.92
logErrorfFunction · 0.85

Tested by

no test coverage detected