-
Notifications
You must be signed in to change notification settings - Fork 58
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Problem
Projects using IOTA SDK need to register custom configuration sections that load from environment variables. Currently each project implements its own config loading logic, leading to:
- Duplicated helper functions (
getEnvOrDefault,getEnvIntOrDefault) - Inconsistent configuration patterns across projects
- No unified way to extend the SDK's configuration system
Use Case
shy-eld's Shyona module has agent configuration that needs to be loaded from environment variables. Currently this is duplicated between:
modules/shyona/config.go- module configcmd/shyona-test/config.go- CLI config
Proposed Solution
Add a generic config extension mechanism using Go generics:
// ConfigExtension defines a configuration section that can be registered
type ConfigExtension interface {
Prefix() string // e.g., "OPENAI_", "AGENTS_"
Validate() error
}
// RegisterConfigExtension registers and loads a custom config section
func RegisterConfigExtension[T ConfigExtension](cfg *Configuration) (*T, error)
// Example usage:
type OpenAIConfig struct {
APIKey string
Model string
MaxTokens int
}
func (c OpenAIConfig) Prefix() string { return "OPENAI_" }
func (c OpenAIConfig) Validate() error { /* ... */ }
// In application setup:
openaiCfg, err := configuration.RegisterConfigExtension[OpenAIConfig](cfg)Acceptance Criteria
- Generic
RegisterConfigExtensionfunction that loads env vars based on prefix - Support for common types (string, int, bool, duration)
- Validation hook for custom validation logic
- Documentation with usage examples
- No breaking changes to existing configuration
Related
- shy-eld#505
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request