globalid

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, + 2 more Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AssetTranslator = commonTranslator{
	// contains filtered or unexported fields
}

AssetTranslator global ID resource

View Source
var CheckTranslator = commonTranslator{
	// contains filtered or unexported fields
}

CheckTranslator global ID resource

View Source
var ClusterRoleBindingTranslator = commonTranslator{
	// contains filtered or unexported fields
}

ClusterRoleBindingTranslator global ID resource

View Source
var ClusterRoleTranslator = commonTranslator{
	// contains filtered or unexported fields
}

ClusterRoleTranslator global ID resource

View Source
var EntityTranslator = commonTranslator{
	// contains filtered or unexported fields
}

EntityTranslator global ID resource

View Source
var EventTranslator = commonTranslator{
	// contains filtered or unexported fields
}

EventTranslator global ID resource

View Source
var HandlerTranslator = commonTranslator{
	// contains filtered or unexported fields
}

HandlerTranslator global ID resource

View Source
var HookTranslator = commonTranslator{
	// contains filtered or unexported fields
}

HookTranslator global ID resource

View Source
var Lookup = register.Lookup

Lookup given ID components return applicable encoder

View Source
var MutatorTranslator = commonTranslator{
	// contains filtered or unexported fields
}

MutatorTranslator global ID resource

View Source
var NamespaceTranslator = commonTranslator{
	// contains filtered or unexported fields
}

NamespaceTranslator global ID resource

View Source
var ReverseLookup = register.ReverseLookup

ReverseLookup finds Encoder capable of encoding record as global ID

View Source
var RoleBindingTranslator = commonTranslator{
	// contains filtered or unexported fields
}

RoleBindingTranslator global ID resource

View Source
var RoleTranslator = commonTranslator{
	// contains filtered or unexported fields
}

RoleTranslator global ID resource

View Source
var SilenceTranslator = commonTranslator{
	// contains filtered or unexported fields
}

SilenceTranslator global ID resource

View Source
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 NewRegister

func NewRegister() Register

NewRegister instatiates new register.

func (Register) Lookup

func (r Register) Lookup(components StandardComponents) (Decoder, error)

Lookup given ID components return applicable encoder

func (Register) ReverseLookup

func (r Register) ReverseLookup(record interface{}) (Encoder, error)

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

func NewRegistrar(register Register) Registrar

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

type Translator interface {
	ForResourceNamed() string
	Encoder
	Decoder
}

A Translator represents something that is globally identifable

Jump to

Keyboard shortcuts

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