Documentation
¶
Overview ¶
Package components provides abstractions and utilities for representing, querying, and managing software components within an Azure Linux project. We define a software component as being a buildable entity that may produce zero, one, or multiple packages when built.
Responsibilities ¶
This package is responsible for:
- Defining types and interfaces for component metadata, configuration, and relationships.
- Providing logic to enumerate and filter on collections of components within the environment.
- Integrating with the broader azldev environment (azldev.Env) and project configuration (projectconfig.ComponentConfig) to ensure context-sensitive component handling.
Usage Context ¶
This package is used by command implementations and automation logic that need to operate on sets of components, determine their properties, or perform actions such as builds, checks, or queries.
Index ¶
- Variables
- func AddComponentFilterOptionsToCommand(cmd *cobra.Command, filter *ComponentFilter)
- func FindAllSpecPaths(env *azldev.Env) ([]string, error)
- func GenerateComponentGroupNameCompletions(cmd *cobra.Command, args []string, toComplete string) (completions []string, directive cobra.ShellCompDirective)
- func GenerateComponentNameCompletions(cmd *cobra.Command, args []string, toComplete string) (completions []string, directive cobra.ShellCompDirective)
- type Component
- type ComponentDetails
- type ComponentFilter
- type ComponentGroup
- type ComponentGroupMember
- type ComponentSet
- type Resolver
- func (r *Resolver) FindAllComponents() (components *ComponentSet, err error)
- func (r *Resolver) FindComponents(filter *ComponentFilter) (components *ComponentSet, err error)
- func (r *Resolver) FindComponentsByNamePattern(pattern string) (components *ComponentSet, err error)
- func (r *Resolver) GetComponentByName(name string) (component Component, err error)
- func (r *Resolver) GetComponentGroupByName(componentGroupName string) (componentGroup *ComponentGroup, err error)
Constants ¶
This section is empty.
Variables ¶
var ErrComponentGroupNotFound = errors.New("component group not found")
Well-known errors.
Functions ¶
func AddComponentFilterOptionsToCommand ¶
func AddComponentFilterOptionsToCommand(cmd *cobra.Command, filter *ComponentFilter)
Adds to the given command a standardized set of command options for selecting components from the loaded configuration. This allows consistency across the commands that operate on components in some form. Those commands that only support operating on a fixed number of components (say, 1) can further extend the logic by adding their own checks.
func FindAllSpecPaths ¶
Collects file paths to all .spec files known about in this environment.
func GenerateComponentGroupNameCompletions ¶
func GenerateComponentGroupNameCompletions( cmd *cobra.Command, args []string, toComplete string, ) (completions []string, directive cobra.ShellCompDirective)
Function suitable for use as a cobra.ValidArgsFunction in a cobra.Command. Intended for use in generating completions for commands that take component group names as positional arguments.
func GenerateComponentNameCompletions ¶
func GenerateComponentNameCompletions( cmd *cobra.Command, args []string, toComplete string, ) (completions []string, directive cobra.ShellCompDirective)
Function suitable for use as a cobra.ValidArgsFunction in a cobra.Command. Intended for use in generating completions for commands that take component names as positional arguments.
Types ¶
type Component ¶
type Component interface {
// GetName returns the name of the component.
GetName() string
// GetConfig returns the static configuration for the component.
GetConfig() *projectconfig.ComponentConfig
// GetSpec returns an abstract object that represents the specification for building the component.
GetSpec() specs.ComponentSpec
// GetDetails inspects the component and retrieves more detailed information; non-trivial
// computation may be required to collect these details.
GetDetails() (info *ComponentDetails, err error)
}
Component provides abstract access to a *software component*; software components are buildable entities that can be used in a project, and which typically produce 1 or more packages when built.
type ComponentDetails ¶
type ComponentDetails struct {
// We embed the details retrieved from the component's spec as well.
specs.ComponentSpecDetails
// Config holds the static configuration for the component, including its name.
Config projectconfig.ComponentConfig
}
ComponentDetails encapsulates detailed information about a component, including both configuration information as well as detailed information that may be computationally intensive to collect. This information can be separately retrieved from the Component but this type provides a convenient data-oriented structure to encapsulate all details about a component in one place.
type ComponentFilter ¶
type ComponentFilter struct {
// Exact names to match against component groups. Does not support patterns or wildcards.
ComponentGroupNames []string
// Patterns to match against components; if no wildcards are present in the patterns, then an exact match
// is required, otherwise lack of matches is still success.
ComponentNamePatterns []string
// Paths to individual spec files. Does not support patterns or wild-carding.
SpecPaths []string
// If true, then *all* known components are included in the result set.
IncludeAllComponents bool
}
Describes a filter that selects a subset of components known within the environment's loaded configuration.
func (ComponentFilter) HasNoCriteria ¶
func (f ComponentFilter) HasNoCriteria() bool
HasNoCriteria returns true if the filter has no criteria set, meaning that it will never match any components.
type ComponentGroup ¶
type ComponentGroup struct {
// The group's name.
Name string
// A list of the group's members.
Components []ComponentGroupMember
}
ComponentGroup defines a component group. Component groups are used to group components, and optionally apply shared configuration or policy to them.
type ComponentGroupMember ¶
type ComponentGroupMember struct {
// Name of the component.
ComponentName string
// Path to the component's spec (optional).
SpecPath string
}
ComponentGroupMember defines a member of a ComponentGroup.
type ComponentSet ¶
type ComponentSet struct {
// contains filtered or unexported fields
}
Represents a unique logical set of components. Maintains insertion order.
func (*ComponentSet) Add ¶
func (cs *ComponentSet) Add(component Component)
Adds `component` to the component set, associating it with `name`. If a component with the same name is already present, it's replaced with `component`. Insertion order is maintained for stable enumeration.
func (*ComponentSet) Components ¶
func (cs *ComponentSet) Components() []Component
Retrieves the components in the set, in original insertion order.
func (*ComponentSet) Contains ¶
func (cs *ComponentSet) Contains(name string) bool
Checks if a component called `name` is present in the set.
func (*ComponentSet) Len ¶
func (cs *ComponentSet) Len() int
Returns the number of unique components in the set.
func (*ComponentSet) Names ¶
func (cs *ComponentSet) Names() []string
Retrieves the names of the components in the set, in original insertion order.
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver is a utility for resolving components in an environment.
func NewResolver ¶
NewResolver constructs a new Resolver for the given environment.
func (*Resolver) FindAllComponents ¶
func (r *Resolver) FindAllComponents() (components *ComponentSet, err error)
Finds *all* components defined in the environment.
func (*Resolver) FindComponents ¶
func (r *Resolver) FindComponents(filter *ComponentFilter) (components *ComponentSet, err error)
Given a component filter, finds all components defined in the environment that match the filter.
func (*Resolver) FindComponentsByNamePattern ¶
func (r *Resolver) FindComponentsByNamePattern(pattern string) (components *ComponentSet, err error)
Finds all components in the environment whose names match the given glob pattern.
func (*Resolver) GetComponentByName ¶
Finds the component with the given name defined in the provided environment. Returns error if it can't be found.
func (*Resolver) GetComponentGroupByName ¶
func (r *Resolver) GetComponentGroupByName(componentGroupName string) (componentGroup *ComponentGroup, err error)
Looks up the named component group in the provided environment. Returns error if it can't be found.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package components_testutils is a generated GoMock package.
|
Package components_testutils is a generated GoMock package. |