patch

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PluginsDir = "plugins"
	PatchesDir = "patches"
)
View Source
const (
	UpdateStrategy = "binary"
)

Variables

This section is empty.

Functions

func LeftJoinOn

func LeftJoinOn(gateway, agent *controlv1.UpdateManifest) *controlv1.PatchList

Types

type BinaryPatcher

type BinaryPatcher interface {
	GeneratePatch(old io.Reader, new io.Reader, patchOut io.Writer) error
	ApplyPatch(old io.Reader, patch io.Reader, newOut io.Writer) error
	CheckFormat(reader io.ReaderAt) bool
}

func NewPatcherFromFormat

func NewPatcherFromFormat(reader io.ReaderAt) (BinaryPatcher, bool)

type BsdiffPatcher

type BsdiffPatcher struct{}

func (BsdiffPatcher) ApplyPatch

func (BsdiffPatcher) ApplyPatch(old io.Reader, patch io.Reader, newOut io.Writer) (err error)

func (BsdiffPatcher) CheckFormat

func (BsdiffPatcher) CheckFormat(reader io.ReaderAt) bool

func (BsdiffPatcher) GeneratePatch

func (BsdiffPatcher) GeneratePatch(old io.Reader, new io.Reader, patchOut io.Writer) (err error)

type Cache

type Cache interface {
	// RequestPatch will return a patch which will transform the binary at oldHash to the binary at newHash. If the patch
	// does not exist, and both referenced binaries exist, the patch will be generated and stored in the cache before
	// returning.
	// This function is thread-safe and reentrant. The patch will only be computed once regardless of how many
	// concurrent calls are made.
	// If the patch does not exist, and one or both of the referenced plugins do not exist, this function will return
	// an error, and the patch will not be generated.
	RequestPatch(oldHash, newHash string) ([]byte, error)

	// PatchKey Returns an opaque unique key representing a patch between the two revisions. The key is guaranteed to be
	// unique for the inputs but is not guaranteed to have a specific format, or even contain the input strings.
	PatchKey(oldHash, newHash string) string

	// Archive compresses and saves all plugins in the given plugin manifest to the cache, if they do not exist.
	Archive(manifest *controlv1.PluginArchive) error

	// GetBinaryFile returns the plugin with the given hash, if it exists.
	GetBinaryFile(dir, hash string) ([]byte, error)

	// ListDigests returns a list of all plugin digests in the cache. It does not return patch digests.
	ListDigests() ([]string, error)

	// Clean removes all objects in the cache associated with the given plugin hashes, including any patches that
	// reference those plugins.
	Clean(hashes ...string)

	// MetricsCollectors returns a list of prometheus collectors that can be used to track cache metrics.
	MetricsCollectors() []prometheus.Collector

	// MetricsSnapshot returns a snapshot of the current cache metrics.
	MetricsSnapshot() CacheMetrics
}

func NewFilesystemCache

func NewFilesystemCache(fsys afero.Fs, conf v1beta1.FilesystemCacheSpec, patcher BinaryPatcher, lg *slog.Logger) (Cache, error)

type CacheMetrics

type CacheMetrics struct {
	CacheMisses           int64
	CacheHits             int64
	PluginCount           int64
	PatchCount            int64
	TotalSizeBytes        int64
	PatchCalcSecondsTotal int64
	PatchCalcCount        int64
}

type CacheMetricsTracker

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

func NewCacheMetricsTracker

func NewCacheMetricsTracker(constLabels map[string]string) CacheMetricsTracker

func (*CacheMetricsTracker) AddToPatchCount

func (c *CacheMetricsTracker) AddToPatchCount(value int64)

func (*CacheMetricsTracker) AddToPluginCount

func (c *CacheMetricsTracker) AddToPluginCount(value int64)

func (*CacheMetricsTracker) AddToTotalSizeBytes

func (c *CacheMetricsTracker) AddToTotalSizeBytes(digest string, value int64)

func (*CacheMetricsTracker) CacheHit

func (c *CacheMetricsTracker) CacheHit(oldDigest, newDigest string)

func (*CacheMetricsTracker) CacheMiss

func (c *CacheMetricsTracker) CacheMiss(oldDigest, newDigest string)

func (*CacheMetricsTracker) IncPatchCalcCount

func (c *CacheMetricsTracker) IncPatchCalcCount(oldDigest, newDigest string)

func (*CacheMetricsTracker) IncPatchCalcSecsTotal

func (c *CacheMetricsTracker) IncPatchCalcSecsTotal(oldDigest, newDigest string, value float64)

func (*CacheMetricsTracker) MetricsCollectors

func (c *CacheMetricsTracker) MetricsCollectors() []prometheus.Collector

func (*CacheMetricsTracker) MetricsSnapshot

func (c *CacheMetricsTracker) MetricsSnapshot() CacheMetrics

func (*CacheMetricsTracker) SetPatchCount

func (c *CacheMetricsTracker) SetPatchCount(count int64)

func (*CacheMetricsTracker) SetPluginCount

func (c *CacheMetricsTracker) SetPluginCount(count int64)

func (*CacheMetricsTracker) SetTotalSizeBytes

func (c *CacheMetricsTracker) SetTotalSizeBytes(digest string, size int64)

type FilesystemCache

type FilesystemCache struct {
	CacheMetricsTracker
	// contains filtered or unexported fields
}

func (*FilesystemCache) Archive

func (p *FilesystemCache) Archive(manifest *controlv1.PluginArchive) error

func (*FilesystemCache) Clean

func (p *FilesystemCache) Clean(hashes ...string)

func (*FilesystemCache) GetBinaryFile

func (p *FilesystemCache) GetBinaryFile(dir, hash string) ([]byte, error)

func (*FilesystemCache) ListDigests

func (p *FilesystemCache) ListDigests() ([]string, error)

func (*FilesystemCache) PatchKey

func (*FilesystemCache) PatchKey(oldDigest, newDigest string) string

func (*FilesystemCache) RequestPatch

func (p *FilesystemCache) RequestPatch(oldDigest, newDigest string) ([]byte, error)

type ZstdPatcher added in v0.11.2

type ZstdPatcher struct{}

func (ZstdPatcher) ApplyPatch added in v0.11.2

func (ZstdPatcher) ApplyPatch(old io.Reader, patch io.Reader, newOut io.Writer) (err error)

func (ZstdPatcher) CheckFormat added in v0.11.2

func (ZstdPatcher) CheckFormat(reader io.ReaderAt) bool

func (ZstdPatcher) GeneratePatch added in v0.11.2

func (ZstdPatcher) GeneratePatch(old io.Reader, new io.Reader, patchOut io.Writer) (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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