ref

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: Apache-2.0 Imports: 10 Imported by: 16

Documentation

Index

Constants

View Source
const (
	// = Application
	PartOfLabel = "app.kubernetes.io/part-of"
)

Labels

View Source
const (
	Tag = "ref"
)

Variables

View Source
var (
	// Application identifier included in reference labels.
	// **Must set be by the using application.
	Application = ""
)

Functions

func Equals

func Equals(refA, refB *v1.ObjectReference) bool

Equals comparison. May be used with `nil` pointers.

func GetRequests

func GetRequests(kind string, a handler.MapObject) []reconcile.Request

Impl the handler interface.

func Handler

func Handler(owner interface{}) handler.EventHandler

Build an event handler. Example:

err = cnt.Watch(
   &source.Kind{
      Type: &api.Referenced{},
   },
   libref.Handler(&api.Owner{}))

func Label

func Label(object v1.Object) (label, uid string)

Build unique reference label for an object. Format: <kind> = <uid>

func Labels

func Labels(object v1.Object) map[string]string

Build reference labels for an object. Includes both `Application` and unique labels.

func RefSet

func RefSet(ref *v1.ObjectReference) bool

Determine if the ref is `set`. Must not be `nil` with Namespace and Name not "".

func ToKind

func ToKind(resource interface{}) string

Determine the resource Kind.

Types

type EventMapper

type EventMapper struct {
	Map *RefMap
}

Predicate Event Mapper All ObjectReference fields with the `ref` tag will be mapped.

Example (CRD):

type Resource struct {
    ThingRef *v1.ObjectReference `json:"thingRef" ref:"Thing"`
}

Example (usage):

func (p Predicate) Create(e event.CreateEvent) bool {
    ...
    ref.Mapper.Create(e)
}}
var Mapper *EventMapper

func (*EventMapper) Create

func (r *EventMapper) Create(event event.CreateEvent)

Create event.

func (*EventMapper) Delete

func (r *EventMapper) Delete(event event.DeleteEvent)

Delete Mapper.

func (*EventMapper) Update

func (r *EventMapper) Update(event event.UpdateEvent)

Update event.

type Owner

type Owner v1.ObjectReference

A resource that contains an ObjectReference.

type RefMap

type RefMap struct {
	Content map[Target]map[Owner]bool
	// contains filtered or unexported fields
}

A 1-n mapping of Target => [Owner, ...].

var Map *RefMap

Global

func (*RefMap) Add

func (r *RefMap) Add(owner Owner, target Target)

Add mapping of a ref-owner to a ref-target.

func (*RefMap) Delete

func (r *RefMap) Delete(owner Owner, target Target)

Delete mapping of a ref-owner to a ref-target.

func (*RefMap) DeleteOwner

func (r *RefMap) DeleteOwner(owner Owner)

Delete all mappings to an owner.

func (*RefMap) Find

func (r *RefMap) Find(target Target) []Owner

Find all owners mapped to the target.

func (*RefMap) Match

func (r *RefMap) Match(target Target, owner Owner) bool

Determine if target mapped to owner.

func (*RefMap) Prune

func (r *RefMap) Prune()

Prune empty mappings.

type Target

type Target v1.ObjectReference

The resource that is the target of an ObjectReference.

Jump to

Keyboard shortcuts

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