xconfig

package
v0.0.0-...-6295505 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NodesConverter      TNodesConverter
	OtherNodesConverter TOtherNodesConverter
)
View Source
var (
	ErrEditPending  = errors.New(`the configuration is already being edited (--discard to edit from the installed configuration or --recover to edit the unapplied config)`)
	ErrEditValidate = errors.New("validation error")
)
View Source
var (
	RegexpOperation = regexp.MustCompile(`(\$\(\(.+\)\))`)
	ErrExist        = errors.New("configuration does not exist")
	ErrNoKeyword    = errors.New("keyword does not exist")
	ErrType         = errors.New("type error")

	DriverGroups = set.New("ip", "volume", "disk", "fs", "share", "container", "app", "sync", "task")
)

Functions

func Diff

func Diff(a, b string) (string, error)

func Edit

func Edit(src string, mode EditMode, ref Referrer) error

Types

type Alert

type Alert struct {
	Path    naming.Path `json:"path"`
	Level   AlertLevel  `json:"level"`
	Kind    AlertKind   `json:"kind"`
	Key     key.T       `json:"key"`
	Driver  driver.ID   `json:"driver"`
	Comment string      `json:"comment"`
}

func (Alert) String

func (t Alert) String() string

func (Alert) StringWithoutMeta

func (t Alert) StringWithoutMeta() string

type AlertKind

type AlertKind int

func (AlertKind) MarshalJSON

func (t AlertKind) MarshalJSON() ([]byte, error)

func (AlertKind) String

func (t AlertKind) String() string

func (*AlertKind) UnmarshalJSON

func (t *AlertKind) UnmarshalJSON(b []byte) error

UnmarshalJSON unmashals a quoted json string to the enum value

type AlertLevel

type AlertLevel int

func (AlertLevel) MarshalJSON

func (t AlertLevel) MarshalJSON() ([]byte, error)

func (AlertLevel) String

func (t AlertLevel) String() string

func (*AlertLevel) UnmarshalJSON

func (t *AlertLevel) UnmarshalJSON(b []byte) error

UnmarshalJSON unmashals a quoted json string to the enum value

type Alerts

type Alerts []Alert

func ValidateFile

func ValidateFile(p string, ref Referrer) (Alerts, error)

func (Alerts) HasError

func (t Alerts) HasError() bool

func (Alerts) HasWarn

func (t Alerts) HasWarn() bool

func (Alerts) Render

func (t Alerts) Render() string

func (Alerts) String

func (t Alerts) String() string

func (Alerts) StringWithoutMeta

func (t Alerts) StringWithoutMeta() string

func (Alerts) Tree

func (t Alerts) Tree() *tree.Tree

type Converter

type Converter func(string) (interface{}, error)

type EditMode

type EditMode int
const (
	EditModeNormal EditMode = iota
	EditModeDiscard
	EditModeRecover
)

type ErrPostponedRef

type ErrPostponedRef struct {
	Ref string
	RID string
}

func NewErrPostponedRef

func NewErrPostponedRef(ref string, rid string) ErrPostponedRef

func (ErrPostponedRef) Error

func (t ErrPostponedRef) Error() string

type Referrer

type Referrer interface {
	KeywordLookup(key.T, string) keywords.Keyword
	IsVolatile() bool
	Config() *T

	// for reference private to the referrer. ex: path for an object
	Dereference(string) (string, error)

	// for scoping
	Nodes() ([]string, error)
	DRPNodes() ([]string, error)
	EncapNodes() ([]string, error)
}

Referrer is the interface implemented by node and object to provide a reference resolver using their private attributes.

type T

type T struct {
	ConfigFilePath string
	Path           naming.Path
	Referrer       Referrer
	NodeReferrer   Referrer
	// contains filtered or unexported fields
}

T exposes methods to read and write configurations.

func NewObject

func NewObject(p string, sources ...any) (*T, error)

NewObject configures and returns a T instance pointer. The first argument is the path of the configuration file to write to.

The path must be repeated as one of the following sources to read it. Accepted sources are []byte in ini format or a configuration file path containing ini formatted data.

func (T) Changed

func (t T) Changed() bool

func (*T) Commit

func (t *T) Commit() error

func (*T) CommitData

func (t *T) CommitData(configData rawconfig.T) error

func (*T) CommitDataTo

func (t *T) CommitDataTo(configData rawconfig.T, configPath string) error

func (*T) CommitDataToInvalid

func (t *T) CommitDataToInvalid(configData rawconfig.T, configPath string) error

func (*T) CommitInvalid

func (t *T) CommitInvalid() error

func (*T) CommitTo

func (t *T) CommitTo(configPath string) error

func (*T) CommitToInvalid

func (t *T) CommitToInvalid(configPath string) error

func (*T) DeleteSections

func (t *T) DeleteSections(sections ...string) error

DeleteSections deletes sections from the config and commit changes

func (*T) Doc

func (t *T) Doc(k key.T) (string, error)

func (*T) DriverGroupSet

func (t *T) DriverGroupSet(op keyop.T) error

func (*T) Eval

func (t *T) Eval(k key.T) (interface{}, error)

func (*T) EvalAs

func (t *T) EvalAs(k key.T, impersonate string) (interface{}, error)

EvalAs returns a key value,

  • contextualized for a node (by default the local node, customized by the impersonate option)
  • dereferenced
  • evaluated

func (*T) EvalAsNoConv

func (t *T) EvalAsNoConv(k key.T, impersonate string) (string, error)

func (*T) EvalKeywordAs

func (t *T) EvalKeywordAs(k key.T, kw keywords.Keyword, impersonate string) (interface{}, error)

func (*T) EvalNoConv

func (t *T) EvalNoConv(k key.T) (string, error)

func (*T) Get

func (t *T) Get(k key.T) string

func (*T) GetBool

func (t *T) GetBool(k key.T) bool

func (*T) GetBoolStrict

func (t *T) GetBoolStrict(k key.T) (bool, error)

func (*T) GetDuration

func (t *T) GetDuration(k key.T) *time.Duration

func (*T) GetDurationStrict

func (t *T) GetDurationStrict(k key.T) (*time.Duration, error)

func (*T) GetInt

func (t *T) GetInt(k key.T) int

func (*T) GetIntStrict

func (t *T) GetIntStrict(k key.T) (int, error)

func (*T) GetSize

func (t *T) GetSize(k key.T) *int64

func (*T) GetSizeStrict

func (t *T) GetSizeStrict(k key.T) (*int64, error)

func (*T) GetStrict

func (t *T) GetStrict(k key.T) (string, error)

func (*T) GetString

func (t *T) GetString(k key.T) string

func (*T) GetStringAs

func (t *T) GetStringAs(k key.T, impersonate string) string

func (*T) GetStringStrict

func (t *T) GetStringStrict(k key.T) (string, error)

func (*T) GetStringStrictAs

func (t *T) GetStringStrictAs(k key.T, impersonate string) (string, error)

func (*T) GetStrings

func (t *T) GetStrings(k key.T) []string

func (*T) GetStringsStrict

func (t *T) GetStringsStrict(k key.T) ([]string, error)

func (*T) HasKey

func (t *T) HasKey(k key.T) bool

HasKey returns true if the k exists

func (*T) HasKeyMatchingOp

func (t *T) HasKeyMatchingOp(kop keyop.T) bool

func (T) HasSectionString

func (t T) HasSectionString(s string) bool

func (*T) IsInDRPNodes

func (t *T) IsInDRPNodes(impersonate string) (bool, error)

func (*T) IsInEncapNodes

func (t *T) IsInEncapNodes(impersonate string) (bool, error)

func (*T) IsInNodes

func (t *T) IsInNodes(impersonate string) (bool, error)

func (*T) Keys

func (t *T) Keys(section string) []string

Keys returns the key names available in a section

func (*T) LoadRaw

func (t *T) LoadRaw(configData rawconfig.T) error

func (T) ModTime

func (t T) ModTime() time.Time

func (T) NewAlertCandidates

func (t T) NewAlertCandidates(k key.T, did driver.ID) Alert

func (T) NewAlertCapabilities

func (t T) NewAlertCapabilities(k key.T, did driver.ID) Alert

func (T) NewAlertDeprecated

func (t T) NewAlertDeprecated(k key.T, did driver.ID, release, replacedBy string) Alert

func (T) NewAlertEval

func (t T) NewAlertEval(k key.T, did driver.ID, comment string) Alert

func (T) NewAlertScoping

func (t T) NewAlertScoping(k key.T, did driver.ID) Alert

func (T) NewAlertUnknown

func (t T) NewAlertUnknown(k key.T, did driver.ID) Alert

func (T) NewAlertUnknownDriver

func (t T) NewAlertUnknownDriver(k key.T, did driver.ID) Alert

func (T) Ops

func (t T) Ops() []string

Ops returns the list of <section>.<option>[@<scope>]=<value> This format is used by the volume pools framework.

func (*T) PrepareDeleteSections

func (t *T) PrepareDeleteSections(sections ...string) error

PrepareDeleteSections deletes sections from the config without committing changes.

func (*T) PrepareSet

func (t *T) PrepareSet(kops ...keyop.T) error

PrepareSet applies key operations to config without committing changes.

func (*T) PrepareUnset

func (t *T) PrepareUnset(ks ...key.T) error

PrepareUnset unsets keywords from config without committing changes.

func (*T) PrepareUpdate

func (t *T) PrepareUpdate(deleteSections []string, unsetKeys []key.T, keyOps []keyop.T) error

PrepareUpdate applies:

1- delete sections
2- unset keywords
3- apply key operations

without committing changes.

func (T) Raw

func (t T) Raw() rawconfig.T

func (T) RawEvaluated

func (t T) RawEvaluated() (rawconfig.T, error)

func (T) RawEvaluatedAs

func (t T) RawEvaluatedAs(impersonate string) (rawconfig.T, error)

func (*T) Recommit

func (t *T) Recommit() error

func (*T) RecommitInvalid

func (t *T) RecommitInvalid() error

func (*T) RegisterPostCommit

func (t *T) RegisterPostCommit(fn func() error)

func (T) Reload

func (t T) Reload() error

func (T) SectionMap

func (t T) SectionMap(section string) map[string]string

func (T) SectionMapStrict

func (t T) SectionMapStrict(section string) (map[string]string, error)

func (T) SectionSig

func (t T) SectionSig(section string) string

func (T) SectionStrings

func (t T) SectionStrings() []string

SectionStrings returns list of section names.

func (*T) Set

func (t *T) Set(ops ...keyop.T) error

func (*T) Unset

func (t *T) Unset(ks ...key.T) error

Unset deletes keys and commits.

func (*T) Update

func (t *T) Update(deleteSections []string, unsetKeys []key.T, keyOps []keyop.T) error

Update applies:

1- delete sections
2- unset keywords
3- apply key operations

and commit changes.

func (T) Validate

func (t T) Validate() (Alerts, error)

type TNodesConverter

type TNodesConverter string

TNodesConverter is the type of converter used for the nodes keyword, which makes sure the local nodename is in the resulting []string.

func (TNodesConverter) Convert

func (t TNodesConverter) Convert(s string) (interface{}, error)

func (TNodesConverter) String

func (t TNodesConverter) String() string

type TOtherNodesConverter

type TOtherNodesConverter string

TOtherNodesConverter is the type of converter used for the drpnodes and encapnodes keyword, which accepts to return an empty list.

func (TOtherNodesConverter) Convert

func (t TOtherNodesConverter) Convert(s string) (interface{}, error)

func (TOtherNodesConverter) String

func (t TOtherNodesConverter) String() string

Jump to

Keyboard shortcuts

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