suggest

package
v5.10.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2019 License: MIT, MIT, MIT, + 1 more Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NameField = &CustomField{
		Name: "name",
		FieldFunc: func(res v2.Resource) []string {
			return []string{res.GetObjectMeta().Name}
		},
	}
	LabelsField = &MapField{
		Name: "labels",
		FieldFunc: func(res v2.Resource) map[string]string {
			return res.GetObjectMeta().Labels
		},
	}
)
View Source
var (
	ErrInvalidRef = errors.New("reference to field must take the form :group/:version/:resource/:field/:name")
)

Functions

This section is empty.

Types

type CustomField

type CustomField struct {
	Name      string
	FieldFunc func(v2.Resource) []string
}

func (*CustomField) Matches

func (f *CustomField) Matches(path string) bool

func (*CustomField) Value

func (f *CustomField) Value(res v2.Resource, path string) []string

type Field

type Field interface {
	Matches(string) bool
	Value(v2.Resource, string) []string
}

type MapField

type MapField struct {
	Name      string
	FieldFunc func(v2.Resource) map[string]string
}

func (*MapField) Matches

func (f *MapField) Matches(path string) bool

func (*MapField) Value

func (f *MapField) Value(res v2.Resource, path string) []string

type ObjectField

type ObjectField struct {
	Name   string
	Fields []Field
}

func (*ObjectField) Matches

func (f *ObjectField) Matches(path string) bool

func (*ObjectField) Value

func (f *ObjectField) Value(res v2.Resource, path string) []string

type RefComponents

type RefComponents struct {
	Group     string
	Name      string
	FieldPath string
}

func ParseRef

func ParseRef(ref string) (r RefComponents, err error)

ParseRef takes an identifier and returns it's components.

func (RefComponents) String

func (r RefComponents) String() string

String prints the identifier

type Register

type Register []*Resource

Register is used to store and later find Sensu resources

func (Register) Lookup

func (r Register) Lookup(ref RefComponents) *Resource

Lookup finds a Resource given a ref

type Resource

type Resource struct {
	Group  string
	Name   string
	Path   string
	Fields []Field
}

Resource represents a Sensu resource

func (*Resource) LookupField

func (r *Resource) LookupField(ref RefComponents) Field

LookupField uses given ref to find the appropriate field.

func (*Resource) URIPath

func (r *Resource) URIPath(ns string) string

URIPath given a namespace returns the API path used to get/list/put/delete the resource.

Jump to

Keyboard shortcuts

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