nebraska

package
v0.0.0-...-e560ebb Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2021 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Overview

Package nebraska implements a fake Omaha server based on "nebraska.py".

Index

Constants

View Source
const Script = "/opt/tls/fake_omaha/nebraska.py"

Script is the path of nebraska.py. Currently we download and build 'nebraska.py' into drone images at this path. TODO(guocb): Package 'nebraska.py' as part of TLS implementation.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	CriticalUpdate         bool `json:"critical_update"`
	ReturnNoupdateStarting int  `json:"return_noupdate_starting"`
}

Config is the Nebraska configurations.

type Environment

type Environment interface {
	// DownloadMetadata downloads update metadata for specified build and type
	// of payloads from GS to a temporary directory and returns the path of it.
	// It is the caller's responsibility to remove the temporary directory after
	// use.
	DownloadMetadata(ctx context.Context, gsPathPrefix string, payloads []*tls.FakeOmaha_Payload) (string, error)
	StartNebraska([]string) (Process, error)
}

Environment is the runtime dependencies, e.g. networking, etc. of the implementation. The main goal of it is for unit test.

func NewEnvironment

func NewEnvironment() Environment

NewEnvironment returns a new instance of Environment that talks to GS and runs a real nebraska process.

type Process

type Process interface {
	Args() []string
	Stop() error
}

Process represents an OS process. It is mainly for unit tests.

type Server

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

Server represents a running instance of 'nebraska.py'.

func NewServer

func NewServer(ctx context.Context, env Environment, gsPathPrefix string, payloads []*tls.FakeOmaha_Payload, updatePayloadsAddress string) (*Server, error)

NewServer starts a Nebraska process and returns a new instance of Server. gsPathPrefix is the GS path to the build of the update, e.g. "gs://chromeos-image-archive/banjo-release/R90-13809.0.0". The update metadata must exist there, so we can download them by appending the file name to this prefix. updatePayloadsAddress is the cache server URL from which we can download payloads, e.g. "http://<server>:<port>/download/banjo-release/R90-13809.0.0".

func (*Server) Close

func (n *Server) Close() error

Close terminates the nebraska server process and cleans up all temp dirs/files. This function is not concurrency safe.

func (*Server) Port

func (n *Server) Port() int

Port returns the port of the Nebraska.

func (*Server) UpdateConfig

func (n *Server) UpdateConfig(c Config) error

UpdateConfig configures the started Nebraska.

Jump to

Keyboard shortcuts

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