di

package
v0.39.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithBuiltinFunc added in v0.39.0

func WithBuiltinFunc(name string, b runner.BuiltinFunction) func(*Container)

WithBuiltinFunc registers a builtin step function under the given name.

func WithOperatorLogger added in v0.39.0

func WithOperatorLogger(l *slog.Logger) func(*Container)

WithOperatorLogger sets the operator-facing logger, threaded through to the service and its jobs. Defaults to slog.Default(). Embedders can redirect or silence it so it does not leak into job output.

func WithStepFunc deprecated added in v0.17.0

func WithStepFunc(name string, spec *proto.Spec, function runner.StepFunc) func(*Container)

Deprecated: use WithStepFunc with a [BuiltinFunction] instead, which bundles the function's spec with its implementation rather than passing them around separately.

Types

type Container

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

Container provides Dependency Injection (DI) for the step-runner.

DI is where an object's dependencies are passed to it, rather than being created internally. Promotes loose coupling, testability, and maintainability. Ideally, constructors are called only in two places: DI, and test builders. This makes it easy to change the constructor function signature.

For example, creating dependencies within an object:

- OCIFetcher depends on `internal.NewClient` and `cache.New` - Changing `internal.NewClient` or `cache.New` function signatures forces a change in OCIFetcher

func NewOCIFetcher() *OCIFetcher {
	return &OCIFetcher{
		client: internal.NewClient(cache.New()),
	}
}

Creating dependencies using DI:

- OCIFetcher only depends on internal.Client (even better, an interface of Client) - Changing NewClient or cache.New requires no change in OCIFetcher - Requires DI Container.OCIFetcher()

func NewOCIFetcher(client *internal.Client) *OCIFetcher {
	return &OCIFetcher{ client: client }
}

func NewContainer

func NewContainer(opts ...func(*Container)) *Container

func (*Container) CacheDir

func (c *Container) CacheDir() (string, error)

func (*Container) CachedImageStore added in v0.26.0

func (c *Container) CachedImageStore(store oci.ImageStore) *oci.CachedImageStore

func (*Container) GitFetcher

func (c *Container) GitFetcher() (*git.GitFetcher, error)

func (*Container) OCIClient added in v0.26.0

func (c *Container) OCIClient() *oci.Client

func (*Container) RemoteImageStore added in v0.26.0

func (c *Container) RemoteImageStore() *oci.RemoteImageStore

func (*Container) ResourceParser added in v0.35.0

func (c *Container) ResourceParser() (*resource.Parser, error)

func (*Container) StepFuncFinder added in v0.17.0

func (c *Container) StepFuncFinder() (runner.StepFuncFinder, error)

func (*Container) StepParser

func (c *Container) StepParser() (*function.Parser, error)

func (*Container) StepRunnerService

func (c *Container) StepRunnerService() (*service.StepRunnerService, error)

Jump to

Keyboard shortcuts

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