Documentation ¶
Index ¶
- Constants
- Variables
- func DeleteReferencesByReferrer(indexers CacheIndexers, dataplaneClient controllers.DataPlaneClient, ...) error
- func ObjectReferenceIndexerReferent(obj interface{}) ([]string, error)
- func ObjectReferenceIndexerReferrer(obj interface{}) ([]string, error)
- func ObjectReferenceKeyFunc(obj interface{}) (string, error)
- func UpdateReferencesToSecret(ctx context.Context, c client.Client, indexers CacheIndexers, ...) error
- type CacheIndexers
- func (c CacheIndexers) DeleteObjectIfNotReferred(obj client.Object, dataplaneClient controllers.DataPlaneClient) error
- func (c CacheIndexers) DeleteObjectReference(referrer client.Object, referent client.Object) error
- func (c CacheIndexers) DeleteReferencesByReferrer(referrer client.Object) error
- func (c CacheIndexers) ListReferencesByReferrer(referrer client.Object) ([]*ObjectReference, error)
- func (c CacheIndexers) ListReferredObjects(referrer client.Object) ([]client.Object, error)
- func (c CacheIndexers) ObjectReferred(obj client.Object) (bool, error)
- func (c CacheIndexers) SetObjectReference(referrer client.Object, referent client.Object) error
- type ObjectReference
Constants ¶
const ( IndexNameReferrer = "referrer" IndexNameReferent = "referent" )
const ( VersionV1 = "v1" KindSecret = "Secret" CACertLabelKey = "konghq.com/ca-cert" )
Variables ¶
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 ¶
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 ¶
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 ¶
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 ¶
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) 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 ¶
ListReferredObjects lists all objects referred by referrer in reference cache.
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 ¶
SetObjectReference adds or updates a reference record between referrer and referent in reference cache.