updater

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OSKeyName is the url parameter key to send to the checkin API for the operating system of the local netscale (e.g. windows, darwin, linux)
	OSKeyName = "os"

	// ArchitectureKeyName is the url parameter key to send to the checkin API for the architecture of the local netscale (e.g. amd64, x86)
	ArchitectureKeyName = "arch"

	// BetaKeyName is the url parameter key to send to the checkin API to signal if the update should be a beta version or not
	BetaKeyName = "beta"

	// VersionKeyName is the url parameter key to send to the checkin API to specific what version to upgrade or downgrade to
	VersionKeyName = "version"

	// ClientVersionName is the url parameter key to send the version that this netscale is currently running with
	ClientVersionName = "clientVersion"
)
View Source
const (
	DefaultCheckUpdateFreq = time.Hour * 24

	UpdateURL        = "https://update.argotunnel.com"
	StagingUpdateURL = "https://staging-update.argotunnel.com"

	LogFieldVersion = "version"
)

Variables

View Source
var (
	BuiltForPackageManager = ""
)

Functions

func Init

func Init(v string)

func IsSysV

func IsSysV() bool

func Update

func Update(c *cli.Context) error

Update is the handler for the update command from the command line

Types

type AutoUpdater

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

AutoUpdater periodically checks for new version of netscale.

func NewAutoUpdater

func NewAutoUpdater(updateDisabled bool, freq time.Duration, listeners *gracenet.Net, log *zerolog.Logger) *AutoUpdater

func (*AutoUpdater) Run

func (a *AutoUpdater) Run(ctx context.Context) error

func (*AutoUpdater) Update

func (a *AutoUpdater) Update(updateDisabled bool, newFreq time.Duration)

Update is the method to pass new AutoUpdaterConfigurable to a running AutoUpdater. It is safe to be called concurrently

type CheckResult

type CheckResult interface {
	Apply() error
	Version() string
	UserMessage() string
}

CheckResult is the behaviour resulting from checking in with the Update Service

func CheckForUpdate

func CheckForUpdate(options updateOptions) (CheckResult, error)

func NewWorkersVersion

func NewWorkersVersion(url, version, checksum, targetPath, userMessage string, isCompressed bool) CheckResult

NewWorkersVersion creates a new Version object. This is normally created by a WorkersService JSON checkin response url is where to download the file version is the version of this update checksum is the expected checksum of the downloaded file target path is where the file should be replace. Normally this the running netscale's path userMessage is a possible message to convey back to the user after having checked in with the Updater Service isCompressed tells whether the asset to update netscale is compressed or not

type Options

type Options struct {
	// IsBeta is for beta updates to be installed if available
	IsBeta bool

	// IsForced is to forcibly download the latest version regardless of the current version
	IsForced bool

	// RequestedVersion is the specific version to upgrade or downgrade to
	RequestedVersion string
}

Options are the update options supported by the

type Service

type Service interface {
	Check() (CheckResult, error)
}

Service is the functions to get check for new updates

func NewWorkersService

func NewWorkersService(currentVersion, url, targetPath string, opts Options) Service

NewWorkersService creates a new updater Service object.

type UpdateOutcome

type UpdateOutcome struct {
	Updated     bool
	Version     string
	UserMessage string
	Error       error
}

type VersionResponse

type VersionResponse struct {
	URL          string `json:"url"`
	Version      string `json:"version"`
	Checksum     string `json:"checksum"`
	IsCompressed bool   `json:"compressed"`
	UserMessage  string `json:"userMessage"`
	ShouldUpdate bool   `json:"shouldUpdate"`
	Error        string `json:"error"`
}

VersionResponse is the JSON response from the Workers API endpoint

type VersionWarningChecker

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

func StartWarningCheck

func StartWarningCheck(c *cli.Context) VersionWarningChecker

func (VersionWarningChecker) LogWarningIfAny

func (checker VersionWarningChecker) LogWarningIfAny(log *zerolog.Logger)

type WorkersService

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

WorkersService implements Service. It contains everything needed to check in with the WorkersAPI and download and apply the updates

func (*WorkersService) Check

func (s *WorkersService) Check() (CheckResult, error)

Check does a check in with the Workers API to get a new version update

type WorkersVersion

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

WorkersVersion implements the Version interface. It contains everything needed to perform a version upgrade

func (*WorkersVersion) Apply

func (v *WorkersVersion) Apply() error

Apply does the actual verification and update logic. This includes signature and checksum validation, replacing the binary, etc

func (*WorkersVersion) UserMessage

func (v *WorkersVersion) UserMessage() string

String returns a possible message to convey back to user after having checked in with the Updater Service. E.g. it can warn about the need to update the version currently running.

func (*WorkersVersion) Version

func (v *WorkersVersion) Version() string

String returns the version number of this update/release (e.g. 2020.08.05)

Jump to

Keyboard shortcuts

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