Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AssetTranslator = commonTranslator{ // contains filtered or unexported fields }
AssetTranslator global ID resource
var CheckTranslator = commonTranslator{ // contains filtered or unexported fields }
CheckTranslator global ID resource
var ClusterRoleBindingTranslator = commonTranslator{ // contains filtered or unexported fields }
ClusterRoleBindingTranslator global ID resource
var ClusterRoleTranslator = commonTranslator{ // contains filtered or unexported fields }
ClusterRoleTranslator global ID resource
var EntityTranslator = commonTranslator{ // contains filtered or unexported fields }
EntityTranslator global ID resource
var EventTranslator = commonTranslator{ // contains filtered or unexported fields }
EventTranslator global ID resource
var HandlerTranslator = commonTranslator{ // contains filtered or unexported fields }
HandlerTranslator global ID resource
var HookTranslator = commonTranslator{ // contains filtered or unexported fields }
HookTranslator global ID resource
var Lookup = register.Lookup
Lookup given ID components return applicable encoder
var MutatorTranslator = commonTranslator{ // contains filtered or unexported fields }
MutatorTranslator global ID resource
var NamespaceTranslator = commonTranslator{ // contains filtered or unexported fields }
NamespaceTranslator global ID resource
var ReverseLookup = register.ReverseLookup
ReverseLookup finds Encoder capable of encoding record as global ID
var RoleBindingTranslator = commonTranslator{ // contains filtered or unexported fields }
RoleBindingTranslator global ID resource
var RoleTranslator = commonTranslator{ // contains filtered or unexported fields }
RoleTranslator global ID resource
var SilenceTranslator = commonTranslator{ // contains filtered or unexported fields }
SilenceTranslator global ID resource
var UserTranslator = commonTranslator{ // contains filtered or unexported fields }
UserTranslator global ID resource
Functions ¶
This section is empty.
Types ¶
type Components ¶
type Components interface { // Resource definition associated with this ID. Resource() string // Namespace is the name of the namespace the resource belongs to. Namespace() string // ResourceType is a optional element that describes any sort of sub-type of // the resource. ResourceType() string // UniqueComponent is a string that uniquely identify a resource; often times // this is the resource's name. UniqueComponent() string // String return string representation of ID String() string }
Components describes the components of a global identifier.
When represented as a string the ID appears in the follwoing format, parens denote optional components.
srn:resource:(?ns:)(?resourceType/)uniqueComponents
Example global IDs
srn:entities:default:default:selene.local srn:events:sales:prod:check/aG93ZHkgYnVkCg== srn:checks:auto:staging:disk-full srn:users:deanlearner
func Decode ¶
func Decode(gid string) (Components, error)
Decode parses, looks up decoder & decodes given ID.
type Decoder ¶
type Decoder interface {
Decode(StandardComponents) Components
}
A Decoder can decode global IDs for a specific resource
type Encoder ¶
type Encoder interface { IsResponsible(interface{}) bool Encode(interface{}) Components EncodeToString(interface{}) string }
An Encoder can encode global IDs for a specific resource
type EventComponents ¶
type EventComponents struct { StandardComponents // contains filtered or unexported fields }
EventComponents adds methods to easily access unique elements of event.
func NewEventComponents ¶
func NewEventComponents(components StandardComponents) EventComponents
NewEventComponents instantiates new EventComponents composite.
func (*EventComponents) CheckName ¶
func (n *EventComponents) CheckName() string
CheckName method returns second element of global ID's uniqueComponents IF the event is associated with a check otherwise returns an empty string.
func (*EventComponents) EntityName ¶
func (n *EventComponents) EntityName() string
EntityName method returns first element of global ID's uniqueComponents.
func (*EventComponents) MetricID ¶
func (n *EventComponents) MetricID() string
MetricID method returns second element of global ID's uniqueComponents IF the event is associated with a metric otherwise returns an empty string.
type NamedComponents ¶
type NamedComponents struct{ StandardComponents }
NamedComponents adds Name method that returns first element of global ID's uniqueComponents.
func (NamedComponents) Name ¶
func (n NamedComponents) Name() string
Name method returns first element of global ID's uniqueComponents. Congurent with most Sensu records Check#Name, Entity#ID, Asset#name, etc.
type Register ¶
type Register struct { Logger logrus.FieldLogger // contains filtered or unexported fields }
A Register holds resource definitions for easy lookup
func (Register) Lookup ¶
func (r Register) Lookup(components StandardComponents) (Decoder, error)
Lookup given ID components return applicable encoder
func (Register) ReverseLookup ¶
ReverseLookup finds Encoder capable of encoding record as global ID
type Registrar ¶
type Registrar struct { Logger logrus.FieldLogger // contains filtered or unexported fields }
A Registrar is used to register new resources
func NewRegistrar ¶
NewRegistrar instatiates new registrar.
func (*Registrar) Add ¶
func (registrar *Registrar) Add(translator Translator)
Add resource to global ID register
type StandardComponents ¶
type StandardComponents struct {
// contains filtered or unexported fields
}
StandardComponents describes the standard components of a global identifier.
func Parse ¶
func Parse(gid string) (StandardComponents, error)
Parse takes a global ID string, decodes it and returns it's components.
func (StandardComponents) Namespace ¶
func (id StandardComponents) Namespace() string
Namespace is the name of the namespace the resource belongs to.
func (StandardComponents) Resource ¶
func (id StandardComponents) Resource() string
Resource definition associated with this ID.
func (StandardComponents) ResourceType ¶
func (id StandardComponents) ResourceType() string
ResourceType is a optional element that describes any sort of sub-type of the resource.
func (StandardComponents) String ¶
func (id StandardComponents) String() string
String returns the string representation of the global ID.
func (StandardComponents) UniqueComponent ¶
func (id StandardComponents) UniqueComponent() string
UniqueComponent is a string that uniquely identify a resource; often times this is the resource's name.
type Translator ¶
A Translator represents something that is globally identifable