kr8_cache

import "github.com/ice-bergtech/kr8/pkg/kr8_cache"

Package kr8_cache defines the structure for kr8+ cluster-component resource caching. Cache is based on cluster-level config, component config, and component file reference hashes.

Index

type ClusterCache

This is cluster-level cache that applies to all components. If it is deemed invalid, the component cache is also invalid.

type ClusterCache struct {
    // Raw cluster _kr8_spec object
    Kr8_Spec string `json:"kr8_spec"`
    // Raw cluster _cluster object
    Cluster string `json:"cluster"`
}

func CreateClusterCache

func CreateClusterCache(config string) *ClusterCache

Stores the cluster kr8_spec and cluster config as cluster-level cache.

func (*ClusterCache) CheckClusterCache

func (cache *ClusterCache) CheckClusterCache(config string, logger zerolog.Logger) bool

Compares current cluster config represented as a json string to the cache. Returns true if cache is valid.

type ComponentCache

type ComponentCache struct {
    // Raw component config string
    ComponentConfig string `json:"component_config"`
    // Map of filenames to file hashes
    ComponentFiles map[string]string `json:"component_files"`
}

func CreateComponentCache

func CreateComponentCache(config string, listFiles []string) (*ComponentCache, error)

func (*ComponentCache) CheckComponentCache

func (cache *ComponentCache) CheckComponentCache(config string, componentName string, componentPath string, files []string, logger zerolog.Logger) (bool, *ComponentCache)

type DeploymentCache

Object that contains the cache for a single cluster.

type DeploymentCache struct {
    // A struct containing cluster-level cache values
    ClusterConfig *ClusterCache `json:"cluster_config"`
    // Map of cache entries for cluster components.
    // Depends on ClusterConfig cache being valid to be considered valid.
    ComponentConfigs map[string]ComponentCache `json:"component_config"`
    LibraryCache     *LibraryCache             `json:"library_cache"`
}

func InitDeploymentCache

func InitDeploymentCache(config string, baseDir string, cacheResults map[string]ComponentCache) *DeploymentCache

func LoadClusterCache

func LoadClusterCache(cacheFile string) (*DeploymentCache, error)

Load cluster cache from a specified cache file. Assumes cache is gzipped, but falls back to plaintext if there's an error.

func (*DeploymentCache) CheckClusterCache

func (cache *DeploymentCache) CheckClusterCache(config string, logger zerolog.Logger) bool

func (*DeploymentCache) CheckClusterComponentCache

func (cache *DeploymentCache) CheckClusterComponentCache(config string, componentName string, componentPath string, files []string, logger zerolog.Logger) (bool, *ComponentCache, error)

func (*DeploymentCache) WriteCache

func (cache *DeploymentCache) WriteCache(outFile string, compress bool) error

type LibraryCache

type LibraryCache struct {
    Directory string            `json:"directory"`
    Entries   map[string]string `json:"entries"`
}

func CreateLibraryCache

func CreateLibraryCache(baseDir string) *LibraryCache