(extraEnv map[string]interface{}, events ...string)
| 164 | } |
| 165 | |
| 166 | func ExecutePluginHookWithContext(extraEnv map[string]interface{}, events ...string) error { |
| 167 | if len(plugins) == 0 { |
| 168 | return nil |
| 169 | } |
| 170 | |
| 171 | // apply global plugin context |
| 172 | newEnv := map[string]string{} |
| 173 | pluginContextLock.Lock() |
| 174 | for k, v := range pluginContext { |
| 175 | newEnv[k] = v |
| 176 | } |
| 177 | pluginContextLock.Unlock() |
| 178 | |
| 179 | // apply extra context |
| 180 | convertedExtraEnv := ConvertExtraEnv("DEVSPACE_PLUGIN", extraEnv) |
| 181 | for k, v := range convertedExtraEnv { |
| 182 | newEnv[k] = v |
| 183 | } |
| 184 | |
| 185 | for _, plugin := range plugins { |
| 186 | for _, e := range events { |
| 187 | newEnv["DEVSPACE_PLUGIN_EVENT"] = e |
| 188 | err := executePluginHookAt(plugin, e, newEnv) |
| 189 | if err != nil { |
| 190 | return err |
| 191 | } |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | return nil |
| 196 | } |
| 197 | |
| 198 | func ConvertExtraEnv(base string, extraEnv map[string]interface{}) map[string]string { |
| 199 | out := map[string]string{} |
no test coverage detected