version

package
v0.0.0-...-65247a5 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2014 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

The version package implements version parsing. It also acts as guardian of the current client Juju version number.

Index

Constants

This section is empty.

Variables

View Source
var Current = Binary{
	Number: MustParse(version),
	Series: readSeries(lsbReleaseFile),
	Arch:   ubuntuArch(runtime.GOARCH),
}

Current gives the current version of the system. If the file "FORCE-VERSION" is present in the same directory as the running binary, it will override this.

View Source
var Zero = Number{}

Zero is occasionally convenient and readable. Please don't change its value.

Functions

func ParseMajorMinor

func ParseMajorMinor(vers string) (int, int, error)

ParseMajorMinor takes an argument of the form "major.minor" and returns ints major and minor.

func ReleaseVersion

func ReleaseVersion() string

ReleaseVersion looks for the value of DISTRIB_RELEASE in the content of the lsbReleaseFile. If the value is not found, the file is not found, or an error occurs reading the file, an empty string is returned.

Types

type Binary

type Binary struct {
	Number
	Series string
	Arch   string
}

Binary specifies a binary version of juju.

func MustParseBinary

func MustParseBinary(s string) Binary

MustParseBinary parses a binary version and panics if it does not parse correctly.

func ParseBinary

func ParseBinary(s string) (Binary, error)

ParseBinary parses a binary version of the form "1.2.3-series-arch".

func (Binary) GetBSON

func (v Binary) GetBSON() (interface{}, error)

GetBSON turns v into a bson.Getter so it can be saved directly on a MongoDB database with mgo.

func (Binary) GetYAML

func (v Binary) GetYAML() (tag string, value interface{})

GetYAML implements goyaml.Getter

func (Binary) MarshalJSON

func (v Binary) MarshalJSON() ([]byte, error)

func (*Binary) SetBSON

func (vp *Binary) SetBSON(raw bson.Raw) error

SetBSON turns v into a bson.Setter so it can be loaded directly from a MongoDB database with mgo.

func (*Binary) SetYAML

func (vp *Binary) SetYAML(tag string, value interface{}) bool

SetYAML implements goyaml.Setter

func (Binary) String

func (v Binary) String() string

func (*Binary) UnmarshalJSON

func (vp *Binary) UnmarshalJSON(data []byte) error

type Number

type Number struct {
	Major int
	Minor int
	Patch int
	Build int
}

Number represents a juju version. When bugs are fixed the patch number is incremented; when new features are added the minor number is incremented and patch is reset; and when compatibility is broken the major version is incremented and minor and patch are reset. The build number is automatically assigned and has no well defined sequence. If the build number is greater than zero or the minor version is odd, it indicates that the release is still in development.

func MustParse

func MustParse(s string) Number

MustParse parses a version and panics if it does not parse correctly.

func Parse

func Parse(s string) (Number, error)

Parse parses the version, which is of the form 1.2.3 giving the major, minor and release versions respectively.

func (Number) Compare

func (v Number) Compare(w Number) int

Compare returns -1, 0 or 1 depending on whether v is less than, equal to or greater than w.

func (Number) GetBSON

func (v Number) GetBSON() (interface{}, error)

GetBSON turns v into a bson.Getter so it can be saved directly on a MongoDB database with mgo.

func (Number) GetYAML

func (v Number) GetYAML() (tag string, value interface{})

GetYAML implements goyaml.Getter

func (Number) IsDev

func (v Number) IsDev() bool

IsDev returns whether the version represents a development version. A version with an odd-numbered minor component or a nonzero build component is considered to be a development version.

func (Number) MarshalJSON

func (v Number) MarshalJSON() ([]byte, error)

func (*Number) SetBSON

func (vp *Number) SetBSON(raw bson.Raw) error

SetBSON turns v into a bson.Setter so it can be loaded directly from a MongoDB database with mgo.

func (*Number) SetYAML

func (vp *Number) SetYAML(tag string, value interface{}) bool

SetYAML implements goyaml.Setter

func (Number) String

func (v Number) String() string

func (*Number) UnmarshalJSON

func (vp *Number) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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