Documentation
¶
Overview ¶
Package adapters contains import adapter implementations for the config package. Import this package to register all built-in adapters.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearMockData ¶
func ClearMockData()
ClearMockData clears all mock data. This is intended for testing cleanup.
func SetMockData ¶
SetMockData sets the mock data for the global mock adapter. This is intended for testing.
Types ¶
type GoGetterAdapter ¶
type GoGetterAdapter struct{}
GoGetterAdapter handles remote imports using HashiCorp's go-getter. It supports a wide variety of URL schemes for downloading remote configurations.
func (*GoGetterAdapter) Resolve ¶
func (g *GoGetterAdapter) Resolve( ctx context.Context, importPath string, basePath string, tempDir string, currentDepth int, maxDepth int, ) ([]config.ResolvedPaths, error)
Resolve downloads a remote configuration and processes any nested imports.
func (*GoGetterAdapter) Schemes ¶
func (g *GoGetterAdapter) Schemes() []string
Schemes returns all URL schemes/prefixes handled by go-getter.
type LocalAdapter ¶
type LocalAdapter struct{}
LocalAdapter handles local filesystem imports. It is registered as the default adapter and handles paths without URL schemes.
func (*LocalAdapter) Resolve ¶
func (l *LocalAdapter) Resolve( _ context.Context, importPath, basePath, tempDir string, currentDepth, maxDepth int, ) ([]config.ResolvedPaths, error)
Resolve processes a local filesystem import path.
func (*LocalAdapter) Schemes ¶
func (l *LocalAdapter) Schemes() []string
Schemes returns nil because LocalAdapter is the default fallback. It handles any path that doesn't match other adapters' schemes.
type MockAdapter ¶
type MockAdapter struct {
// MockData allows tests to inject custom YAML content.
// Key is the path after "mock://", value is YAML content.
MockData map[string]string
}
MockAdapter generates synthetic YAML for testing. This enables unit tests without external dependencies.
Usage:
- mock://empty → Empty YAML config
- mock://error → Returns error (test error handling)
- mock://nested → Config with nested mock:// imports
- mock://custom/path → Config with mock_path set to "custom/path"
Tests can inject custom data via MockData field.
func GetGlobalMockAdapter ¶
func GetGlobalMockAdapter() *MockAdapter
GetGlobalMockAdapter returns the global mock adapter instance. This is used by the init.go to register the singleton.
func (*MockAdapter) Resolve ¶
func (m *MockAdapter) Resolve( ctx context.Context, importPath string, basePath string, tempDir string, currentDepth int, maxDepth int, ) ([]config.ResolvedPaths, error)
Resolve generates synthetic YAML based on the mock path.
func (*MockAdapter) Schemes ¶
func (m *MockAdapter) Schemes() []string
Schemes returns the mock:// scheme.