reference

package
v3.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IndexNameReferrer = "referrer"
	IndexNameReferent = "referent"
)
View Source
const (
	VersionV1      = "v1"
	KindSecret     = "Secret"
	CACertLabelKey = "konghq.com/ca-cert"
)

Variables

View Source
var ErrTypeNotObjectReference = fmt.Errorf("type of object in indexer is not ObjectReference")

ErrTypeNotObjectReference is the error returned to caller to tell that type of the object stored in indexer is not ObjectReference. It should not happen in normal use, because only ObjectReference should be added to the indexer.

Functions

func DeleteReferencesByReferrer

func DeleteReferencesByReferrer(indexers CacheIndexers, dataplaneClient controllers.DataPlaneClient, referrer client.Object) error

DeleteReferencesByReferrer deletes all reference records with specified referrer in reference cache. If the affected secret is not referred by any other objects, it deletes the secret in object cache.

func ObjectReferenceIndexerReferent

func ObjectReferenceIndexerReferent(obj interface{}) ([]string, error)

ObjectReferenceIndexerReferent is the index function to index by the referent, which returns index in the following format from referent: group/version,Kind=kind/namespace/name.

func ObjectReferenceIndexerReferrer

func ObjectReferenceIndexerReferrer(obj interface{}) ([]string, error)

ObjectReferenceIndexerReferrer is the index function to index by the referrer, which returns the index in the following format from referrer: group/version,Kind=kind/namespace/name.

func ObjectReferenceKeyFunc

func ObjectReferenceKeyFunc(obj interface{}) (string, error)

ObjectReferenceKeyFunc is the function to transfer the reference relataioships between k8s objects. The key is transferred to the following format: group/version,Kind=kind/namespace/name:group/version,Kind=kind/namespace/name The part before : is from referrer, and after : is from referent.

func UpdateReferencesToSecret

func UpdateReferencesToSecret(
	ctx context.Context,
	c client.Client, indexers CacheIndexers, dataplaneClient controllers.DataPlaneClient,
	referrer client.Object, referencedSecretNameMap map[k8stypes.NamespacedName]struct{},
) error

UpdateReferencesToSecret updates the reference records between referrer and each secret in namespacedNames in record cache.

Types

type CacheIndexers

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

CacheIndexers implements a reference cache to store reference relationship between k8s objects provided by cache.Indexer. It could do CRUD on reference records when referrer and referent are both provided. It can also list reference records by referrer or by referent.

func NewCacheIndexers

func NewCacheIndexers(logger logr.Logger) CacheIndexers

func (CacheIndexers) DeleteObjectIfNotReferred

func (c CacheIndexers) DeleteObjectIfNotReferred(obj client.Object, dataplaneClient controllers.DataPlaneClient) error

DeleteObjectIfNotReferred deletes object from object cach by dataplaneClient the object is not referenced in reference cache.

func (CacheIndexers) DeleteObjectReference

func (c CacheIndexers) DeleteObjectReference(referrer client.Object, referent client.Object) error

DeleteObjectReference deletes the reference record between referrer and referent from reference cache.

func (CacheIndexers) DeleteReferencesByReferrer

func (c CacheIndexers) DeleteReferencesByReferrer(referrer client.Object) error

DeleteReferencesByReferrer deletes all reference records where referrer has the same key (GroupVersionKind+NamespacedName, that means the same k8s object). called when a k8s object deleted in cluster, or when we do not care about it anymore.

func (CacheIndexers) ListReferencesByReferent added in v3.1.0

func (c CacheIndexers) ListReferencesByReferent(referent client.Object) ([]*ObjectReference, error)

ListReferencesByReferent lists all reference records referring to the same referent.

func (CacheIndexers) ListReferencesByReferrer

func (c CacheIndexers) ListReferencesByReferrer(referrer client.Object) ([]*ObjectReference, error)

ListReferencesByReferrer lists all reference records where referrer has the same key (GroupVersionKind+NamespacedName, that means the same k8s object).

func (CacheIndexers) ListReferredObjects

func (c CacheIndexers) ListReferredObjects(referrer client.Object) ([]client.Object, error)

ListReferredObjects lists all objects referred by referrer in reference cache.

func (CacheIndexers) ListReferrerObjectsByReferent added in v3.1.0

func (c CacheIndexers) ListReferrerObjectsByReferent(referent client.Object) ([]client.Object, error)

ListReferrerObjectsByReferent lists all objects that refers to the same referent.

func (CacheIndexers) ObjectReferred

func (c CacheIndexers) ObjectReferred(obj client.Object) (bool, error)

ObjectReferred returns true if an object is referenced (being the referent) in at least one reference record.

func (CacheIndexers) SetObjectReference

func (c CacheIndexers) SetObjectReference(referrer client.Object, referent client.Object) error

SetObjectReference adds or updates a reference record between referrer and referent in reference cache.

type ObjectReference

type ObjectReference struct {
	Referrer client.Object
	Referent client.Object
}

Jump to

Keyboard shortcuts

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