version

package
v0.0.0-...-0123b22 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 21 Imported by: 4

Documentation

Overview

Deprecated: Use storj.io/common/version instead.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ShouldUpdate

func ShouldUpdate(rollout Rollout, nodeID storj.NodeID) bool

ShouldUpdate checks if for the the given rollout state, a user with the given nodeID should update. Deprecated and should eventually be unexported. Please use ShouldUpdateVersion instead.

Types

type AllowedVersions

type AllowedVersions struct {
	Satellite   OldSemVer
	Storagenode OldSemVer
	Uplink      OldSemVer
	Gateway     OldSemVer
	Identity    OldSemVer

	Processes Processes `json:"processes"`
}

AllowedVersions provides the Minimum SemVer per Service. TODO: I don't think this name is representative of what this struct now holds.

type Info

type Info struct {
	Timestamp  time.Time `json:"timestamp,omitempty"`
	CommitHash string    `json:"commitHash,omitempty"`
	Version    SemVer    `json:"version"`
	Release    bool      `json:"release,omitempty"`
	Modified   bool      `json:"modified,omitempty"`
	// contains filtered or unexported fields
}

Info is the versioning information for a binary.

var (
	// VerError is the error class for version-related errors.
	VerError = errs.Class("version")

	// Build is a struct containing all relevant build information associated with the binary.
	Build Info
)

func New

func New(data []byte) (v Info, err error)

New creates Version_Info from a json byte array.

func (Info) IsZero

func (info Info) IsZero() bool

IsZero checks if the version struct is its zero value.

func (Info) Log

func (info Info) Log(logger func(msg string, fields ...zap.Field))

Log prints out the version information to a zap compatible log.

func (Info) Marshal

func (info Info) Marshal() ([]byte, error)

Marshal converts the existing Version Info to any json byte array.

func (Info) Proto

func (info Info) Proto() (*pb.NodeVersion, error)

Proto converts an Info struct to a pb.NodeVersion TODO: shouldn't we just use pb.NodeVersion everywhere? gogoproto will let us make it match Info.

func (*Info) Stats

func (info *Info) Stats(cb func(key monkit.SeriesKey, field string, val float64))

Stats implements the monkit.StatSource interface.

func (Info) String

func (info Info) String() (out string)

String returns with new line separated, printable information for humans.

type OldSemVer

type OldSemVer struct {
	Major int64 `json:"major"`
	Minor int64 `json:"minor"`
	Patch int64 `json:"patch"`
}

OldSemVer represents a semantic version.

Note: use `SemVer` in newer code; these structs marshal to JSON differently.

func NewOldSemVer

func NewOldSemVer(v string) (OldSemVer, error)

NewOldSemVer parses a given version and returns an instance of OldSemVer or an error if unable to parse the version.

func (OldSemVer) String

func (old OldSemVer) String() string

type Process

type Process struct {
	Minimum   Version `json:"minimum"`
	Suggested Version `json:"suggested"`
	Rollout   Rollout `json:"rollout"`
}

Process versions for specific binary.

type Processes

type Processes struct {
	Satellite          Process `json:"satellite"`
	Storagenode        Process `json:"storagenode"`
	StoragenodeUpdater Process `json:"storagenode-updater"`
	Uplink             Process `json:"uplink"`
	Gateway            Process `json:"gateway"`
	Identity           Process `json:"identity"`
}

Processes describes versions for each binary. TODO: this name is inconsistent with the versioncontrol server pkg's analogue, `Versions`.

type Rollout

type Rollout struct {
	Seed   RolloutBytes `json:"seed"`
	Cursor RolloutBytes `json:"cursor"`
}

Rollout represents the state of a version rollout.

type RolloutBytes

type RolloutBytes [32]byte

RolloutBytes implements json un/marshalling using hex de/encoding.

func PercentageToCursor

func PercentageToCursor(pct int) RolloutBytes

PercentageToCursor calculates the cursor value for the given percentage of nodes which should update. Deprecated: use PercentageToCursorF which is more precise.

func PercentageToCursorF

func PercentageToCursorF(pct float64) RolloutBytes

PercentageToCursorF calculates the cursor value for the given floating point percentage.

func (RolloutBytes) MarshalJSON

func (rb RolloutBytes) MarshalJSON() ([]byte, error)

MarshalJSON hex-encodes RolloutBytes and pre/appends JSON string literal quotes.

func (*RolloutBytes) UnmarshalJSON

func (rb *RolloutBytes) UnmarshalJSON(b []byte) error

UnmarshalJSON drops the JSON string literal quotes and hex-decodes RolloutBytes .

type SemVer

type SemVer struct {
	semver.Version
}

SemVer represents a semantic version. TODO: replace with semver.Version.

func NewSemVer

func NewSemVer(v string) (SemVer, error)

NewSemVer parses a given version and returns an instance of SemVer or an error if unable to parse the version.

func (*SemVer) Compare

func (sem *SemVer) Compare(version SemVer) int

Compare compare two versions, return -1 if compared version is greater, 0 if equal and 1 if less.

func (SemVer) IsZero

func (sem SemVer) IsZero() bool

IsZero checks if the semantic version is its zero value.

func (*SemVer) String

func (sem *SemVer) String() (version string)

String converts the SemVer struct to a more easy to handle string.

type Version

type Version struct {
	Version string `json:"version"`
	URL     string `json:"url"`
}

Version represents version and download URL for binary.

func ShouldUpdateVersion

func ShouldUpdateVersion(currentVersion SemVer, nodeID storj.NodeID, requested Process) (updateVersion Version, reason string, err error)

ShouldUpdateVersion determines if, given a current version and data from the version server, if the current version should be updated. It returns the Version to update to or an empty Version.

func (*Version) IsZero

func (ver *Version) IsZero() bool

IsZero checks if the Version is its zero value.

func (*Version) SemVer

func (ver *Version) SemVer() (SemVer, error)

SemVer converts a version struct into a semantic version struct.

Jump to

Keyboard shortcuts

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