Documentation
¶
Overview ¶
Package plugin/sdk provides helper types and functions for building ScrapeGoat plugins using the init() registration pattern.
Index ¶
- type BasePlugin
- func (p *BasePlugin) Close() error
- func (p *BasePlugin) GetBool(key string, defaultVal bool) bool
- func (p *BasePlugin) GetInt(key string, defaultVal int) int
- func (p *BasePlugin) GetString(key, defaultVal string) string
- func (p *BasePlugin) Init(cfg map[string]any) error
- func (p *BasePlugin) Name() string
- func (p *BasePlugin) Version() string
- type FilterMiddleware
- type ItemFilter
- type ItemTransform
- type TransformMiddleware
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BasePlugin ¶
type BasePlugin struct {
PluginName string
PluginType string
PluginVersion string
Config map[string]any
Logger *slog.Logger
}
BasePlugin provides a default implementation for the Plugin interface that plugin authors can embed to reduce boilerplate.
func (*BasePlugin) GetBool ¶
func (p *BasePlugin) GetBool(key string, defaultVal bool) bool
GetBool extracts a boolean config value with a default.
func (*BasePlugin) GetInt ¶
func (p *BasePlugin) GetInt(key string, defaultVal int) int
GetInt extracts an integer config value with a default.
func (*BasePlugin) GetString ¶
func (p *BasePlugin) GetString(key, defaultVal string) string
GetString extracts a string config value with a default.
func (*BasePlugin) Init ¶
func (p *BasePlugin) Init(cfg map[string]any) error
Init stores config and is a no-op by default.
func (*BasePlugin) Version ¶
func (p *BasePlugin) Version() string
Version returns the plugin version.
type FilterMiddleware ¶
type FilterMiddleware struct {
FilterFn ItemFilter
PluginName string
}
FilterMiddleware creates a pipeline middleware from a filter function.
func (*FilterMiddleware) Name ¶
func (m *FilterMiddleware) Name() string
Name returns the middleware name.
type ItemFilter ¶
ItemFilter is a function that returns true to keep an item.
type ItemTransform ¶
ItemTransform is a function that modifies an item in place.
type TransformMiddleware ¶
type TransformMiddleware struct {
TransformFn ItemTransform
PluginName string
}
TransformMiddleware creates a pipeline middleware from a transform function.
func (*TransformMiddleware) Name ¶
func (m *TransformMiddleware) Name() string
Name returns the middleware name.