func()

in api/internal/handler/schema/plugin.go [47:79]


func (h *Handler) Plugins(c droplet.Context) (interface{}, error) {
	input := c.Input().(*ListInput)

	plugins := conf.Schema.Get("plugins")
	if input.All {
		var res []map[string]interface{}
		list := plugins.Value().(map[string]interface{})
		for name, schemaConfig := range list {
			if enable, ok := conf.Plugins[name]; !ok || !enable {
				continue
			}
			plugin := schemaConfig.(map[string]interface{})
			plugin["name"] = name
			if _, ok := plugin["type"]; !ok {
				plugin["type"] = "other"
			}
			res = append(res, plugin)
		}
		return res, nil
	}

	var ret []string
	list := plugins.Map()
	for pluginName := range list {
		if enable, ok := conf.Plugins[pluginName]; !ok || !enable {
			continue
		}

		ret = append(ret, pluginName)
	}

	return ret, nil
}