44 lines
1,006 B
Go
44 lines
1,006 B
Go
package makeshift
|
|
|
|
import (
|
|
"git.towk2.me/towk/makeshift/pkg/storage"
|
|
)
|
|
|
|
type ProfileMap map[string]*Profile
|
|
type Profile struct {
|
|
ID string `json:"id"` // profile ID
|
|
Description string `json:"description,omitempty"` // profile description
|
|
Tags []string `json:"tags,omitempty"` // tags used for ...
|
|
Data map[string]any `json:"data,omitempty"` // include render data
|
|
}
|
|
|
|
type Plugin interface {
|
|
Name() string
|
|
Version() string
|
|
Description() string
|
|
Metadata() Metadata
|
|
|
|
Init() error
|
|
Run(data storage.KVStore, args []string) error
|
|
Cleanup() error
|
|
}
|
|
type Metadata map[string]any
|
|
type Hook struct {
|
|
Data storage.KVStore
|
|
Args []string
|
|
Plugin Plugin
|
|
}
|
|
|
|
func (h *Hook) Run() error {
|
|
return h.Plugin.Run(h.Data, h.Args)
|
|
}
|
|
|
|
func PluginToMap(p Plugin) map[string]any {
|
|
return map[string]any{
|
|
"name": p.Name(),
|
|
"version": p.Version(),
|
|
"description": p.Description(),
|
|
"metadata": p.Metadata(),
|
|
}
|
|
|
|
}
|