Documentation ¶
Index ¶
- func DeleteSnapConfig(st *state.State, snapName string) error
- func DiscardRevisionConfig(st *state.State, snapName string, rev snap.Revision) error
- func GetFeatureFlag(tr Conf, feature features.SnapdFeature) (bool, error)
- func GetSnapConfig(st *state.State, snapName string) (*json.RawMessage, error)
- func IsNoOption(err error) bool
- func ParseKey(key string) (subkeys []string, err error)
- func PatchConfig(snapName string, subkeys []string, pos int, config interface{}, ...) (interface{}, error)
- func RestoreRevisionConfig(st *state.State, snapName string, rev snap.Revision) error
- func SaveRevisionConfig(st *state.State, snapName string, rev snap.Revision) error
- func SetSnapConfig(st *state.State, snapName string, snapcfg *json.RawMessage) error
- type Conf
- type NoOptionError
- type Transaction
- func (t *Transaction) Changes() []string
- func (t *Transaction) Commit()
- func (t *Transaction) Get(snapName, key string, result interface{}) error
- func (t *Transaction) GetMaybe(instanceName, key string, result interface{}) error
- func (t *Transaction) Set(instanceName, key string, value interface{}) error
- func (t *Transaction) State() *state.State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteSnapConfig ¶
DeleteSnapConfig removed configuration of given snap from the state.
func DiscardRevisionConfig ¶
DiscardRevisionConfig removes configuration snapshot of given snap/revision. If no configuration exists for given revision it does nothing (no error). The caller is responsible for locking the state.
func GetFeatureFlag ¶
func GetFeatureFlag(tr Conf, feature features.SnapdFeature) (bool, error)
GetFeatureFlag returns the value of a given feature flag.
func GetSnapConfig ¶
GetSnapConfig retrieves the raw configuration of a given snap.
func IsNoOption ¶
IsNoOption returns whether the provided error is a *NoOptionError.
func PatchConfig ¶
func RestoreRevisionConfig ¶
RestoreRevisionConfig restores a given revision of snap configuration into config -> snapName. If no configuration exists for given revision it does nothing (no error). The caller is responsible for locking the state.
func SaveRevisionConfig ¶
SaveRevisionConfig makes a copy of config -> snapSnape configuration into the versioned config. It doesn't do anything if there is no configuration for given snap in the state. The caller is responsible for locking the state.
func SetSnapConfig ¶
SetSnapConfig replaces the configuration of a given snap.
Types ¶
type Conf ¶
type Conf interface { Get(snapName, key string, result interface{}) error Set(snapName, key string, value interface{}) error Changes() []string State() *state.State }
Conf is an interface describing both state and transaction.
type NoOptionError ¶
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 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) Changes ¶
func (t *Transaction) Changes() []string
Changes returns the changing keys associated with this transaction
func (*Transaction) Commit ¶
func (t *Transaction) Commit()
Commit applies to the state the configuration changes made in the transaction and updates the observed configuration to the result of the operation.
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. The provided key may be formed as a dotted key path through nested maps. For example, the "a.b.c" key describes the {a: {b: {c: value}}} map.
Transactions do not see updates from the current state or from other transactions.
func (*Transaction) GetMaybe ¶
func (t *Transaction) GetMaybe(instanceName, 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(instanceName, key string, value interface{}) error
Set sets the provided snap's configuration key to the given value. The provided key may be formed as a dotted key path through nested maps. For example, the "a.b.c" key describes the {a: {b: {c: value}}} map. When the key is provided in that form, intermediate maps are mutated rather than replaced, and created when necessary.
The provided value must marshal properly by encoding/json. Changes are not persisted until Commit is called.
func (*Transaction) State ¶
func (t *Transaction) State() *state.State
State returns the system State