config

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package config contains APIs used to work with injector configuration files, which are formed by FilenameOrchestrionToolGo and FilenameOrchestrionYML files.

Index

Constants

View Source
const FilenameOrchestrionToolGo = "orchestrion.tool.go"
View Source
const FilenameOrchestrionYML = "orchestrion.yml"

Variables

View Source
var ErrInvalidGoPackage = errors.New("no .go files in package")

Functions

func HasConfig

func HasConfig(ctx context.Context, pkgLoader PackageLoader, pkg *packages.Package, validate bool) (bool, error)

HasConfig determines whether the specified package contains injector configuration, and optionally validates it. If the PackageLoader is nil, a default implementation is used.

func ValidateObject

func ValidateObject(obj map[string]any) error

ValidateObject checks the provided object for conformance to the embedded JSON schema. Returns an error if the object does not conform to the schema.

func Visit added in v1.1.0

func Visit(cfg Config, visitor Visitor) error

Visit calls the visitor for each configuration found in the specified root Config.

Types

type Config

type Config interface {
	// Aspects returns all aspects defined in this configuration in a single list.
	Aspects() []*aspect.Aspect
	// contains filtered or unexported methods
}

Config represents an injector's configuration. It can be obtained using Loader.Load.

type File added in v1.1.0

type File interface {
	Name() string
	Description() string
	Caveats() string
	Icon() string

	OwnAspects() []*aspect.Aspect
}

type Loader

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

Loader is a facility to load configuration from available sources.

func NewLoader

func NewLoader(pkgLoader PackageLoader, dir string, validate bool) *Loader

NewLoader creates a new Loader in the specified directory.

If the [PackageLoader] is nil, a default implementation is used.

The directory is used to resolve relative paths and must be a valid Go package directory, meaning it must contain at least one `.go` file. If [Loader.validate] is true, the YAML documents will be validated against the JSON schema.

func (*Loader) Load

func (l *Loader) Load(ctx context.Context) (_ Config, err error)

Load proceeds to load the configuration from this loader's directory.

type PackageLoader added in v1.3.0

type PackageLoader = func(context.Context, string, ...string) ([]*packages.Package, error)

type Visitor added in v1.1.0

type Visitor = func(cfg File, pkgPath string) error

Jump to

Keyboard shortcuts

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