groups

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: GPL-3.0, LGPL-3.0 Imports: 18 Imported by: 0 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

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

View Source
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

View Source
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.

View Source
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 New

func New(opts Options) *Resolver

New builds a resolver.

func (*Resolver) All

func (r *Resolver) All(source string) (string, error)

All implements nodeset.Resolver.

func (*Resolver) DefaultSource

func (r *Resolver) DefaultSource() string

DefaultSource implements nodeset.Lister.

func (*Resolver) GroupsOf

func (r *Resolver) GroupsOf(node string) (map[string][]string, error)

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

func (r *Resolver) GroupsOfContext(ctx context.Context, node string) (map[string][]string, error)

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) List

func (r *Resolver) List(source string) ([]string, error)

List implements nodeset.Lister.

func (*Resolver) Resolve

func (r *Resolver) Resolve(source, group string) (string, error)

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.

func (*Resolver) Sources

func (r *Resolver) Sources() []string

Sources lists the configured source names in sorted order.

type TargetFunc

type TargetFunc func(role string) (transport.Target, error)

TargetFunc resolves the host role an exec source runs on.

Jump to

Keyboard shortcuts

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