di

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package di exposes shared dependency injection helpers for KSail commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveClusterProvisionerFactory

func ResolveClusterProvisionerFactory(
	injector Injector,
) (clusterprovisioner.Factory, error)

ResolveClusterProvisionerFactory retrieves the cluster provisioner factory dependency.

func ResolveTimer

func ResolveTimer(injector Injector) (timer.Timer, error)

ResolveTimer retrieves the timer dependency from the injector with consistent error handling.

func RunEWithRuntime

func RunEWithRuntime(
	runtimeContainer *Runtime,
	handler func(cmd *cobra.Command, injector Injector) error,
) func(*cobra.Command, []string) error

RunEWithRuntime returns a cobra RunE function that resolves dependencies using the provided runtime container. The handler is executed with the active command and resolved injector when the command runs.

func WithTimer

func WithTimer(
	handler func(cmd *cobra.Command, injector Injector, tmr timer.Timer) error,
) func(cmd *cobra.Command, injector Injector) error

WithTimer decorates a handler to automatically resolve the timer dependency.

Types

type Injector

type Injector = do.Injector

Injector is an alias for the underlying DI container implementation.

type MockInjector added in v1.14.0

type MockInjector struct {
	mock.Mock
}

MockInjector is an autogenerated mock type for the Injector type

func NewMockInjector added in v1.14.0

func NewMockInjector(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockInjector

NewMockInjector creates a new instance of MockInjector. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockInjector) Ancestors added in v1.14.0

func (_mock *MockInjector) Ancestors() []*do.Scope

Ancestors provides a mock function for the type MockInjector

func (*MockInjector) ChildByID added in v1.14.0

func (_mock *MockInjector) ChildByID(s string) (*do.Scope, bool)

ChildByID provides a mock function for the type MockInjector

func (*MockInjector) ChildByName added in v1.14.0

func (_mock *MockInjector) ChildByName(s string) (*do.Scope, bool)

ChildByName provides a mock function for the type MockInjector

func (*MockInjector) Children added in v1.14.0

func (_mock *MockInjector) Children() []*do.Scope

Children provides a mock function for the type MockInjector

func (*MockInjector) EXPECT added in v1.14.0

func (_m *MockInjector) EXPECT() *MockInjector_Expecter

func (*MockInjector) HealthCheck added in v1.14.0

func (_mock *MockInjector) HealthCheck() map[string]error

HealthCheck provides a mock function for the type MockInjector

func (*MockInjector) HealthCheckWithContext added in v1.14.0

func (_mock *MockInjector) HealthCheckWithContext(context1 context.Context) map[string]error

HealthCheckWithContext provides a mock function for the type MockInjector

func (*MockInjector) ID added in v1.14.0

func (_mock *MockInjector) ID() string

ID provides a mock function for the type MockInjector

func (*MockInjector) ListInvokedServices added in v1.14.0

func (_mock *MockInjector) ListInvokedServices() []do.ServiceDescription

ListInvokedServices provides a mock function for the type MockInjector

func (*MockInjector) ListProvidedServices added in v1.14.0

func (_mock *MockInjector) ListProvidedServices() []do.ServiceDescription

ListProvidedServices provides a mock function for the type MockInjector

func (*MockInjector) Name added in v1.14.0

func (_mock *MockInjector) Name() string

Name provides a mock function for the type MockInjector

func (*MockInjector) RootScope added in v1.14.0

func (_mock *MockInjector) RootScope() *do.RootScope

RootScope provides a mock function for the type MockInjector

func (*MockInjector) Scope added in v1.14.0

func (_mock *MockInjector) Scope(s string, fns ...func(do.Injector)) *do.Scope

Scope provides a mock function for the type MockInjector

func (*MockInjector) Shutdown added in v1.14.0

func (_mock *MockInjector) Shutdown() *do.ShutdownReport

Shutdown provides a mock function for the type MockInjector

func (*MockInjector) ShutdownWithContext added in v1.14.0

func (_mock *MockInjector) ShutdownWithContext(context1 context.Context) *do.ShutdownReport

ShutdownWithContext provides a mock function for the type MockInjector

type MockInjector_Ancestors_Call added in v1.14.0

type MockInjector_Ancestors_Call struct {
	*mock.Call
}

MockInjector_Ancestors_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Ancestors'

func (*MockInjector_Ancestors_Call) Return added in v1.14.0

func (*MockInjector_Ancestors_Call) Run added in v1.14.0

func (*MockInjector_Ancestors_Call) RunAndReturn added in v1.14.0

func (_c *MockInjector_Ancestors_Call) RunAndReturn(run func() []*do.Scope) *MockInjector_Ancestors_Call

type MockInjector_ChildByID_Call added in v1.14.0

type MockInjector_ChildByID_Call struct {
	*mock.Call
}

MockInjector_ChildByID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ChildByID'

func (*MockInjector_ChildByID_Call) Return added in v1.14.0

func (*MockInjector_ChildByID_Call) Run added in v1.14.0

func (*MockInjector_ChildByID_Call) RunAndReturn added in v1.14.0

func (_c *MockInjector_ChildByID_Call) RunAndReturn(run func(s string) (*do.Scope, bool)) *MockInjector_ChildByID_Call

type MockInjector_ChildByName_Call added in v1.14.0

type MockInjector_ChildByName_Call struct {
	*mock.Call
}

MockInjector_ChildByName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ChildByName'

func (*MockInjector_ChildByName_Call) Return added in v1.14.0

func (*MockInjector_ChildByName_Call) Run added in v1.14.0

func (*MockInjector_ChildByName_Call) RunAndReturn added in v1.14.0

type MockInjector_Children_Call added in v1.14.0

type MockInjector_Children_Call struct {
	*mock.Call
}

MockInjector_Children_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Children'

func (*MockInjector_Children_Call) Return added in v1.14.0

func (*MockInjector_Children_Call) Run added in v1.14.0

func (*MockInjector_Children_Call) RunAndReturn added in v1.14.0

func (_c *MockInjector_Children_Call) RunAndReturn(run func() []*do.Scope) *MockInjector_Children_Call

type MockInjector_Expecter added in v1.14.0

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

func (*MockInjector_Expecter) Ancestors added in v1.14.0

Ancestors is a helper method to define mock.On call

func (*MockInjector_Expecter) ChildByID added in v1.14.0

func (_e *MockInjector_Expecter) ChildByID(s interface{}) *MockInjector_ChildByID_Call

ChildByID is a helper method to define mock.On call

  • s string

func (*MockInjector_Expecter) ChildByName added in v1.14.0

func (_e *MockInjector_Expecter) ChildByName(s interface{}) *MockInjector_ChildByName_Call

ChildByName is a helper method to define mock.On call

  • s string

func (*MockInjector_Expecter) Children added in v1.14.0

Children is a helper method to define mock.On call

func (*MockInjector_Expecter) HealthCheck added in v1.14.0

HealthCheck is a helper method to define mock.On call

func (*MockInjector_Expecter) HealthCheckWithContext added in v1.14.0

func (_e *MockInjector_Expecter) HealthCheckWithContext(context1 interface{}) *MockInjector_HealthCheckWithContext_Call

HealthCheckWithContext is a helper method to define mock.On call

  • context1 context.Context

func (*MockInjector_Expecter) ID added in v1.14.0

ID is a helper method to define mock.On call

func (*MockInjector_Expecter) ListInvokedServices added in v1.14.0

ListInvokedServices is a helper method to define mock.On call

func (*MockInjector_Expecter) ListProvidedServices added in v1.14.0

ListProvidedServices is a helper method to define mock.On call

func (*MockInjector_Expecter) Name added in v1.14.0

Name is a helper method to define mock.On call

func (*MockInjector_Expecter) RootScope added in v1.14.0

RootScope is a helper method to define mock.On call

func (*MockInjector_Expecter) Scope added in v1.14.0

func (_e *MockInjector_Expecter) Scope(s interface{}, fns ...interface{}) *MockInjector_Scope_Call

Scope is a helper method to define mock.On call

  • s string
  • fns ...func(do.Injector)

func (*MockInjector_Expecter) Shutdown added in v1.14.0

Shutdown is a helper method to define mock.On call

func (*MockInjector_Expecter) ShutdownWithContext added in v1.14.0

func (_e *MockInjector_Expecter) ShutdownWithContext(context1 interface{}) *MockInjector_ShutdownWithContext_Call

ShutdownWithContext is a helper method to define mock.On call

  • context1 context.Context

type MockInjector_HealthCheckWithContext_Call added in v1.14.0

type MockInjector_HealthCheckWithContext_Call struct {
	*mock.Call
}

MockInjector_HealthCheckWithContext_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HealthCheckWithContext'

func (*MockInjector_HealthCheckWithContext_Call) Return added in v1.14.0

func (*MockInjector_HealthCheckWithContext_Call) Run added in v1.14.0

func (*MockInjector_HealthCheckWithContext_Call) RunAndReturn added in v1.14.0

type MockInjector_HealthCheck_Call added in v1.14.0

type MockInjector_HealthCheck_Call struct {
	*mock.Call
}

MockInjector_HealthCheck_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HealthCheck'

func (*MockInjector_HealthCheck_Call) Return added in v1.14.0

func (*MockInjector_HealthCheck_Call) Run added in v1.14.0

func (*MockInjector_HealthCheck_Call) RunAndReturn added in v1.14.0

func (_c *MockInjector_HealthCheck_Call) RunAndReturn(run func() map[string]error) *MockInjector_HealthCheck_Call

type MockInjector_ID_Call added in v1.14.0

type MockInjector_ID_Call struct {
	*mock.Call
}

MockInjector_ID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ID'

func (*MockInjector_ID_Call) Return added in v1.14.0

func (*MockInjector_ID_Call) Run added in v1.14.0

func (_c *MockInjector_ID_Call) Run(run func()) *MockInjector_ID_Call

func (*MockInjector_ID_Call) RunAndReturn added in v1.14.0

func (_c *MockInjector_ID_Call) RunAndReturn(run func() string) *MockInjector_ID_Call

type MockInjector_ListInvokedServices_Call added in v1.14.0

type MockInjector_ListInvokedServices_Call struct {
	*mock.Call
}

MockInjector_ListInvokedServices_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListInvokedServices'

func (*MockInjector_ListInvokedServices_Call) Return added in v1.14.0

func (*MockInjector_ListInvokedServices_Call) Run added in v1.14.0

func (*MockInjector_ListInvokedServices_Call) RunAndReturn added in v1.14.0

type MockInjector_ListProvidedServices_Call added in v1.14.0

type MockInjector_ListProvidedServices_Call struct {
	*mock.Call
}

MockInjector_ListProvidedServices_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListProvidedServices'

func (*MockInjector_ListProvidedServices_Call) Return added in v1.14.0

func (*MockInjector_ListProvidedServices_Call) Run added in v1.14.0

func (*MockInjector_ListProvidedServices_Call) RunAndReturn added in v1.14.0

type MockInjector_Name_Call added in v1.14.0

type MockInjector_Name_Call struct {
	*mock.Call
}

MockInjector_Name_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Name'

func (*MockInjector_Name_Call) Return added in v1.14.0

func (*MockInjector_Name_Call) Run added in v1.14.0

func (_c *MockInjector_Name_Call) Run(run func()) *MockInjector_Name_Call

func (*MockInjector_Name_Call) RunAndReturn added in v1.14.0

func (_c *MockInjector_Name_Call) RunAndReturn(run func() string) *MockInjector_Name_Call

type MockInjector_RootScope_Call added in v1.14.0

type MockInjector_RootScope_Call struct {
	*mock.Call
}

MockInjector_RootScope_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RootScope'

func (*MockInjector_RootScope_Call) Return added in v1.14.0

func (*MockInjector_RootScope_Call) Run added in v1.14.0

func (*MockInjector_RootScope_Call) RunAndReturn added in v1.14.0

type MockInjector_Scope_Call added in v1.14.0

type MockInjector_Scope_Call struct {
	*mock.Call
}

MockInjector_Scope_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Scope'

func (*MockInjector_Scope_Call) Return added in v1.14.0

func (*MockInjector_Scope_Call) Run added in v1.14.0

func (_c *MockInjector_Scope_Call) Run(run func(s string, fns ...func(do.Injector))) *MockInjector_Scope_Call

func (*MockInjector_Scope_Call) RunAndReturn added in v1.14.0

func (_c *MockInjector_Scope_Call) RunAndReturn(run func(s string, fns ...func(do.Injector)) *do.Scope) *MockInjector_Scope_Call

type MockInjector_ShutdownWithContext_Call added in v1.14.0

type MockInjector_ShutdownWithContext_Call struct {
	*mock.Call
}

MockInjector_ShutdownWithContext_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ShutdownWithContext'

func (*MockInjector_ShutdownWithContext_Call) Return added in v1.14.0

func (*MockInjector_ShutdownWithContext_Call) Run added in v1.14.0

func (*MockInjector_ShutdownWithContext_Call) RunAndReturn added in v1.14.0

type MockInjector_Shutdown_Call added in v1.14.0

type MockInjector_Shutdown_Call struct {
	*mock.Call
}

MockInjector_Shutdown_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Shutdown'

func (*MockInjector_Shutdown_Call) Return added in v1.14.0

func (*MockInjector_Shutdown_Call) Run added in v1.14.0

func (*MockInjector_Shutdown_Call) RunAndReturn added in v1.14.0

type MockInjector_clone_Call added in v1.14.0

type MockInjector_clone_Call struct {
	*mock.Call
}

MockInjector_clone_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'clone'

func (*MockInjector_clone_Call) Return added in v1.14.0

func (*MockInjector_clone_Call) Run added in v1.14.0

func (_c *MockInjector_clone_Call) Run(run func(rootScope *do.RootScope, scope *do.Scope)) *MockInjector_clone_Call

func (*MockInjector_clone_Call) RunAndReturn added in v1.14.0

func (_c *MockInjector_clone_Call) RunAndReturn(run func(rootScope *do.RootScope, scope *do.Scope) *do.Scope) *MockInjector_clone_Call

type MockInjector_onServiceInvoke_Call added in v1.14.0

type MockInjector_onServiceInvoke_Call struct {
	*mock.Call
}

MockInjector_onServiceInvoke_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'onServiceInvoke'

func (*MockInjector_onServiceInvoke_Call) Return added in v1.14.0

func (*MockInjector_onServiceInvoke_Call) Run added in v1.14.0

func (*MockInjector_onServiceInvoke_Call) RunAndReturn added in v1.14.0

type MockInjector_serviceExistRec_Call added in v1.14.0

type MockInjector_serviceExistRec_Call struct {
	*mock.Call
}

MockInjector_serviceExistRec_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'serviceExistRec'

func (*MockInjector_serviceExistRec_Call) Return added in v1.14.0

func (*MockInjector_serviceExistRec_Call) Run added in v1.14.0

func (*MockInjector_serviceExistRec_Call) RunAndReturn added in v1.14.0

type MockInjector_serviceExist_Call added in v1.14.0

type MockInjector_serviceExist_Call struct {
	*mock.Call
}

MockInjector_serviceExist_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'serviceExist'

func (*MockInjector_serviceExist_Call) Return added in v1.14.0

func (*MockInjector_serviceExist_Call) Run added in v1.14.0

func (*MockInjector_serviceExist_Call) RunAndReturn added in v1.14.0

type MockInjector_serviceForEachRec_Call added in v1.14.0

type MockInjector_serviceForEachRec_Call struct {
	*mock.Call
}

MockInjector_serviceForEachRec_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'serviceForEachRec'

func (*MockInjector_serviceForEachRec_Call) Return added in v1.14.0

func (*MockInjector_serviceForEachRec_Call) Run added in v1.14.0

func (*MockInjector_serviceForEachRec_Call) RunAndReturn added in v1.14.0

type MockInjector_serviceForEach_Call added in v1.14.0

type MockInjector_serviceForEach_Call struct {
	*mock.Call
}

MockInjector_serviceForEach_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'serviceForEach'

func (*MockInjector_serviceForEach_Call) Return added in v1.14.0

func (*MockInjector_serviceForEach_Call) Run added in v1.14.0

func (*MockInjector_serviceForEach_Call) RunAndReturn added in v1.14.0

func (_c *MockInjector_serviceForEach_Call) RunAndReturn(run func(fn func(string, *do.Scope, any) bool)) *MockInjector_serviceForEach_Call

type MockInjector_serviceGetRec_Call added in v1.14.0

type MockInjector_serviceGetRec_Call struct {
	*mock.Call
}

MockInjector_serviceGetRec_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'serviceGetRec'

func (*MockInjector_serviceGetRec_Call) Return added in v1.14.0

func (*MockInjector_serviceGetRec_Call) Run added in v1.14.0

func (*MockInjector_serviceGetRec_Call) RunAndReturn added in v1.14.0

type MockInjector_serviceGet_Call added in v1.14.0

type MockInjector_serviceGet_Call struct {
	*mock.Call
}

MockInjector_serviceGet_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'serviceGet'

func (*MockInjector_serviceGet_Call) Return added in v1.14.0

func (*MockInjector_serviceGet_Call) Run added in v1.14.0

func (*MockInjector_serviceGet_Call) RunAndReturn added in v1.14.0

func (_c *MockInjector_serviceGet_Call) RunAndReturn(run func(s string) (any, bool)) *MockInjector_serviceGet_Call

type MockInjector_serviceHealthCheck_Call added in v1.14.0

type MockInjector_serviceHealthCheck_Call struct {
	*mock.Call
}

MockInjector_serviceHealthCheck_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'serviceHealthCheck'

func (*MockInjector_serviceHealthCheck_Call) Return added in v1.14.0

func (*MockInjector_serviceHealthCheck_Call) Run added in v1.14.0

func (*MockInjector_serviceHealthCheck_Call) RunAndReturn added in v1.14.0

type MockInjector_serviceSet_Call added in v1.14.0

type MockInjector_serviceSet_Call struct {
	*mock.Call
}

MockInjector_serviceSet_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'serviceSet'

func (*MockInjector_serviceSet_Call) Return added in v1.14.0

func (*MockInjector_serviceSet_Call) Run added in v1.14.0

func (*MockInjector_serviceSet_Call) RunAndReturn added in v1.14.0

func (_c *MockInjector_serviceSet_Call) RunAndReturn(run func(s string, v any)) *MockInjector_serviceSet_Call

type MockInjector_serviceShutdown_Call added in v1.14.0

type MockInjector_serviceShutdown_Call struct {
	*mock.Call
}

MockInjector_serviceShutdown_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'serviceShutdown'

func (*MockInjector_serviceShutdown_Call) Return added in v1.14.0

func (*MockInjector_serviceShutdown_Call) Run added in v1.14.0

func (*MockInjector_serviceShutdown_Call) RunAndReturn added in v1.14.0

type Module

type Module func(do.Injector) error

Module registers dependencies with the DI container.

type Runtime

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

Runtime owns shared dependency registration for Cobra commands.

func New

func New(modules ...Module) *Runtime

New constructs a Runtime with the provided base modules. Modules are applied in the order supplied when invoking commands.

func NewRuntime

func NewRuntime() *Runtime

NewRuntime constructs the shared runtime container used by root command and tests.

func (*Runtime) Invoke

func (r *Runtime) Invoke(
	handler func(Injector) error,
	extraModules ...Module,
) error

Invoke builds a fresh injector, applies base and extra modules, and executes the provided function.

Jump to

Keyboard shortcuts

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