build

package
v0.0.0-...-b1a16a8 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: BSD-2-Clause-Patent Imports: 15 Imported by: 0

Documentation

Overview

Package build provides an importable repository of variables set at build time.

Index

Constants

View Source
const (
	// DaosComponentHeader defines the header name used to convey the component name.
	DaosComponentHeader = "x-daos-component"
	// DaosVersionHeader defines the header name used to convey the component version.
	DaosVersionHeader = "x-daos-version"
)
View Source
const (
	// MaxMinorDelta is the default maximum minor version delta
	// allowed between two components.
	MaxMinorDelta = 2
)

Variables

View Source
var (
	// ErrNoCtxMetadata is returned when no component/version metadata is found in the context.
	ErrNoCtxMetadata = errors.New("no component/version metadata found in context")
	// ErrCtxMetadataExists is returned when component/version metadata has already been set in the context.
	ErrCtxMetadataExists = errors.New("component/version metadata already exists in context")
)
View Source
var (
	// ComponentAny is a wildcard component.
	ComponentAny = Component("")
	// ComponentServer represents the control plane server.
	ComponentServer = Component("server")
	// ComponentAdmin represents the Control API client.
	ComponentAdmin = Component("admin")
	// ComponentAgent represents the compute node agent.
	ComponentAgent = Component("agent")
	// ComponentClient represents the libdaos client.
	ComponentClient = Component("client")
)
View Source
var (
	// ConfigDir should be set via linker flag using the value of CONF_DIR.
	ConfigDir = "./"
	// DaosVersion should be set via linker flag using the value of DAOS_VERSION.
	DaosVersion = "unset"
	// BuildTime should be set via linker flag using the value of BUILD_TIME.
	BuildTime = ""
	// BuildHost should be set via linker flag using the value of BUILD_HOST.
	BuildHost = ""
	// BuildInfo should be set via linker flag using the value of BUILD_INFO.
	BuildInfo = ""
	// ControlPlaneName defines a consistent name for the control plane server.
	ControlPlaneName = "DAOS Control Server"
	// DataPlaneName defines a consistent name for the engine.
	DataPlaneName = "DAOS I/O Engine"
	// ManagementServiceName defines a consistent name for the Management Service.
	ManagementServiceName = "DAOS Management Service"
	// AgentName defines a consistent name for the compute node agent.
	AgentName = "DAOS Agent"
	// CLIUtilName defines a consistent name for the daos CLI utility.
	CLIUtilName = "DAOS CLI"
	// AdminUtilName defines a consistent name for the dmg utility.
	AdminUtilName = "DAOS Admin Tool"

	// DefaultControlPort defines the default control plane listener port.
	DefaultControlPort = 10001

	// DefaultSystemName defines the default DAOS system name.
	DefaultSystemName = "daos_server"

	// VCS is the version control system used to build the binary.
	VCS = ""
	// Revision is the VCS revision of the binary.
	Revision = ""
	// LastCommit is the time of the last commit.
	LastCommit time.Time
	// ReleaseBuild is true if the binary was built with the release tag.
	ReleaseBuild bool
	// DirtyBuild is true if the binary was built with uncommitted changes.
	DirtyBuild bool
)

Functions

func CheckCompatibility

func CheckCompatibility(self, other *VersionedComponent, customRules ...*InteropRule) error

CheckCompatibility checks a pair of versioned components for compatibility based on specific interoperability constraints or general rules.

The design is aimed at allowing a component to verify compatibility with another component, and the logic can be customized by callers for specific requirements at the call site.

e.g. "I am server v2.0.0. Am I compatible with agent v1.2.0?"

func IsIncompatComponents

func IsIncompatComponents(err error) bool

IsIncompatComponents returns true if the error is an instance of ErrIncompatComponents.

func MarshalJSON

func MarshalJSON(name string) ([]byte, error)

MarshalJSON returns a JSON string containing a structured representation of the binary build info.

func String

func String(name string) string

String returns a string containing the name, version, and for non-release builds, the revision of the binary.

func ToContext

func ToContext(parent context.Context, comp Component, verStr string) (context.Context, error)

ToContext adds the component and version to the context.

func VersionString

func VersionString(name, version string) string

VersionString returns a string concatenation of the supplied name and version.

Types

type Component

type Component string

Component is a component of the system.

func (Component) Matches

func (c Component) Matches(other Component) bool

Matches returns true if the component is equal to other or one of the components is a wildcard.

func (Component) String

func (c Component) String() string

type ErrIncompatComponents

type ErrIncompatComponents struct {
	Components []*VersionedComponent
}

ErrIncompatComponents is returned when two components are incompatible.

func (ErrIncompatComponents) Error

func (e ErrIncompatComponents) Error() string

type Info

type Info struct {
	Name      string     `json:"name"`
	Version   string     `json:"version"`
	Revision  string     `json:"revision,omitempty"`
	Dirty     bool       `json:"dirty,omitempty"`
	Release   bool       `json:"release,omitempty"`
	BuildHost string     `json:"build_host,omitempty"`
	BuildTime *time.Time `json:"build_time,omitempty"`
	BuildInfo string     `json:"build_info,omitempty"`
}

Info contains a structured representation of the binary build info.

type InteropRule

type InteropRule struct {
	Self          Component
	Other         Component
	Description   string
	StopOnSuccess bool // If set, and the rule is satisfied, stop checking rules.
	Check         func(self, other *VersionedComponent) bool
	Match         func(self, other *VersionedComponent) bool
}

InteropRule is a rule for checking compatibility between two versioned components.

func (*InteropRule) Matches

func (rule *InteropRule) Matches(self, other *VersionedComponent) bool

Matches returns true if the rule matches the components.

type Version

type Version struct {
	Major int
	Minor int
	Patch int
}

Version represents a semantic version.

func GetLibraryInfo

func GetLibraryInfo(libName string) (*Version, string, error)

GetLibraryInfo attempts to resolve the given library name into a version and path. NB: The library must provide an ABI method to obtain its version, and that method needs to be added to this package in order to support it.

func MustNewVersion

func MustNewVersion(in string) Version

MustNewVersion creates a new version from a string, panics if the version cannot be created.

func NewVersion

func NewVersion(in string) (Version, error)

NewVersion creates a new version from a string.

func (Version) Equals

func (v Version) Equals(other Version) bool

Equals tests if two versions are equal.

func (Version) GreaterThan

func (v Version) GreaterThan(other Version) bool

GreaterThan tests if the version is greater than the other.

func (Version) GreaterThanOrEquals

func (v Version) GreaterThanOrEquals(other Version) bool

GreaterThanOrEquals tests if the version is greater than or equal to the other.

func (Version) IsZero

func (v Version) IsZero() bool

IsZero returns true if the version is zero.

func (Version) LessThan

func (v Version) LessThan(other Version) bool

LessThan tests if the version is less than the other.

func (Version) LessThanOrEquals

func (v Version) LessThanOrEquals(other Version) bool

LessThanOrEquals tests if the version is less than or equal to the other.

func (Version) MajorDelta

func (v Version) MajorDelta(other Version) int

MajorDelta returns the difference between the major versions.

func (Version) MinorDelta

func (v Version) MinorDelta(other Version) int

MinorDelta returns the difference between the minor versions.

func (Version) PatchCompatible

func (v Version) PatchCompatible(other Version) bool

PatchCompatible tests if the major and minor versions are the same.

func (Version) PatchDelta

func (v Version) PatchDelta(other Version) int

PatchDelta returns the difference between the patch versions.

func (Version) String

func (v Version) String() string

type VersionedComponent

type VersionedComponent struct {
	Version   Version
	Component Component
}

VersionedComponent is a component with a version.

func FromContext

func FromContext(ctx context.Context) (*VersionedComponent, error)

FromContext returns a versioned component obtained from the context.

func NewVersionedComponent

func NewVersionedComponent(comp Component, version string) (*VersionedComponent, error)

NewVersionedComponent creates a new VersionedComponent.

func (*VersionedComponent) String

func (vc *VersionedComponent) String() string

Jump to

Keyboard shortcuts

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