filters

package
v0.25.4 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const CustomRulesFilterName = "custom-rules"

Variables

View Source
var (
	PresetNameSeparator = "---preset---"
)

Functions

This section is empty.

Types

type Filter

type Filter struct {
	Name        string        `validate:"required" yaml:"-"`
	Title       string        `validate:"required"`
	Params      []FilterParam `validate:"dive" yaml:",omitempty"`
	Tags        []string      `validate:"dive,alphaunicode" yaml:",omitempty"`
	Template    string        `validate:"required"`
	Description string        `validate:"required" yaml:"-"`
	// contains filtered or unexported fields
}

func (*Filter) HasTag

func (f *Filter) HasTag(tag string) bool

type FilterAndTests

type FilterAndTests struct {
	Filter `yaml:"a,inline"`
	Tests  []testCase
}

type FilterParam

type FilterParam struct {
	Name        string      `validate:"required"`
	Description string      `validate:"required"`
	Link        string      `validate:"omitempty,url" yaml:",omitempty"`
	Type        ParamType   `validate:"required,oneof=checkbox string list multiline"`
	OnlyIf      string      `validate:"omitempty,valid_only_if" yaml:",omitempty"`
	Default     interface{} `validate:"valid_default"`
	Presets     []Preset    `validate:"omitempty,preset_allowed,dive" yaml:",omitempty"`
}

func (*FilterParam) BuildPresetParamName

func (p *FilterParam) BuildPresetParamName(preset string) string

type Instance

type Instance struct {
	Filter   string                 `yaml:"filter" validate:"required"`
	Params   map[string]interface{} `yaml:"params,omitempty"`
	TestMode bool                   `yaml:"test_mode,omitempty"`
}

func (*Instance) Render

func (i *Instance) Render(out io.Writer, repo repository) error

type List

type List struct {
	Title     string      `yaml:"title" validate:"required"`
	Instances []*Instance `yaml:"instances" validate:"dive,required"`
	TestMode  bool        `yaml:"test_mode,omitempty"`
}

func (*List) Render

func (l *List) Render(out io.Writer, logger logger, repo repository) error

func (*List) Validate

func (l *List) Validate() error

type ParamType

type ParamType string
const (
	BooleanParam    ParamType = "checkbox"
	StringParam     ParamType = "string"
	StringListParam ParamType = "list"
	MultiLineParam  ParamType = "multiline"
)

type Preset

type Preset struct {
	Name        string   `validate:"required"`
	Description string   `validate:"required"`
	Source      string   `validate:"omitempty,url" yaml:",omitempty"`
	Values      []string `validate:"required"`
	Default     bool     `yaml:",omitempty"`
}

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

Repository holds parsed Filters ready for use

func LoadFilters

func LoadFilters(input fs.FS) (*Repository, error)

LoadFilters parses all filter definitions in the given filesystem

func (*Repository) GetFilter

func (r *Repository) GetFilter(name string) (*Filter, error)

func (*Repository) GetFilters

func (r *Repository) GetFilters() []*Filter

func (*Repository) GetTags

func (r *Repository) GetTags() []string

func (*Repository) Render

func (r *Repository) Render(w io.Writer, instance *Instance) error

type TestModeTransformer added in v0.21.0

type TestModeTransformer struct {
	// contains filtered or unexported fields
}

func NewTestModeTransformer added in v0.21.0

func NewTestModeTransformer(out io.Writer) *TestModeTransformer

func (*TestModeTransformer) Write added in v0.21.0

func (t *TestModeTransformer) Write(p []byte) (int, error)

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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