di

package
v0.44.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 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 WithInProcessOnly added in v0.44.0

func WithInProcessOnly() func(*Container)

WithInProcessOnly restricts the container to in-process execution: no builtins are registered, and git/OCI/local references and exec functions are rejected. Embedders register their own with WithBuiltinFunc.

Covers only what the container builds; a job also needs runner.WithGlobalCtxInProcessOnly.

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.

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

OCIClient, RemoteImageStore and CachedImageStore are intentionally not gated on inProcessOnly, unlike GitFetcher and CacheDir. They have no eager side effect — the store paths are joined, not created — and ResourceParser short-circuits above before it reaches them in that mode. An embedder that assembles its own parser from these parts steps outside the guarantee.

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