identitymanager

package
v1.6.9 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package identitymanager tracks which global identities are being used by the currently running cilium-agent

Index

Constants

This section is empty.

Variables

View Source
var (
	// GlobalIdentityManager is a singleton instance of an IdentityManager, used
	// for easy updating / tracking lifecycles of identities on the local node
	// without having to pass around a specific instance of an IdentityManager
	// throughout Cilium.
	GlobalIdentityManager = NewIdentityManager()
)

Functions

func Add

func Add(identity *identity.Identity)

Add inserts the identity into the GlobalIdentityManager.

func GetIdentityModels

func GetIdentityModels() []*models.IdentityEndpoints

GetIdentityModels returns the API model of all identities in the GlobalIdentityManager.

func Remove

func Remove(identity *identity.Identity)

Remove deletes the identity from the GlobalIdentityManager.

func RemoveOldAddNew

func RemoveOldAddNew(old, new *identity.Identity)

RemoveOldAddNew removes old from and inserts new into the GlobalIdentityManager.

func Subscribe

func Subscribe(o Observer)

Subscribe adds the specified Observer to the global identity manager, to be notified upon changes to local identity usage.

Types

type IdentitiesModel

type IdentitiesModel []*models.IdentityEndpoints

IdentitiesModel is a wrapper so that we can implement the sort.Interface to sort the slice by ID

func (IdentitiesModel) Less

func (s IdentitiesModel) Less(i, j int) bool

Less returns true if the element in index `i` is lower than the element in index `j`

type IdentityManager

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

IdentityManager caches information about a set of identities, currently a reference count of how many users there are for each identity.

func NewIdentityManager

func NewIdentityManager() *IdentityManager

NewIdentityManager returns an initialized IdentityManager.

func (*IdentityManager) Add

func (idm *IdentityManager) Add(identity *identity.Identity)

Add inserts the identity into the identity manager. If the identity is already in the identity manager, the reference count for the identity is incremented.

func (*IdentityManager) GetIdentityModels

func (idm *IdentityManager) GetIdentityModels() []*models.IdentityEndpoints

GetIdentityModels returns the API representation of the IdentityManager.

func (*IdentityManager) Remove

func (idm *IdentityManager) Remove(identity *identity.Identity)

Remove deletes the identity from the identity manager. If the identity is already in the identity manager, the reference count for the identity is decremented. If the identity is not in the cache, this is a no-op. If the ref count becomes zero, the identity is removed from the cache.

func (*IdentityManager) RemoveOldAddNew

func (idm *IdentityManager) RemoveOldAddNew(old, new *identity.Identity)

RemoveOldAddNew removes old from the identity manager and inserts new into the IdentityManager. Caller must have previously added the old identity with Add(). This is a no-op if both identities have the same numeric ID.

type Observer

type Observer interface {
	// LocalEndpointIdentityAdded is called when an identity first becomes
	// used on the node. Implementations must ensure that the callback
	// returns within a reasonable period.
	LocalEndpointIdentityAdded(*identity.Identity)

	// LocalEndpointIdentityRemoved is called when an identity is no longer
	// in use on the node. Implementations must ensure that the callback
	// returns within a reasonable period.
	LocalEndpointIdentityRemoved(*identity.Identity)
}

Observer can sign up to receive events whenever local identities are removed.

Jump to

Keyboard shortcuts

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