Documentation
¶
Overview ¶
Package groups resolves the @group references of a node set expression.
A group source is one of three things: a table written in the configuration, one group per value of a node attribute, which is what the genders file used to provide, or the output of a command run on an infrastructure host, which is how the workload manager is asked what it currently knows.
Index ¶
- Constants
- Variables
- type Options
- type Resolver
- func (r *Resolver) All(source string) (string, error)
- func (r *Resolver) DefaultSource() string
- func (r *Resolver) GroupsOf(node string) (map[string][]string, error)
- func (r *Resolver) GroupsOfContext(ctx context.Context, node string) (map[string][]string, error)
- func (r *Resolver) List(source string) ([]string, error)
- func (r *Resolver) Resolve(source, group string) (string, error)
- func (r *Resolver) Sources() []string
- type TargetFunc
Constants ¶
const ( PlaceholderGroup = "$GROUP" PlaceholderNode = "$NODE" )
Placeholders an exec source's argument vector may carry. They are substituted as whole arguments, never expanded by a shell, so a group name cannot turn into a command.
Variables ¶
var ErrCannotList = errors.New("the source cannot list its groups")
ErrCannotList is what a source answers when it has no way to list its groups, which is a property of its configuration rather than a failure.
var ErrNotDefined = errors.New("group not defined")
ErrNotDefined is what a source answers when it definitely has no group of the name asked for. It is the only answer that lets a bare @group move on to the next source.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
// Spec is the group configuration of the cluster.
Spec v1alpha1.GroupsSpec
// Inventory backs the attribute sources.
Inventory *inventory.Inventory
// Runner runs the commands of an exec source.
Runner transport.Runner
// Target resolves the host role an exec source runs on.
Target TargetFunc
// CacheDir holds the resolved groups of sources that ask to be cached.
// An empty directory keeps the cache in memory only.
CacheDir string
// Scope names what the resolver answers for, such as the site, cluster
// and context. The cache directory is shared by every configuration a
// user has, so an entry is only reused by a resolver of the same scope,
// for the same target host and the same command.
Scope string
// Timeout bounds each command an exec source runs. It is enforced on the
// target, the way every remote command is.
Timeout time.Duration
// Context bounds the commands an exec source runs. The nodeset resolver
// interface carries no context of its own, so it is held here.
Context context.Context
}
Options configure a resolver.
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver implements nodeset.Resolver over the configured group sources, and nodeset.Lister for the commands that list groups or complete their names.
func (*Resolver) DefaultSource ¶
DefaultSource implements nodeset.Lister.
func (*Resolver) GroupsOf ¶
GroupsOf returns the groups of one node, across every source that can answer the question.
A source that fails does not hide what the others found: the memberships that were found are returned together with an error naming each source that could not be asked. A source that has no way to list its groups is left out without an error.
func (*Resolver) GroupsOfContext ¶ added in v0.4.0
GroupsOfContext is GroupsOf with its lookups made, and reported, under ctx, such as the target of the node they are for in a pool, rather than under the resolver's own context. A lookup another caller made first is reported where that one made it.
func (*Resolver) Resolve ¶
Resolve implements nodeset.Resolver.
A bare @group reference looks in the default source first and then in every other source, so the groups of a small installation need no prefix. The search moves on only when a source answers that it has no such group. A source that cannot be asked stops it: the group may well be that source's, and another source's group of the same name is not an answer.