config

package
v0.0.0-...-ff5f600 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2016 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package config handles configuration state passed across instances of the device manager.

The State object captures setting that the device manager needs to be aware of when it starts. This is passed to the first invocation of the device manager, and then passed down from old device manager to new device manager upon update. The device manager has an implementation-dependent mechanism for parsing and passing state, which is encapsulated by the state sub-package (currently, the mechanism uses environment variables). When instantiating a new instance of the device manager service, the developer needs to pass in a copy of State. They can obtain this by calling Load, which captures any config state passed by a previous version of device manager during update. Any new version of the device manager must be able to decode a previous version's config state, even if the new version changes the mechanism for passing this state (that is, device manager implementations must be backward-compatible as far as accepting and passing config state goes). TODO(caprita): add config state versioning?

Index

Constants

View Source
const (
	// EnvelopeEnv is the name of the environment variable that holds the
	// serialized device manager application envelope.
	EnvelopeEnv = "V23_DM_ENVELOPE"
	// PreviousEnv is the name of the environment variable that holds the
	// path to the previous version of the device manager.
	PreviousEnv = "V23_DM_PREVIOUS"
	// OriginEnv is the name of the environment variable that holds the
	// object name of the application repository that can be used to
	// retrieve the device manager application envelope.
	OriginEnv = "V23_DM_ORIGIN"
	// RootEnv is the name of the environment variable that holds the
	// path to the directory in which device manager workspaces are
	// created.
	RootEnv = "V23_DM_ROOT"
	// CurrentLinkEnv is the name of the environment variable that holds
	// the path to the soft link that points to the current device manager.
	CurrentLinkEnv = "V23_DM_CURRENT"
	// HelperEnv is the name of the environment variable that holds the path
	// to the suid helper used to start apps as specific system users.
	HelperEnv = "V23_DM_HELPER"
)

Variables

This section is empty.

Functions

func QuoteEnv

func QuoteEnv(env []string) (ret []string)

QuoteEnv wraps environment variable values in double quotes, making them suitable for inclusion in a bash script.

Types

type State

type State struct {
	// Name is the device manager's object name.  Must be non-empty.
	Name string
	// Envelope is the device manager's application envelope.  If nil, any
	// envelope fetched from the application repository will trigger an
	// update.
	Envelope *application.Envelope
	// Previous holds the local path to the previous version of the device
	// manager.  If empty, revert is disabled.
	Previous string
	// Root is the directory on the local filesystem that contains
	// the applications' workspaces.  Must be non-empty.
	Root string
	// Origin is the application repository object name for the device
	// manager application.  If empty, update is disabled.
	Origin string
	// CurrentLink is the local filesystem soft link that should point to
	// the version of the device manager binary/script through which device
	// manager is started.  Device manager is expected to mutate this during
	// a self-update.  Must be non-empty.
	CurrentLink string
	// Helper is the path to the setuid helper for running applications as
	// specific users.
	Helper string
}

State specifies how the device manager is configured. This should encapsulate what the device manager needs to know and/or be able to mutate about its environment.

func Load

func Load() (*State, error)

Load reconstructs the config state passed to the device manager (presumably by the parent device manager during an update). Currently, this is done via environment variables.

func (*State) Save

func (c *State) Save(envelope *application.Envelope) ([]string, error)

Save serializes the config state meant to be passed to a child device manager during an update, returning a slice of "key=value" strings, which are expected to be stuffed into environment variable settings by the caller.

func (*State) Validate

func (c *State) Validate() error

Validate checks the config state.

Jump to

Keyboard shortcuts

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