clair: github.com/coreos/clair/ext/versionfmt Index | Files | Directories

package versionfmt

import "github.com/coreos/clair/ext/versionfmt"

Package versionfmt exposes functions to dynamically register formats used to parse Feature Versions.

Index

Package Files

driver.go

Constants

const (
    // MinVersion is a special package version which is always sorted first.
    MinVersion = "#MINV#"

    // MaxVersion is a special package version which is always sorted last.
    MaxVersion = "#MAXV#"
)

Variables

var (
    // ErrUnknownVersionFormat is returned when a function does not have enough
    // context to determine the format of a version.
    ErrUnknownVersionFormat = errors.New("unknown version format")

    // ErrInvalidVersion is returned when a function needs to validate a version,
    // but should return an error in the case where the version is invalid.
    ErrInvalidVersion = errors.New("invalid version")
)

func Compare Uses

func Compare(format, versionA, versionB string) (int, error)

Compare is a helper function that will compare two versions with a given format and return an error if there are any failures.

func GetFixedIn Uses

func GetFixedIn(format, rangeA string) (string, error)

GetFixedIn is a helper function that computes the next fixed in version given a affected version range `rangeA`.

func InRange Uses

func InRange(format, version, versionRange string) (bool, error)

InRange is a helper function that checks if `versionA` is in `rangeB`

func RegisterParser Uses

func RegisterParser(name string, p Parser)

RegisterParser provides a way to dynamically register an implementation of a Parser.

If RegisterParser is called twice with the same name, the name is blank, or if the provided Parser is nil, this function panics.

func Valid Uses

func Valid(format, version string) error

Valid is a helper function that will return an error if the version fails to validate with a given format.

type Parser Uses

type Parser interface {
    // Valid attempts to parse a version string and returns its success.
    Valid(string) bool

    // Compare parses two different version strings.
    // Returns 0 when equal, -1 when a < b, 1 when b < a.
    Compare(a, b string) (int, error)

    // InRange computes if a is in range of b
    //
    // NOTE(Sida): For legacy version formats, rangeB is a version and
    // always use if versionA < rangeB as threshold.
    InRange(versionA, rangeB string) (bool, error)

    // GetFixedIn computes a fixed in version for a certain version range.
    //
    // NOTE(Sida): For legacy version formats, rangeA is a version and
    // be returned directly becuase it was considered fixed in version.
    GetFixedIn(rangeA string) (string, error)
}

Parser represents any format that can compare two version strings.

func GetParser Uses

func GetParser(name string) (p Parser, exists bool)

GetParser returns the registered Parser with a provided name.

Directories

PathSynopsis
dpkgPackage dpkg implements a versionfmt.Parser for version numbers used in dpkg based software packages.
rpmPackage rpm implements a versionfmt.Parser for version numbers used in rpm based software packages.

Package versionfmt imports 3 packages (graph) and is imported by 35 packages. Updated 2017-09-23. Refresh now. Tools for package owners.