plugin

package
v0.0.0-...-53c5c15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {
	Extractor string
	Section   string
	Field     string
}

Field holds (previously) flattened metadata for an <extractor>.<section>.<field>

func ParseField

func ParseField(field string) (Field, error)

parseField parses a flattened <extractor>.<section>.<field> into components

type PluginData

type PluginData struct {
	Sections Sections `json:"sections,omitempty"`
}

ExtractorData is returned by an extractor

func (*PluginData) Print

func (e *PluginData) Print()

Print extractor data to the console

func (*PluginData) ToJson

func (e *PluginData) ToJson() (string, error)

ToJson serializes to json

type PluginInterface

type PluginInterface interface {
	Name() string
	Description() string

	// This is probably a dumb way to do it, but it works
	IsExtractor() bool
	IsCreator() bool

	// Extractors
	Extract(bool) (PluginData, error)
	Validate() bool
	Sections() []string

	// Creators take a map of named options
	Create(PluginOptions) error
}

A Plugin interface can define any of the following:

an Extract function to return extractor data across sections
a validate function to typically check that the plugin is valid
a Creation interface that can use extractor data to generate something new

type PluginOptions

type PluginOptions struct {
	BoolOpts map[string]bool
	StrOpts  map[string]string
	IntOpts  map[string]int32
	ListOpts map[string][]string
}

PluginOptions allow packaging named values of different types This is an alternative to using interfaces.

type PluginSection

type PluginSection map[string]string

An extractor section corresponds to a named group of attributes

type Plugins

type Plugins map[string]PluginInterface

Extractors is a lookup of registered extractors by name

type Result

type Result struct {
	Results map[string]PluginData `json:"results,omitempty"`
}

A Result wraps named extractor data, just for easy dumping to json

func (*Result) AddCustomFields

func (r *Result) AddCustomFields(fields []string)

AddCustomFields adds or updates an existing result with custom metadata, either new or to overwrite

func (*Result) Load

func (r *Result) Load(filename string) error

Load a filename into the result object!

func (*Result) Print

func (r *Result) Print()

Print prints the result to the terminal

func (*Result) ToJson

func (r *Result) ToJson() ([]byte, error)

ToJson serializes a result to json

type Sections

type Sections map[string]PluginSection

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL