Documentation
¶
Index ¶
- func WithStepFunc(name string, spec *proto.Spec, function runner.StepFunc) func(*Container)
- type Container
- func (c *Container) CacheDir() (string, error)
- func (c *Container) DistFetcher() *dist.Fetcher
- func (c *Container) GitFetcher() (*git.GitFetcher, error)
- func (c *Container) StepFuncFinder() (runner.StepFuncFinder, error)
- func (c *Container) StepParser() (*runner.Parser, error)
- func (c *Container) StepResourceParser() (*runner.StepResourceParser, error)
- func (c *Container) StepRunnerService() (*service.StepRunnerService, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 (*Container) DistFetcher ¶
func (*Container) GitFetcher ¶
func (c *Container) GitFetcher() (*git.GitFetcher, error)
func (*Container) StepFuncFinder ¶ added in v0.17.0
func (c *Container) StepFuncFinder() (runner.StepFuncFinder, error)
func (*Container) StepResourceParser ¶
func (c *Container) StepResourceParser() (*runner.StepResourceParser, error)
func (*Container) StepRunnerService ¶
func (c *Container) StepRunnerService() (*service.StepRunnerService, error)