update

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 20, 2021 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

package update contains the types and functions used by the update system.

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultOptions are the default options to use when creating an update
	// client.
	DefaultOptions = Options{
		RootDirectory:     "/var/lib/orbit",
		ServerURL:         defaultURL,
		RootKeys:          defaultRootKeys,
		LocalStore:        client.MemoryLocalStore(),
		InsecureTransport: false,
		Platform:          constant.PlatformName,
		OrbitChannel:      "stable",
		OsquerydChannel:   "stable",
	}
)

Functions

func CheckFileHash

func CheckFileHash(meta *data.TargetFileMeta, localPath string) error

CheckFileHash checks the file at the local path against the provided hash functions.

Types

type Options

type Options struct {
	// RootDirectory is the root directory from which other directories should be referenced.
	RootDirectory string
	// ServerURL is the URL of the update server.
	ServerURL string
	// InsecureTransport skips TLS certificate verification in the transport if
	// set to true. Best to leave this on, but due to the file signing any
	// tampering by a MitM should be detectable.
	InsecureTransport bool
	// RootKeys is the JSON encoded root keys to use to bootstrap trust.
	RootKeys string
	// LocalStore is the local metadata store.
	LocalStore client.LocalStore
	// Platform is the target of the platform to update for. In the default
	// options this is the current platform.
	Platform string
	// OrbitChannel is the update channel to use for Orbit.
	OrbitChannel string
	// OsquerydChannel is the update channel to use for osquery (osqueryd).
	OsquerydChannel string
}

Options are the options that can be provided when creating an Updater.

type Runner

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

Runner is a specialized runner for the updater. It is designed with Execute and Interrupt functions to be compatible with oklog/run.

func NewRunner

func NewRunner(client *Updater, opt RunnerOptions) (*Runner, error)

NewRunner creates a new runner with the provided options. The runner must be started with Execute.

func (*Runner) Execute

func (r *Runner) Execute() error

Execute begins a loop checking for updates.

func (*Runner) Interrupt

func (r *Runner) Interrupt(err error)

type RunnerOptions

type RunnerOptions struct {
	// CheckInterval is the interval to check for updates.
	CheckInterval time.Duration
	// Targets is the names of the artifacts to watch for updates.
	Targets map[string]string
}

RunnerOptions is options provided for the update runner.

type Updater

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

Updater is responsible for managing update state.

func New

func New(opt Options) (*Updater, error)

New creates a new updater given the provided options. All the necessary directories are initialized.

func (*Updater) Download

func (u *Updater) Download(repoPath, localPath string) error

Download downloads the target to the provided path. The file is deleted and an error is returned if the hash does not match.

func (*Updater) Get

func (u *Updater) Get(target, channel string) (string, error)

Get returns the local path to the specified target. The target is downloaded if it does not yet exist locally or the hash does not match.

func (*Updater) LocalPath

func (u *Updater) LocalPath(target, channel string) string

func (*Updater) Lookup

func (u *Updater) Lookup(target, channel string) (*data.TargetFileMeta, error)

Lookup looks up the provided target in the local target metadata. This should be called after UpdateMetadata.

func (*Updater) RepoPath

func (u *Updater) RepoPath(target, channel string) string

func (*Updater) Targets

func (u *Updater) Targets() (data.TargetFiles, error)

Targets gets all of the known targets

func (*Updater) UpdateMetadata

func (u *Updater) UpdateMetadata() error

Directories

Path Synopsis
package badgerstore implements the go-tuf LocalStore interface using Badger as a backing store.
package badgerstore implements the go-tuf LocalStore interface using Badger as a backing store.

Jump to

Keyboard shortcuts

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