(c *gin.Context)
| 329 | } |
| 330 | |
| 331 | func GetTaskPlugin(c *gin.Context) { |
| 332 | key := c.Param("key") |
| 333 | version := c.Query("version") |
| 334 | plugin, err := model.GetTaskPluginVersion(key, version) |
| 335 | if err == nil { |
| 336 | loaded, compileErr := jsplugin.NewRegistry().Register(plugin.Source, jsplugin.Options{Key: plugin.Key, Version: plugin.Version}) |
| 337 | if compileErr != nil { |
| 338 | common.ApiErrorMsg(c, compileErr.Error()) |
| 339 | return |
| 340 | } |
| 341 | common.ApiSuccess(c, taskPluginDetail{Plugin: plugin, Meta: loaded.Meta, Source: plugin.Source, Layer: "override", HasIcon: plugin.HasIcon()}) |
| 342 | return |
| 343 | } |
| 344 | if !errors.Is(err, gorm.ErrRecordNotFound) || version != "" { |
| 345 | common.ApiError(c, err) |
| 346 | return |
| 347 | } |
| 348 | source, err := plugins.Source(key) |
| 349 | if err != nil { |
| 350 | common.ApiErrorMsg(c, "task plugin not found") |
| 351 | return |
| 352 | } |
| 353 | loaded, err := jsplugin.NewRegistry().RegisterFactory(source, jsplugin.Options{Key: key}) |
| 354 | if err != nil { |
| 355 | common.ApiError(c, err) |
| 356 | return |
| 357 | } |
| 358 | _, _, hasIcon := plugins.Icon(key) |
| 359 | common.ApiSuccess(c, taskPluginDetail{Meta: loaded.Meta, Source: source, Layer: "factory", HasIcon: hasIcon}) |
| 360 | } |
| 361 | |
| 362 | type taskPluginDryRunRequest struct { |
| 363 | Hook string `json:"hook" binding:"required"` |
nothing calls this directly
no test coverage detected