selector

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: GPL-3.0 Imports: 4 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 selector resolves target expressions against a named, tagged, grouped set of things. Hosts and printers are separate inventories with separate rules about what may be connected to, but the expression language is one language, and this is the only implementation of it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

type Set[T any] struct {
	// Noun names one item in error messages: "host", "printer".
	Noun string
	// Items is every candidate.
	Items []T
	// Groups maps a group name to member names. Members are assumed to have
	// been validated against Items when the inventory was built.
	Groups map[string][]string

	Name   func(T) string
	HasTag func(T, string) bool
}

Set describes what an expression is resolved against.

func (Set[T]) Select

func (s Set[T]) Select(expr string) ([]T, error)

Select resolves an expression into a de-duplicated, name-sorted list.

The expression is a comma separated list of terms. Each term is one of:

all          every item
@group       every member of the named group
#tag         every item carrying the tag
name         an item name, which may contain glob wildcards (web-*)

A term prefixed with '!' subtracts its matches from the set instead of adding them, so "@prod,!#retired" means "everything in prod that is not tagged retired". Exclusions are applied after all inclusions regardless of where they appear in the expression.

Jump to

Keyboard shortcuts

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