di

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Container

type Container struct{}

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() *Container

func (*Container) CacheDir

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

func (*Container) DistFetcher

func (c *Container) DistFetcher() *dist.Fetcher

func (*Container) GitFetcher

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

func (*Container) StepParser

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

func (*Container) StepResourceParser

func (c *Container) StepResourceParser() (*runner.StepResourceParser, 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