...

Package cache

import "sigs.k8s.io/cli-utils/pkg/apply/cache"
Overview
Index

Overview ▾

type ResourceCache

ResourceCache stores CachedResource objects

type ResourceCache interface {
    ResourceCacheReader
    // Load one or more resources into the cache, generating the ObjMetadata
    // from the objects.
    Load(...ResourceStatus)
    // Put the resource into the cache using the specified ID.
    Put(object.ObjMetadata, ResourceStatus)
    // Remove the resource associated with the ID from the cache.
    Remove(object.ObjMetadata)
    // Clear the cache.
    Clear()
}

type ResourceCacheMap

ResourceCacheMap stores ResourceStatus objects in a map indexed by resource ID. ResourceCacheMap is thread-safe.

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

func NewResourceCacheMap

func NewResourceCacheMap() *ResourceCacheMap

NewResourceCacheMap returns a new empty ResourceCacheMap

func (*ResourceCacheMap) Clear

func (rc *ResourceCacheMap) Clear()

Clear the cache.

func (*ResourceCacheMap) Get

func (rc *ResourceCacheMap) Get(id object.ObjMetadata) ResourceStatus

Get retrieves the resource associated with the ID from the cache. Returns (nil, true) if not found in the cache.

func (*ResourceCacheMap) Load

func (rc *ResourceCacheMap) Load(values ...ResourceStatus)

Load resources into the cache, generating the ID from the resource itself. Existing resources with the same ID will be replaced.

func (*ResourceCacheMap) Put

func (rc *ResourceCacheMap) Put(id object.ObjMetadata, value ResourceStatus)

Put the resource into the cache using the supplied ID, replacing any existing resource with the same ID.

func (*ResourceCacheMap) Remove

func (rc *ResourceCacheMap) Remove(id object.ObjMetadata)

Remove the resource associated with the ID from the cache.

type ResourceCacheReader

ResourceCacheReader retrieves CachedResource objects

type ResourceCacheReader interface {
    // Get the resource associated with the ID from the cache.
    // If not cached, status will be Unknown and resource will be nil.
    Get(object.ObjMetadata) ResourceStatus
}

type ResourceStatus

ResourceStatus wraps an unstructured resource object, combined with the computed status (whether the status matches the spec).

type ResourceStatus struct {
    // Resource is the last known value retrieved from the cluster
    Resource *unstructured.Unstructured
    // Status of the resource
    Status status.Status
    // StatusMessage is the human readable reason for the status
    StatusMessage string
}