patch

package
v0.9.2-rc4 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2023 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LeftJoinOn added in v0.8.0

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

func ManifestMetadataFromContext added in v0.8.0

func ManifestMetadataFromContext(ctx context.Context) (*controlv1.PluginManifest, bool)

Types

type BinaryPatcher added in v0.8.0

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 added in v0.8.0

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

type BsdiffPatcher added in v0.8.0

type BsdiffPatcher struct{}

func (BsdiffPatcher) ApplyPatch added in v0.8.0

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

func (BsdiffPatcher) CheckFormat added in v0.8.0

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

func (BsdiffPatcher) GeneratePatch added in v0.8.0

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

type Cache added in v0.8.0

type Cache interface {
	// RequestPatch will return a patch which will transform the plugin at oldHash to the plugin at newHash. If the patch
	// does not exist, and both referenced plugins 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

	// GetPlugin returns the plugin with the given hash, if it exists.
	GetPlugin(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 added in v0.8.0

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

type CacheMetrics added in v0.8.0

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

type CacheMetricsTracker added in v0.8.0

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

func NewCacheMetricsTracker added in v0.8.0

func NewCacheMetricsTracker(constLabels map[string]string) CacheMetricsTracker

func (*CacheMetricsTracker) AddToPatchCount added in v0.8.0

func (c *CacheMetricsTracker) AddToPatchCount(value int64)

func (*CacheMetricsTracker) AddToPluginCount added in v0.8.0

func (c *CacheMetricsTracker) AddToPluginCount(value int64)

func (*CacheMetricsTracker) AddToTotalSizeBytes added in v0.8.0

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

func (*CacheMetricsTracker) CacheHit added in v0.8.0

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

func (*CacheMetricsTracker) CacheMiss added in v0.8.0

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

func (*CacheMetricsTracker) IncPatchCalcCount added in v0.8.0

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

func (*CacheMetricsTracker) IncPatchCalcSecsTotal added in v0.8.0

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

func (*CacheMetricsTracker) MetricsCollectors added in v0.8.0

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

func (*CacheMetricsTracker) MetricsSnapshot added in v0.8.0

func (c *CacheMetricsTracker) MetricsSnapshot() CacheMetrics

func (*CacheMetricsTracker) SetPatchCount added in v0.8.0

func (c *CacheMetricsTracker) SetPatchCount(count int64)

func (*CacheMetricsTracker) SetPluginCount added in v0.8.0

func (c *CacheMetricsTracker) SetPluginCount(count int64)

func (*CacheMetricsTracker) SetTotalSizeBytes added in v0.8.0

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

type FilesystemCache added in v0.8.0

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

func (*FilesystemCache) Archive added in v0.8.0

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

func (*FilesystemCache) Clean added in v0.8.0

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

func (*FilesystemCache) GetPlugin added in v0.8.0

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

func (*FilesystemCache) ListDigests added in v0.8.0

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

func (*FilesystemCache) PatchKey added in v0.8.0

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

func (*FilesystemCache) RequestPatch added in v0.8.0

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

type FilesystemPluginSyncServer

type FilesystemPluginSyncServer struct {
	controlv1.UnsafePluginSyncServer
	SyncServerOptions
	// contains filtered or unexported fields
}

func NewFilesystemPluginSyncServer

func NewFilesystemPluginSyncServer(
	cfg v1beta1.PluginsSpec,
	lg *zap.SugaredLogger,
	opts ...SyncServerOption,
) (*FilesystemPluginSyncServer, error)

func (*FilesystemPluginSyncServer) Collectors added in v0.8.0

func (*FilesystemPluginSyncServer) GetPluginManifest added in v0.8.0

func (*FilesystemPluginSyncServer) RunGarbageCollection added in v0.8.0

func (f *FilesystemPluginSyncServer) RunGarbageCollection(ctx context.Context, store storage.ClusterStore) error

func (*FilesystemPluginSyncServer) StreamServerInterceptor

func (f *FilesystemPluginSyncServer) StreamServerInterceptor() grpc.StreamServerInterceptor

func (*FilesystemPluginSyncServer) SyncPluginManifest added in v0.8.0

func (f *FilesystemPluginSyncServer) SyncPluginManifest(
	ctx context.Context,
	theirManifest *controlv1.PluginManifest,
) (*controlv1.SyncResults, error)

type PatchClient added in v0.8.0

type PatchClient interface {
	Patch(patches *controlv1.PatchList) error
}

func NewPatchClient added in v0.8.0

func NewPatchClient(config v1beta1.PluginsSpec, lg *zap.SugaredLogger, opts ...PatchClientOption) (PatchClient, error)

type PatchClientOption added in v0.8.0

type PatchClientOption func(*PatchClientOptions)

func WithBaseFS added in v0.8.0

func WithBaseFS(basefs afero.Fs) PatchClientOption

type PatchClientOptions added in v0.8.0

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

type SyncServerOption added in v0.8.0

type SyncServerOption func(*SyncServerOptions)

func WithFs added in v0.8.0

func WithFs(fsys afero.Fs) SyncServerOption

func WithPluginSyncFilters added in v0.8.0

func WithPluginSyncFilters(filters plugins.Filter) SyncServerOption

type SyncServerOptions added in v0.8.0

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

Jump to

Keyboard shortcuts

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