kr8_cache

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClusterCache

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

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

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

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"`
}

Object that contains the cache for a single cluster.

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

Jump to

Keyboard shortcuts

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