context

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2024 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseContextHandler

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

BaseContextHandler implements the ContextHandlerInterface

func NewContextHandler

func NewContextHandler(injector di.Injector) *BaseContextHandler

NewContextHandler creates a new ContextHandler instance

func (*BaseContextHandler) Clean

func (c *BaseContextHandler) Clean() error

Clean cleans up context specific artifacts

func (*BaseContextHandler) GetConfigRoot

func (c *BaseContextHandler) GetConfigRoot() (string, error)

GetConfigRoot retrieves the configuration root path based on the current context

func (*BaseContextHandler) GetContext

func (c *BaseContextHandler) GetContext() string

GetContext retrieves the current context from the configuration

func (*BaseContextHandler) Initialize

func (c *BaseContextHandler) Initialize() error

Initialize initializes the context handler

func (*BaseContextHandler) SetContext

func (c *BaseContextHandler) SetContext(context string) error

SetContext sets the current context in the configuration and saves it

type ContextHandler

type ContextHandler interface {
	Initialize() error
	GetContext() string              // Retrieves the current context
	SetContext(context string) error // Sets the current context
	GetConfigRoot() (string, error)  // Retrieves the configuration root path
	Clean() error                    // Cleans up context specific artifacts
}

ContextHandlerInterface defines the interface for context operations

type MockContext

type MockContext struct {
	InitializeFunc    func() error               // Function to mock Initialize
	GetContextFunc    func() string              // Function to mock GetContext
	SetContextFunc    func(context string) error // Function to mock SetContext
	GetConfigRootFunc func() (string, error)     // Function to mock GetConfigRoot
	CleanFunc         func() error               // Function to mock Clean
}

MockContext is a mock implementation of the ContextInterface

func NewMockContext

func NewMockContext() *MockContext

NewMockContext creates a new instance of MockContext

func (*MockContext) Clean

func (m *MockContext) Clean() error

Clean calls the mock CleanFunc if set, otherwise returns nil

func (*MockContext) GetConfigRoot

func (m *MockContext) GetConfigRoot() (string, error)

GetConfigRoot calls the mock GetConfigRootFunc if set, otherwise returns a reasonable default config root and nil error

func (*MockContext) GetContext

func (m *MockContext) GetContext() string

GetContext calls the mock GetContextFunc if set, otherwise returns a reasonable default context and nil error

func (*MockContext) Initialize

func (m *MockContext) Initialize() error

Initialize calls the mock InitializeFunc if set, otherwise returns nil

func (*MockContext) SetContext

func (m *MockContext) SetContext(context string) error

SetContext calls the mock SetContextFunc if set, otherwise returns nil

Jump to

Keyboard shortcuts

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