version

package
v0.89.1 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2025 License: Apache-2.0 Imports: 21 Imported by: 3

Documentation

Index

Constants

View Source
const (
	EQ  operator = "="
	GT  operator = ">"
	LT  operator = "<"
	GTE operator = ">="
	LTE operator = "<="
	OR  operator = "||"
	AND operator = ","
)

Variables

View Source
var ErrNoVersionProvided = errors.New("no version provided for comparison")
View Source
var ErrUnsupportedVersion = fmt.Errorf("unsupported version value")

ErrUnsupportedVersion is returned when a version string cannot be parsed into a rich version object for a known unsupported case (e.g. golang "devel" version).

Functions

This section is empty.

Types

type Comparator

type Comparator interface {
	Compare(*Version) (int, error)
}

type Constraint

type Constraint interface {
	fmt.Stringer
	Satisfied(*Version) (bool, error)
}

func GetConstraint

func GetConstraint(constStr string, format Format) (Constraint, error)

func MustGetConstraint

func MustGetConstraint(constStr string, format Format) Constraint

MustGetConstraint is meant for testing only, do not use within the library

type Format

type Format int
const (
	UnknownFormat Format = iota
	SemanticFormat
	ApkFormat
	DebFormat
	MavenFormat
	RpmFormat
	PythonFormat
	KBFormat
	GemFormat
	PortageFormat
	GolangFormat
	JVMFormat
)

func FormatFromPkg added in v0.80.2

func FormatFromPkg(p pkg.Package) Format

func ParseFormat

func ParseFormat(userStr string) Format

func (Format) String

func (f Format) String() string

type NonFatalConstraintError added in v0.20.0

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

NonFatalConstraintError should be used any time an unexpected but recoverable condition is encountered while checking version constraint satisfaction. The error should get returned by any implementer of the Constraint interface. If returned by the Satisfied method on the Constraint interface, this error will be caught and logged as a warning in the FindMatchesByPackageDistro function in grype/matcher/common/distro_matchers.go

func (NonFatalConstraintError) Error added in v0.20.0

func (e NonFatalConstraintError) Error() string

type UnsupportedFormatError added in v0.88.0

type UnsupportedFormatError struct {
	Left  Format
	Right Format
}

UnsupportedFormatError represents an error when a format doesn't match the expected format

func NewUnsupportedFormatError added in v0.88.0

func NewUnsupportedFormatError(left, right Format) *UnsupportedFormatError

NewUnsupportedFormatError creates a new UnsupportedFormatError

func (*UnsupportedFormatError) Error added in v0.88.0

func (e *UnsupportedFormatError) Error() string

func (*UnsupportedFormatError) Is added in v0.88.0

func (e *UnsupportedFormatError) Is(target error) bool

type Version

type Version struct {
	Raw    string
	Format Format
	// contains filtered or unexported fields
}

func NewVersion

func NewVersion(raw string, format Format) (*Version, error)

func NewVersionFromPkg

func NewVersionFromPkg(p pkg.Package) (*Version, error)

func (Version) CPEs

func (v Version) CPEs() []cpe.CPE

func (Version) Compare added in v0.89.0

func (v Version) Compare(other *Version) (int, error)

func (Version) String

func (v Version) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳