habpkg

package
v0.0.0-...-6794c67 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2021 License: Apache-2.0 Imports: 8 Imported by: 19

Documentation

Index

Constants

View Source
const (
	SemverishGreater = 1
	SemverishEqual   = 0
	SemverishLess    = -1
)

Variables

This section is empty.

Functions

func CompareSemverish

func CompareSemverish(a SemverishVersion, b SemverishVersion) int

func Ident

func Ident(p VersionedPackage) string

Ident returns the path form of a package name as ORIGIN/NAME or ORIGIN/NAME/VERSION or ORIGIN/NAME/VERSION/RELEASE

func IsFullyQualified

func IsFullyQualified(p VersionedPackage) bool

IsFullyQualified returns true if both version and release are specified

func PathFor

func PathFor(p VersionedPackage) string

PathFor returns the expected on-disk path for a given packages

func SemverishGreaterOrEqual

func SemverishGreaterOrEqual(a VersionedArtifact, b VersionedArtifact) (bool, error)

GreaterOrEqual returns true if a is greater or equal to b, assuming both VersionedArtifacts use Semverish versions. It assumes Release() return lexically sortable string in case of a tie.

func ShortIdent

func ShortIdent(p VersionedPackage) string

func VersionString

func VersionString(v VersionedArtifact) string

VersionString (ugh, bad name) returns a string representing the version information available in the VersionedArtifact

Types

type HabPkg

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

HabPkg represents a Habitat package that can be installed from either the depot or a file on disk using the hab command line tool.

func FromList

func FromList(paths []string) ([]HabPkg, error)

func FromString

func FromString(ident string) (HabPkg, error)

FromString takes a string in the form of ORIGIN/NAME and resturns a HabPkg struct

func FromStrings

func FromStrings(data string) ([]HabPkg, error)

FromStrings takes a newline separated list of package identifiers and returns a list of HabPkgs.

func New

func New(origin, name string) HabPkg

New constructs a HabPkg

func NewFQ

func NewFQ(origin, name, version, release string) HabPkg

NewFQ constructs a fully qualified HabPkg

func NewWithVersion

func NewWithVersion(origin, name, version string) HabPkg

NewWithVersion constructs a HabPkg with a version (but no release)

func (*HabPkg) InstallIdent

func (p *HabPkg) InstallIdent() string

func (*HabPkg) MarshalText

func (p *HabPkg) MarshalText() ([]byte, error)

MarshalText turns a HabPkg into text

func (*HabPkg) Name

func (p *HabPkg) Name() string

Name returns the name of the package

func (*HabPkg) Origin

func (p *HabPkg) Origin() string

Origin returns the origin of the package

func (*HabPkg) Release

func (p *HabPkg) Release() string

Release returns the release of the package

func (*HabPkg) String

func (p *HabPkg) String() string

func (*HabPkg) UnmarshalText

func (p *HabPkg) UnmarshalText(text []byte) error

UnmarshalText can take text and parse a HabPkg

func (*HabPkg) Version

func (p *HabPkg) Version() string

Version returns the version of the package

type Hart

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

A Hart represents a hartifact archive on disk.

func HartFromPath

func HartFromPath(path string) (Hart, error)

HartFromPath parses a path into a Hart

func (*Hart) InstallIdent

func (h *Hart) InstallIdent() string

func (*Hart) MarshalText

func (h *Hart) MarshalText() ([]byte, error)

MarshalText turns a HabPkg into text

func (*Hart) Name

func (h *Hart) Name() string

Name returns the file-name-inferred name for the hart.

func (*Hart) Origin

func (h *Hart) Origin() string

VersionedPackage interface implementation Origin returns the file-name-inferred origin for the hart.

func (*Hart) Path

func (h *Hart) Path() string

Path returns the on-disk path to the hart

func (*Hart) Release

func (h *Hart) Release() string

Release returns the file-name-inferred release for the hart.

func (*Hart) String

func (h *Hart) String() string

func (*Hart) UnmarshalText

func (h *Hart) UnmarshalText(text []byte) error

UnmarshalText can take text and parse a HabPkg

func (*Hart) Version

func (h *Hart) Version() string

Version returns the file-name-inferred version for the hart.

func (*Hart) WithName

func (h *Hart) WithName(name string) *Hart

WithName sets the name of the hartifact

func (*Hart) WithOrigin

func (h *Hart) WithOrigin(origin string) *Hart

WithOrigin sets the origin of the hartifact

type HartDir

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

HartDir represents a collection of harts

func NewHartDir

func NewHartDir(path string) HartDir

NewHartDir constructs a hartDir for the given path

func (*HartDir) FindHart

func (d *HartDir) FindHart(origin string, name string) (*Hart, error)

FindHart returns the the newest hartifact for the given origin and name contained in the HartDir. If no hart exists for the given origin and name, an empty string is returned.

type Installable

type Installable interface {
	VersionedPackage
	InstallIdent() string
}

An Installable represents something that can be installed with `hab pkg install`. Currently this includes HabPkgs and Harts.

type SemverishVersion

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

SemverishVersion holds a semver-like version. It supports the following format:

[v]VERSION_PART[.VERSION_PART...][-PRERELEASE][+METADATA]

Unlike traditional semver, it supports any non-zero number of version parts.

func ParseSemverishVersion

func ParseSemverishVersion(s string) (SemverishVersion, error)

type SortableHarts

type SortableHarts []Hart

SortableHarts are paths to hartifacts on disk. We expect the files to follow the hartifact naming conventions and sort them by the version and timestamp embedded in the filename.

func (SortableHarts) Len

func (h SortableHarts) Len() int

Implement sort.Interface for sortableHarts allowing us to use the routines in the sort package to do any sorting.

func (SortableHarts) Less

func (h SortableHarts) Less(i int, j int) bool

func (SortableHarts) Swap

func (h SortableHarts) Swap(i int, j int)

type VersionedArtifact

type VersionedArtifact interface {
	Version() string
	Release() string
}

VersionedArtifact is an interface for artifacts that use habitat-style VERSION/RELEASE version string

type VersionedPackage

type VersionedPackage interface {
	Origin() string
	Name() string
	VersionedArtifact
}

VersionedPackage is an interface to help bridge the gap between HabPkg and Hart.

Jump to

Keyboard shortcuts

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