settings

package
v0.0.0-...-b0bff92 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ItemChange

type ItemChange struct {
	// Type is an enumeration indicating the type of settings change.
	Type int
	// Key is the setting being changed.
	Key string
	// OldValue is the previous value for the setting.
	OldValue interface{}
	// NewValue is the settings value resulting from this change.
	NewValue interface{}
}

ItemChange represents the change of an item in a settings collection.

func MakeAddition

func MakeAddition(key string, newVal interface{}) ItemChange

MakeAddition returns an itemChange indicating a modification of the input key, with its new value.

func MakeDeletion

func MakeDeletion(key string, oldVal interface{}) ItemChange

MakeDeletion returns an ItemChange indicating a deletion of the input key, with its old value.

func MakeModification

func MakeModification(key string, oldVal, newVal interface{}) ItemChange

MakeModification returns an ItemChange indicating a modification of the input key, with its old and new values.

func (*ItemChange) IsAddition

func (c *ItemChange) IsAddition() bool

IsAddition returns true if this change indicates a settings value not previously defines.

func (*ItemChange) IsDeletion

func (c *ItemChange) IsDeletion() bool

Is deletion returns true if this change indicates the removal of a previously operator-defined setting.

func (*ItemChange) IsModification

func (c *ItemChange) IsModification() bool

IsModification returns true if this change is an update of a previously operator-defined setting.

func (*ItemChange) String

func (c *ItemChange) String() string

String returns the item change in a readable format.

type ItemChanges

type ItemChanges []ItemChange

ItemChanges contains a slice of item changes in a config node. It implements the sort interface to sort the items changes by key.

func (ItemChanges) ApplyDeltaSource

func (c ItemChanges) ApplyDeltaSource(oldChanges ItemChanges) (ItemChanges, error)

ApplyDeltaSource uses this second-order delta to generate a first-older delta. It accepts a collection of changes representing a previous state. These are combined with the current changes to generate a new collection. It addresses a requirement that each branch change should represent the "from" state of master config at the time it is first created.

func (ItemChanges) EffectiveChanges

func (c ItemChanges) EffectiveChanges(defaults charm.Settings) map[string]interface{}

EffectiveChanges returns the effective changes resulting from the application of these changes to the input defaults.

func (ItemChanges) Len

func (c ItemChanges) Len() int

func (ItemChanges) Less

func (c ItemChanges) Less(i, j int) bool

func (ItemChanges) Map

func (c ItemChanges) Map() (map[string]ItemChange, error)

Map is a convenience method for working with collections of changes. It returns a map representation of the change collection, indexed with the change key. An error return indicates that the collection had duplicate keys.

func (ItemChanges) Swap

func (c ItemChanges) Swap(i, j int)

Jump to

Keyboard shortcuts

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