keywords

package
v3.0.0-rc67 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// ReferencesRID is the shape of a value naming one resource, as
	// "container#1".
	ReferencesRID = "rid"

	// ReferencesRIDs is the shape of a value naming resources separated by
	// whitespaces, as "fs#1 volume#1".
	ReferencesRIDs = "rids"

	// ReferencesRequires is the shape of the value of a *_requires keyword,
	// naming resources each followed by the states it requires them in, as
	// "ip#0 fs#0(down,stdby down)".
	ReferencesRequires = "requires"
)
View Source
const GroupOtherID = "other"

GroupOtherID is the group of the keywords not grouped yet, which a keyword naming no group belongs to.

View Source
const SourceRandom = "random"

SourceRandom is the source of a key generated: a random password the provision of the object writes once, on its leader node.

Variables

View Source
var ErrDriverNotFound = errors.New("driver not found")

ErrDriverNotFound is the error of a lookup of the keywords of a driver that does not exist.

View Source
var GroupOther = Group{
	ID:    GroupOtherID,
	Name:  "Other",
	Text:  NewText(fs, "text/group/other"),
	Order: 1000,
}

GroupOther is the group of a keyword naming none. Every keyword of the drivers, of the object kinds, of the node and of the cluster names one, as a test of the driverdb package verifies, so it holds none: it is what the api says of a keyword added without a group. It comes after the others.

Functions

func Moved

func Moved(did driver.ID, option string) (string, bool)

Moved is what to write instead of a keyword a driver no longer reads, and says whether the keyword is one of those: a keyword nothing knows about is a keyword nothing can say where it went.

The group answers for its drivers. A keyword moves out of a driver group as a whole here, which is what happened to the filesystem that made its own logical volume: every fs type had it.

func NewText

func NewText(fs embed.FS, path string) string

func SortDriverGroups

func SortDriverGroups(l []DriverGroup)

SortDriverGroups sorts the groups as a wizard shows them: by order, then by id, a group every resource has before the one of a driver of the same id and order, and then by driver.

Types

type DriverGroup

type DriverGroup struct {
	Driver string
	Group
}

DriverGroup is a group as the driver declaring it holds it: Driver is the driver id, as "ip.host", empty for a group every resource has and for the group of the keywords not grouped yet.

type Group

type Group struct {
	// ID is the name a keyword gives its group by, as "addressing".
	ID string

	// Name is the title of the group, as a wizard shows it.
	Name string

	// Text explains the topic of the group.
	Text string

	// Order is the rank of the group among the groups of a section,
	// the lowest first.
	Order int

	// Strategies are the ways to configure the group, when it has
	// alternatives that are not to be set together: an ip addressed
	// statically, or drawn from a network.
	Strategies []Strategy

	// Required says a section of a driver declaring the group follows
	// one of its strategies: one setting none of the keywords the
	// strategies use is refused by the validation, as an ip naming
	// neither an address nor a network to draw one from, which no
	// start can build.
	Required bool
}

Group is a topic of the keywords of a section: the keywords a reader looks at together, as the ones choosing the address of an ip. A wizard shows the keywords of a section by group, the groups by Order.

Every keyword belongs to one group, named by its Group field. A group is declared once, next to its keywords: the groups every resource has next to the keywords every resource has, and a driver adds its own to its manifest.

func (Group) StrategyUsing

func (t Group) StrategyUsing(option string) (Strategy, bool)

StrategyUsing returns the strategy of the group using the option, and whether one does.

type Index

type Index [2]string

func ParseIndex

func ParseIndex(s string) Index

func (Index) String

func (t Index) String() string

type Indices

type Indices []Index

func (Indices) Len

func (t Indices) Len() int

func (Indices) Less

func (t Indices) Less(i, j int) bool

func (Indices) Swap

func (t Indices) Swap(i, j int)

type Inherit

type Inherit int
const (
	InheritLeaf2Head Inherit = iota
	InheritHead2Leaf
	InheritLeaf
	InheritHead
)

func ParseInherit

func ParseInherit(s string) Inherit

func (Inherit) String

func (t Inherit) String() string

type KeySource

type KeySource struct {
	// Path is the datastore.
	Path naming.Path

	// Key is the name of the key.
	Key string

	// Source is the uri the key is seeded from: an http or https url
	// fetched, SourceRandom generated, or the path of a file of the
	// node.
	Source string
}

KeySource is a key of a sec or a cfg a keyword names with the source seeding it when the datastore does not hold it.

func (KeySource) IsRandom

func (t KeySource) IsRandom() bool

IsRandom says the key is generated rather than read from a source.

type Keyword

type Keyword struct {
	Section string
	Option  string
	Attr    string

	// Scopable means the keyword can have a different value on nodes, drpnodes, encapnodes or a specific node.
	Scopable bool

	// Required means the keyword mean be set, and thus disregards the default value.
	Required bool

	// Converter is the routine converting the string value into the
	// keyword expected type. A nil Converter means no conversion.
	Converter converters.Converter

	// Validate, when set, says whether a value is one the keyword
	// takes, for the values no Converter or Candidates tell apart: a
	// value refused is an error of the configuration validation, so it
	// is refused when written rather than when used. It is given the
	// value evaluated, and never an empty one.
	Validate func(value string) error

	// Text is a text explaining the role of the keyword.
	Text string

	// Group is the id of the group of the keyword, the topic a wizard
	// shows it under. Empty is the group of the keywords not grouped
	// yet, GroupOtherID.
	Group string

	// DefaultText is a text explaining the default value.
	DefaultText string

	// Example demonstrates the keyword usage.
	Example string

	// Default is the value returned when the non-required keyword is not set.
	Default string

	// DefaultOption is the name of the option looked up in the
	// DEFAULT section if the keyword is not set. If not set,
	// the string in the Option field is looked up in the DEFAULT
	// section.
	DefaultOption string

	// Candidates is the list of accepted values. An empty list.
	Candidates []string

	// Depends is a list of key-value conditions to meet to accept this keyword in a config.
	Depends []keyop.T

	// Kind limits the scope of this keyword to the object with kind matching this mask.
	Kind naming.Kinds

	// Provisioning is set to true for keywords only used for resource provisioning
	Provisioning bool

	// ProvisioningRequired means the provision of the resource fails
	// without a value: the size of a logical volume, the devices of a
	// md. It is set on Provisioning keywords only, and not on one with
	// a default the provision works with. Unlike Required, a resource
	// configured on what a sysadmin provisioned runs without it.
	ProvisioningRequired bool

	// StopToChange means the value says what the resource holds on a
	// node once started, as the mount point of a filesystem or the
	// address of an ip: a change is refused while the resource is
	// up on a node, as its stop would act on the new value and leave
	// what the former one set up there. The resource is stopped
	// first, or root forces the change.
	StopToChange bool

	// Types limits the scope of the keyword to sections with matching type value
	Types []string

	// Aliases defines alternate names of the keyword.
	Aliases []string

	// Inherit defines weither DEFAULT.<name> overrides <rid>.<name> (Head2Leaf), or
	// <rid>.<name> overrides DEFAULT.<name> (Leaf2Head, the default), or only <rid>.<name>
	// is used (Leaf).
	Inherit Inherit

	// Since is the release the keyword appeared in. It is read by an
	// operator asking whether the agent they run has it, and by the
	// documentation, which says it next to the keyword.
	//
	// It is not filled for the keywords that predate it: what a release
	// has is what its own documentation lists, and when a keyword
	// appeared is answered for the ones added from here on. A keyword
	// that is gone is answered by the documentation of the releases that
	// had it, which no field of a later binary could.
	Since string

	// Deprecated is the release where the keyword has been deprecated. Users can
	// expect the keyword to be unsupported in the next release.
	Deprecated string

	// ReplacedBy means the keyword is deprecated but another keyword can be used instead.
	ReplacedBy string

	// Minimal force the keyword to be included in the minimal configlet of the driver doc.
	Minimal bool

	// RedactSecret means the keyword value is a secret: it is hidden on
	// config show with the flag --redact-secrets, and an object
	// configuration can not reference the one of the node.
	RedactSecret bool

	// DeprecatedValue is a regular expression matching the values om
	// still accepts and no longer recommends, and DeprecatedValueText
	// says what to write instead.
	//
	// The keyword itself is the one to use. It is one of the forms it
	// takes that is on its way out: the size of a logical volume written
	// as the share of its volume group lvm2 computes, which om never
	// learns the result of.
	DeprecatedValue     string
	DeprecatedValueText string

	// Arithmetic means an expression written "$(...)" in this keyword's
	// value is computed.
	//
	// It is implied by a converter that makes a number, which is most of
	// the keywords a sum makes sense in. It is declared where the keyword
	// holds a number but converts to none, because it also accepts a form
	// no number can express: the size of a logical volume, which lvm2
	// also takes as a share of the volume group it is carved from.
	Arithmetic bool

	// Recorded means the value names a thing that now exists, and was
	// written into the configuration when that thing was made: the id an
	// object was created with, the uuid an md array was created with and
	// is assembled by. om writes it where om makes the thing, and an
	// administrator who makes it themselves writes it themselves.
	//
	// A configuration copied to make another thing must not carry it, or
	// the copy names the original. So these are reset when an object is
	// cloned: by "om <path> create --config <source>" unless --restore is
	// given, and by a virtual pool copying its template volume, where a
	// copy keeping the array uuid assembles the template's array under
	// its own name instead of making one.
	Recorded bool

	// KeySources, when set, returns the keys of a sec or a cfg the
	// value names with a source to seed them from: the install lines
	// and the environment references written "source <uri>". It is
	// given the value evaluated, its relative datastore paths being of
	// the namespace given, and errs on a value it cannot read, which
	// the resource refuses at its action.
	//
	// The object reads them to refuse two keywords seeding a key from
	// two sources, or a key of a datastore of another namespace, and
	// to seed the keys missing at its provision and its start.
	KeySources func(value []string, namespace string) ([]KeySource, error)

	// References, when set, says the value names resources of the object:
	// the sections of the groups it lists, in the shape it says.
	References *References
}

Keyword represents a configuration option in an object or node configuration file

func (*Keyword) Clone

func (t *Keyword) Clone() *Keyword

func (*Keyword) DefaultKey

func (t *Keyword) DefaultKey() key.T

func (*Keyword) Doc

func (t *Keyword) Doc(w io.Writer, depth int, kind naming.Kind, section string, rbacDoc RBACDoc) error

func (*Keyword) GroupID

func (t *Keyword) GroupID() string

GroupID returns the id of the group of the keyword, the one of the keywords not grouped yet when it names none.

func (*Keyword) Name

func (t *Keyword) Name() string

Name is a func required by the resource manifest Attr interface

func (*Keyword) SetValue

func (t *Keyword) SetValue(r, v interface{}) error

func (*Keyword) String

func (t *Keyword) String() string

type RBACDoc

type RBACDoc func(kind naming.Kind, section, option string, types []string) string

RBACDoc returns the sentence the documentation of a keyword shows about the grant a user needs to set it through the api, or an empty string when any user may set it.

It is a callback rather than a call into the rbac policy because every driver imports this package, and the policy reads the install grammar of core/datarecv, which imports this package back. The caller of Doc, which sits above both, passes doc.KeywordGrantDoc.

types are the drivers the keyword belongs to, empty for a keyword of every driver of the section: a keyword of a driver the user may not choose needs the grant choosing it does.

type References

type References struct {
	// Groups are the driver groups of the resources the value may name,
	// as "container". Empty is any resource group.
	Groups []string

	// Shape is how the value writes the resources it names:
	// ReferencesRID, ReferencesRIDs or ReferencesRequires.
	Shape string
}

References says what a keyword value names of the resources of its object, for a designer to offer the sections the configuration has, and for the validation to warn of a value naming none.

func (*References) Clone

func (t *References) Clone() *References

Clone returns a copy of the references sharing no slice with t.

func (References) GroupsText

func (t References) GroupsText() string

GroupsText says the groups the value may name a resource of, as "ip or container".

func (References) HasGroup

func (t References) HasGroup(group string) bool

HasGroup reports whether the value may name a resource of the driver group.

func (References) String

func (t References) String() string

String says what the value names, as "container rid", "fs|volume rids" or "requires", the groups left out when any resource is named.

type Store

type Store []*Keyword

func (Store) ByOption

func (t Store) ByOption(option string) Store

func (Store) Doc

func (t Store) Doc(w io.Writer, kind naming.Kind, driver, asked string, depth int, rbacDoc RBACDoc) error

func (Store) DriverKeywords

func (t Store) DriverKeywords(section, typ string, kind naming.Kind) ([]*Keyword, error)

func (Store) KeywordsByDriver

func (t Store) KeywordsByDriver(kind naming.Kind) map[Index]map[string]*Keyword

func (Store) Len

func (t Store) Len() int

func (Store) Less

func (t Store) Less(i, j int) bool

func (Store) Lookup

func (t Store) Lookup(k key.T, kind naming.Kind, sectionType string) *Keyword

func (Store) MatchingOption

func (t Store) MatchingOption(pattern string) (store Store)

MatchingOption returns the keywords whose option matches the fnmatch pattern, as "sched*", in every section of the store.

func (Store) Swap

func (t Store) Swap(i, j int)

func (Store) WithKind

func (t Store) WithKind(kind naming.Kind) (store Store)

func (Store) WithOption

func (t Store) WithOption(option string) (store Store)

WithOption returns the keywords of the option, in every section.

type Strategy

type Strategy struct {
	// ID is the name of the strategy, as "static".
	ID string

	// Name is the title of the strategy, as a wizard shows it.
	Name string

	// Text explains when to choose the strategy, and what it does.
	Text string

	// Uses are the options of the keywords the strategy sets.
	Uses []string

	// Excludes are the options of the keywords the strategy leaves
	// unset, as they belong to another strategy.
	Excludes []string

	// Requires are the options of the keywords a section following
	// the strategy sets too, as the device of the node a static
	// address is plumbed on: the validation refuses the section
	// missing one. They may be of another group.
	Requires []string

	// When are the conditions on a selector keyword choosing the
	// strategy, as "topology=flex", written as the Depends of a
	// keyword. Empty when no keyword chooses it, the keywords set
	// telling which strategy a configuration follows.
	When []keyop.T
}

Strategy is one way to configure a group among its alternatives: the keywords it sets, and the keywords of the other ways it leaves unset. A configuration setting a keyword a strategy excludes next to one it uses is warned of by the validation, as it says two ways at once.

Jump to

Keyboard shortcuts

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