config

package
v3.0.0-...-7ba4d6b Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: Apache-2.0, BSD-3-Clause, MIT Imports: 7 Imported by: 0

Documentation

Overview

Package config defines and handles the parsing and provision of configurations for the runner. This package should be refered to, and should not take dependencies on other parts of this runner.

1. A given configuation file has one or more variations configured. 2. Each variation has a name, and one or more handlers configured. 3. Each handler maps to a specific struct.

 <variation1 name>:
	  <handler1 name>:
	    <handler1 characteristics>
	  <handler2 name>:
	    <handler2 characteristics>

 <variation2 name>:
	  <handler1 name>:
	    <handler1 characteristics>
	  <handler2 name>:
	    <handler2 characteristics>

Handler has it's own name, and an associated characterisitc type.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HandlerMetadata

type HandlerMetadata interface {
	// ConfigURN represents the urn for the handle.
	ConfigURN() string

	// ConfigCharacteristic returns the type of the detailed configuration for the handler.
	// A characteristic type must have a useful zero value that defines the default behavior.
	ConfigCharacteristic() reflect.Type
}

HandlerMetadata is required information about handler configurations. Handlers have an URN, which key for how configurations refer to them, and a Characteristic type, which is it's own individual configuration.

Characteristic types must have useful zero values, representing the default configuration for the handler.

type HandlerRegistry

type HandlerRegistry struct {
	// contains filtered or unexported fields
}

HandlerRegistry stores known handlers and their associated metadata needed to parse the YAML configuration.

func NewHandlerRegistry

func NewHandlerRegistry() *HandlerRegistry

NewHandlerRegistry creates an initialized HandlerRegistry.

func (*HandlerRegistry) GetVariant

func (r *HandlerRegistry) GetVariant(name string) *Variant

GetVariant returns the Variant with the given name. If none exist, GetVariant returns nil.

func (*HandlerRegistry) LoadFromYaml

func (r *HandlerRegistry) LoadFromYaml(in []byte) error

LoadFromYaml takes in a yaml formatted configuration and eagerly processes it for errors.

All handlers are validated against their registered characteristic, and it is an error to have configurations for unknown handlers

func (*HandlerRegistry) RegisterHandlers

func (r *HandlerRegistry) RegisterHandlers(mds ...HandlerMetadata)

RegisterHandlers is about registering the metadata for handler configurations.

func (*HandlerRegistry) UsedHandlers

func (r *HandlerRegistry) UsedHandlers() []string

UsedHandlers returns the IDs of all handlers used in variations.

func (*HandlerRegistry) Variants

func (r *HandlerRegistry) Variants() []string

Variants returns the IDs of all variations loaded into this registry.

type Variant

type Variant struct {
	// contains filtered or unexported fields
}

Variant represents a single complete configuration of all handlers in the registry.

func (*Variant) GetCharacteristics

func (v *Variant) GetCharacteristics(handler string) any

GetCharacteristics returns the characteristics of this handler within this variant.

If the variant doesn't configure this handler, the zero value of the handler characteristic type will be returned. If the handler is unknown to the registry this variant came from, a nil will be returned.

Jump to

Keyboard shortcuts

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