(c *gin.Context)
| 278 | } |
| 279 | |
| 280 | func GetTaskPlugin(c *gin.Context) { |
| 281 | key := c.Param("key") |
| 282 | version := c.Query("version") |
| 283 | plugin, err := model.GetTaskPluginVersion(key, version) |
| 284 | if err == nil { |
| 285 | loaded, compileErr := jsplugin.NewRegistry().Register(plugin.Source, jsplugin.Options{Key: plugin.Key, Version: plugin.Version}) |
| 286 | if compileErr != nil { |
| 287 | common.ApiErrorMsg(c, compileErr.Error()) |
| 288 | return |
| 289 | } |
| 290 | common.ApiSuccess(c, taskPluginDetail{Plugin: plugin, Meta: loaded.Meta, Source: plugin.Source, Layer: "override"}) |
| 291 | return |
| 292 | } |
| 293 | if !errors.Is(err, gorm.ErrRecordNotFound) || version != "" { |
| 294 | common.ApiError(c, err) |
| 295 | return |
| 296 | } |
| 297 | source, err := plugins.Source(key) |
| 298 | if err != nil { |
| 299 | common.ApiErrorMsg(c, "task plugin not found") |
| 300 | return |
| 301 | } |
| 302 | loaded, err := jsplugin.NewRegistry().RegisterFactory(source, jsplugin.Options{Key: key}) |
| 303 | if err != nil { |
| 304 | common.ApiError(c, err) |
| 305 | return |
| 306 | } |
| 307 | common.ApiSuccess(c, taskPluginDetail{Meta: loaded.Meta, Source: source, Layer: "factory"}) |
| 308 | } |
| 309 | |
| 310 | type taskPluginDryRunRequest struct { |
| 311 | Hook string `json:"hook" binding:"required"` |
nothing calls this directly
no test coverage detected