configstate

package
v0.0.0-...-677ed08 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2016 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package configstate implements the manager and state aspects responsible for the configuration of snaps.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Change

func Change(s *state.State, snapName string, patchValues map[string]interface{}) *state.TaskSet

Change returns a taskset required to apply the given configuration patch.

func IsNoOption

func IsNoOption(err error) bool

IsNoOption returns whether the provided error is a *NoOptionError.

Types

type ConfigManager

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

ConfigManager is responsible for the maintenance of per-snap configuration in the system state.

func Manager

func Manager(s *state.State, hookManager *hookstate.HookManager) (*ConfigManager, error)

Manager returns a new ConfigManager.

type NoOptionError

type NoOptionError struct {
	SnapName string
	Key      string
}

NoOptionError indicates that a config option is not set.

func (*NoOptionError) Error

func (e *NoOptionError) Error() string

type Transaction

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

Transaction holds a copy of the configuration originally present in the provided state which can be queried and mutated in isolation from concurrent logic. All changes performed into it are persisted back into the state at once when Commit is called.

Transactions are safe to access and modify concurrently.

func ContextTransaction

func ContextTransaction(context *hookstate.Context) *Transaction

ContextTransaction retrieves the transaction cached within the context (and creates one if it hasn't already been cached).

func NewTransaction

func NewTransaction(st *state.State) *Transaction

NewTransaction creates a new configuration transaction initialized with the given state.

The provided state must be locked by the caller.

func (*Transaction) Commit

func (t *Transaction) Commit()

Commit saves to the state the configuration changes made in the transaction.

The state associated with the transaction must be locked by the caller.

func (*Transaction) Get

func (t *Transaction) Get(snapName, key string, result interface{}) error

Get unmarshals into result the cached value of the provided snap's configuration key. If the key does not exist, an error of type *NoOptionError is returned.

Transactions do not see updates from the current state or from other transactions.

func (*Transaction) GetMaybe

func (t *Transaction) GetMaybe(snapName, key string, result interface{}) error

GetMaybe unmarshals into result the cached value of the provided snap's configuration key. If the key does not exist, no error is returned.

Transactions do not see updates from the current state or from other transactions.

func (*Transaction) Set

func (t *Transaction) Set(snapName, key string, value interface{}) error

Set sets the provided snap's configuration key to the given value.

The provided value must marshal properly by encoding/json. Changes are not persisted until Commit is called.

Jump to

Keyboard shortcuts

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