version

package
v0.4.27 Latest Latest
Warning

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

Go to latest
Published: May 22, 2019 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version string

Version shows the current SONM platform version.

Components like Node, Worker, CLI, etc. share the same version number.

Functions

func ValidateVersion

func ValidateVersion(ctx context.Context, observer Observer)

ValidateVersion performs the current component's version validation. The idea is to notify whether the current version is either outdated or unstable.

Types

type CodecError

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

CodecError represents an en/decoding error while deserializing a version file content into structured representation.

type FS

type FS interface {
	// Open opens the version file for reading.
	Open() (File, error)
	// Create creates the version file with mode 0666.
	Create() (File, error)
}

FS encapsulates platform dependent filesystem functions.

type File

type File interface {
	Read(p []byte) (int, error)
	Write(p []byte) (int, error)
	Close() error
}

File represents a file handle.

Exists primarily for testing purposes.

type LogObserver

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

func NewLogObserver

func NewLogObserver(log *zap.SugaredLogger) *LogObserver

func (*LogObserver) OnBleedingEdgeVersion

func (m *LogObserver) OnBleedingEdgeVersion(version, latestVersion semver.Version)

func (*LogObserver) OnDeprecatedVersion

func (m *LogObserver) OnDeprecatedVersion(version, latestVersion semver.Version)

func (*LogObserver) OnError

func (m *LogObserver) OnError(err error)

type OSError

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

OSError represents an OS error that is occurred during version checking.

func (*OSError) Unwrap

func (m *OSError) Unwrap() error

Unwrap unwraps the underlying error.

This is useful for further error kind checking, for example using "os.IsPermission(err)".

type Observer

type Observer interface {
	OnError(err error)
	OnDeprecatedVersion(version, latestVersion semver.Version)
	OnBleedingEdgeVersion(version, latestVersion semver.Version)
}

type Option

type Option func(o *options)

Option is a type alias for configuring version manager.

func WithClock

func WithClock(clock func() time.Time) Option

WithClock allows to assign a specific clock to the version manager.

By default the "time.Now" is used.

func WithVersion

func WithVersion(version semver.Version) Option

WithVersion allows to specify an application version.

By default the version obtained through link parameters is used.

func WithVersionFetcher

func WithVersionFetcher(versionFetcher VersionFetcher) Option

WithVersionFetcher allows to specify version fetcher.

By default the GitHub tag fetcher is used.

type UpdateError

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

UpdateError is an error that can occur while updating the latest known version.

type VersionFetcher

type VersionFetcher interface {
	Update(ctx context.Context) (semver.Version, error)
}

VersionFetcher is a thing that can update the current latest version number from external sources.

type VersionManager

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

func NewVersionManager

func NewVersionManager(fs FS, options ...Option) *VersionManager

func (*VersionManager) ValidateCurrentVersion

func (m *VersionManager) ValidateCurrentVersion(ctx context.Context) error

ValidateCurrentVersion validates that the current application version is the latest, reporting errors otherwise.

Is is possible that this method fails to open the version file for some reasons, for example because of permissions. It's the user's responsibility either to handle or to ignore the error returned. It's a good idea is to log such errors as warnings, but do not terminate the program.

type VersionMismatchError

type VersionMismatchError struct {
	Version       semver.Version
	LatestVersion semver.Version
}

VersionMismatchError indicates about version mismatch with the latest one.

func (*VersionMismatchError) Error

func (m *VersionMismatchError) Error() string

func (*VersionMismatchError) IsBleedingEdge

func (m *VersionMismatchError) IsBleedingEdge() bool

func (*VersionMismatchError) IsDeprecated

func (m *VersionMismatchError) IsDeprecated() bool

Jump to

Keyboard shortcuts

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