validator

package
v0.19.3 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SumUpDownloadStats

func SumUpDownloadStats(statsDir string, period time.Duration) (uint64, error)

SumUpDownloadStats calculates the sum of uint64 values from files in statsDir modified within the given period. Files older than the period are deleted, and errors during operations are returned where applicable. The opposite function is inspector.WriteUintToFile.

func WriteUintToFile

func WriteUintToFile(dir string, value uint64) error

WriteUintToFile creates a file in the specified directory with the current UTC Unix time as its name and writes the provided uint64 value into it. The opposite function is validator.SumUpDownloadStats.

Types

type ManifestValidator

type ManifestValidator interface {
	Validate(desc *v1.Descriptor, mf *ociutils.Manifest) error
}

ManifestValidator defines an interface for validating an OCI manifest against specific criteria or rules.

type SizeLimitedValidator

type SizeLimitedValidator struct {
	Limit uint64
}

SizeLimitedValidator ensures that the size of an artifact does not exceed a specified limit. Limit specifies the maximum allowed size in bytes.

func (SizeLimitedValidator) Validate

func (s SizeLimitedValidator) Validate(desc *v1.Descriptor, mf *ociutils.Manifest) error

Validate checks if the total size of the artifact does not exceed the configured size limit. It returns an error if the size exceeds the limit or nil otherwise.

type VolumeLimitValidator

type VolumeLimitValidator struct {
	StatsDir string
	Limit    uint64
	Period   time.Duration
}

VolumeLimitValidator validates volume usage against a specified limit within a given time period and directory.

func (VolumeLimitValidator) Validate

func (v VolumeLimitValidator) Validate(desc *v1.Descriptor, mf *ociutils.Manifest) error

Validate checks if the combined size of the descriptor and manifest exceeds the configured volume limit.

Jump to

Keyboard shortcuts

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