Documentation
¶
Index ¶
- func CleanupExpiredEntries()
- func ClearCache()
- func ClearCacheEntry(key string)
- func ExampleAdvancedOptions()
- func ExampleBasicUsage()
- func ExampleConfigurationPreview()
- func ExampleErrorHandling()
- func ExampleExplicitSources()
- func ExampleMigrationFromOldAPI()
- func ExampleWithVariables()
- func GetCacheStats() map[string]int
- func LoadAgentAuto(ctx context.Context, agentName, environment string, options ...agent.Option) (*agent.Agent, error)
- func LoadAgentConfig(ctx context.Context, agentName, environment string, options ...LoadOption) (*agent.AgentConfig, error)
- func LoadAgentFromLocal(ctx context.Context, agentName, environment string, options ...agent.Option) (*agent.Agent, error)
- func LoadAgentFromRemote(ctx context.Context, agentName, environment string, options ...agent.Option) (*agent.Agent, error)
- func LoadAgentWithOptions(ctx context.Context, agentName, environment string, loadOptions []LoadOption, ...) (*agent.Agent, error)
- func LoadAgentWithVariables(ctx context.Context, agentName, environment string, ...) (*agent.Agent, error)
- func LoadAndMergeWithViper(ctx context.Context, v *viper.Viper) (configsLoaded int, configsMerged int, err error)
- func LoadFromEnvironment(ctx context.Context) (map[string]string, error)
- func MergeAgentConfig(primary, base *agent.AgentConfig, strategy MergeStrategy) *agent.AgentConfig
- func PreviewAgentConfig(ctx context.Context, agentName, environment string) (*agent.AgentConfig, error)
- type AgentConfigResponse
- type ConfigSource
- type ConfigurationClient
- type ConfigurationResponse
- type ConfigurationValueType
- type LoadOption
- func WithCache(timeout time.Duration) LoadOption
- func WithEnvOverrides() LoadOption
- func WithLocalFallback(path string) LoadOption
- func WithLocalOnly() LoadOption
- func WithLocalPriorityMerge() LoadOption
- func WithMergeStrategy(strategy MergeStrategy) LoadOption
- func WithRemoteOnly() LoadOption
- func WithRemotePriorityMerge() LoadOption
- func WithVerbose() LoadOption
- func WithoutCache() LoadOption
- type LoadOptions
- type MergeStrategy
- type ResolvedConfigurationValue
- type SecretRef
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanupExpiredEntries ¶ added in v0.2.10
func CleanupExpiredEntries()
CleanupExpiredEntries removes expired cache entries
func ClearCacheEntry ¶ added in v0.2.10
func ClearCacheEntry(key string)
ClearCacheEntry removes a specific cache entry
func ExampleAdvancedOptions ¶ added in v0.2.10
func ExampleAdvancedOptions()
ExampleAdvancedOptions shows advanced configuration options
func ExampleBasicUsage ¶ added in v0.2.10
func ExampleBasicUsage()
ExampleBasicUsage shows the simplest way to load an agent with automatic source detection
func ExampleConfigurationPreview ¶ added in v0.2.10
func ExampleConfigurationPreview()
ExampleConfigurationPreview shows how to preview configurations without creating agents
func ExampleErrorHandling ¶ added in v0.2.10
func ExampleErrorHandling()
ExampleErrorHandling shows proper error handling patterns
func ExampleExplicitSources ¶ added in v0.2.10
func ExampleExplicitSources()
ExampleExplicitSources shows how to force specific configuration sources
func ExampleMigrationFromOldAPI ¶ added in v0.2.10
func ExampleMigrationFromOldAPI()
ExampleMigrationFromOldAPI shows how to migrate from old file-based loading
func ExampleWithVariables ¶ added in v0.2.10
func ExampleWithVariables()
ExampleWithVariables shows how to pass custom variables
func GetCacheStats ¶ added in v0.2.10
GetCacheStats returns cache statistics for monitoring
func LoadAgentAuto ¶ added in v0.2.10
func LoadAgentAuto(ctx context.Context, agentName, environment string, options ...agent.Option) (*agent.Agent, error)
LoadAgentAuto tries remote first, falls back to local (recommended for most use cases)
func LoadAgentConfig ¶ added in v0.2.10
func LoadAgentConfig(ctx context.Context, agentName, environment string, options ...LoadOption) (*agent.AgentConfig, error)
LoadAgentConfig is the main entry point for loading agent configurations It uses AGENT_DEPLOYMENT_ID to load configuration from remote, then falls back to local if configured
func LoadAgentFromLocal ¶ added in v0.2.10
func LoadAgentFromLocal(ctx context.Context, agentName, environment string, options ...agent.Option) (*agent.Agent, error)
LoadAgentFromLocal is a convenience function that loads and creates an agent from local file
func LoadAgentFromRemote ¶ added in v0.2.10
func LoadAgentFromRemote(ctx context.Context, agentName, environment string, options ...agent.Option) (*agent.Agent, error)
LoadAgentFromRemote is a convenience function that loads and creates an agent from remote config
func LoadAgentWithOptions ¶ added in v0.2.10
func LoadAgentWithOptions(ctx context.Context, agentName, environment string, loadOptions []LoadOption, agentOptions ...agent.Option) (*agent.Agent, error)
LoadAgentWithOptions provides full control over loading options
func LoadAgentWithVariables ¶ added in v0.2.10
func LoadAgentWithVariables(ctx context.Context, agentName, environment string, variables map[string]string, options ...agent.Option) (*agent.Agent, error)
LoadAgentWithVariables loads an agent and applies variable substitutions
func LoadAndMergeWithViper ¶
func LoadAndMergeWithViper(ctx context.Context, v *viper.Viper) (configsLoaded int, configsMerged int, err error)
LoadAndMergeWithViper loads dynamic configuration from config service and merges it with viper This handles the complete flow of: 1. Reading AGENT_DEPLOYMENT_ID, ENVIRONMENT, and STAROPS_CONFIG_SERVICE_HOST from viper 2. Setting them in OS environment for SDK access 3. Reloading SDK config 4. Loading dynamic config from service 5. Merging dynamic config into viper (local env vars take priority)
Returns the number of configs loaded and merged, or an error
func LoadFromEnvironment ¶
LoadFromEnvironment loads configuration from environment variables Reads AGENT_DEPLOYMENT_ID and ENVIRONMENT from environment variables and fetches the configuration from the StarOps config service
func MergeAgentConfig ¶ added in v0.2.11
func MergeAgentConfig(primary, base *agent.AgentConfig, strategy MergeStrategy) *agent.AgentConfig
MergeAgentConfig merges two AgentConfig structs based on the specified strategy For RemotePriority: primary values override base values (remote overrides local) For LocalPriority: base values override primary values (local overrides remote)
func PreviewAgentConfig ¶ added in v0.2.10
func PreviewAgentConfig(ctx context.Context, agentName, environment string) (*agent.AgentConfig, error)
PreviewAgentConfig returns the resolved configuration without creating an agent
Types ¶
type AgentConfigResponse ¶ added in v0.2.10
type AgentConfigResponse struct {
AgentConfig struct {
ID string `json:"id"`
AgentName string `json:"agent_name"`
Environment string `json:"environment"`
DisplayName string `json:"display_name"`
Description string `json:"description"`
Goal string `json:"goal"`
SystemPrompt string `json:"system_prompt"`
SchemaVersion string `json:"schema_version"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
} `json:"agent_config"`
GeneratedYAML string `json:"generated_yaml"` // YAML generated from structured data
ResolvedYAML string `json:"resolved_yaml"` // YAML with variables resolved
ResolvedVariables map[string]string `json:"resolved_variables"` // Variable mappings
MissingVariables []string `json:"missing_variables"` // Unresolved variables
}
AgentConfigResponse represents a resolved agent configuration from the service
type ConfigSource ¶ added in v0.2.10
type ConfigSource string
ConfigSource indicates where the configuration came from
const ( ConfigSourceRemote ConfigSource = "remote" ConfigSourceLocal ConfigSource = "local" ConfigSourceCache ConfigSource = "cache" ConfigSourceMerged ConfigSource = "merged" // Remote + Local merged )
type ConfigurationClient ¶
type ConfigurationClient struct {
// contains filtered or unexported fields
}
ConfigurationClient handles fetching configurations from the StarOps config service
func NewClient ¶
func NewClient() (*ConfigurationClient, error)
NewClient creates a new ConfigurationClient using the host from config
func (*ConfigurationClient) FetchAgentConfig ¶ added in v0.2.10
func (c *ConfigurationClient) FetchAgentConfig(ctx context.Context, agentID, environment string) (*AgentConfigResponse, error)
FetchAgentConfig retrieves a resolved agent configuration by agent_id and environment
func (*ConfigurationClient) FetchDeploymentConfig ¶
func (c *ConfigurationClient) FetchDeploymentConfig(ctx context.Context, deploymentID, environment string) (map[string]string, error)
FetchDeploymentConfig fetches configuration for a specific agent deployment Returns a map where keys are configuration keys and values are the resolved values
type ConfigurationResponse ¶
type ConfigurationResponse struct {
ID string `json:"id"`
OrgID string `json:"org_id"`
UserID string `json:"user_id"`
InstanceID string `json:"instance_id"`
Environment string `json:"environment"`
Key string `json:"key"`
Value ResolvedConfigurationValue `json:"value"`
Description *string `json:"description,omitempty"`
CreatedBy *string `json:"created_by,omitempty"`
UpdatedBy *string `json:"updated_by,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
ConfigurationResponse represents the response when returning a configuration with resolved secrets
type ConfigurationValueType ¶
type ConfigurationValueType string
ConfigurationValueType represents the type of value stored
const ( ConfigurationValueTypePlain ConfigurationValueType = "plain" ConfigurationValueTypeSecret ConfigurationValueType = "secret" )
type LoadOption ¶ added in v0.2.10
type LoadOption func(*LoadOptions)
LoadOption is a functional option
func WithCache ¶ added in v0.2.10
func WithCache(timeout time.Duration) LoadOption
WithCache enables caching with specified timeout
func WithEnvOverrides ¶ added in v0.2.10
func WithEnvOverrides() LoadOption
WithEnvOverrides enables environment variable overrides
func WithLocalFallback ¶ added in v0.2.10
func WithLocalFallback(path string) LoadOption
WithLocalFallback enables fallback to local file
func WithLocalOnly ¶ added in v0.2.10
func WithLocalOnly() LoadOption
WithLocalOnly forces local configuration only
func WithLocalPriorityMerge ¶ added in v0.2.11
func WithLocalPriorityMerge() LoadOption
WithLocalPriorityMerge enables merging with local config taking priority Remote config provides defaults for fields not set in local
func WithMergeStrategy ¶ added in v0.2.11
func WithMergeStrategy(strategy MergeStrategy) LoadOption
WithMergeStrategy sets the merge strategy for combining remote and local configs
func WithRemoteOnly ¶ added in v0.2.10
func WithRemoteOnly() LoadOption
WithRemoteOnly forces remote configuration only
func WithRemotePriorityMerge ¶ added in v0.2.11
func WithRemotePriorityMerge() LoadOption
WithRemotePriorityMerge enables merging with remote config taking priority Local config provides defaults for fields not set in remote
func WithVerbose ¶ added in v0.2.10
func WithVerbose() LoadOption
WithVerbose enables verbose logging
type LoadOptions ¶ added in v0.2.10
type LoadOptions struct {
// Source preferences
PreferRemote bool // Try remote first
AllowFallback bool // Fall back to local if remote fails
LocalPath string // Specific local file path
// Merging
MergeStrategy MergeStrategy // How to merge remote and local configs
// Caching
EnableCache bool
CacheTimeout time.Duration
// Behavior
EnableEnvOverrides bool
Verbose bool // Log loading steps
}
LoadOptions configures how agent configurations are loaded
func DefaultLoadOptions ¶ added in v0.2.10
func DefaultLoadOptions() *LoadOptions
DefaultLoadOptions returns sensible defaults
type MergeStrategy ¶ added in v0.2.11
type MergeStrategy string
MergeStrategy determines how configs are merged when both remote and local exist
const ( // MergeStrategyNone - No merging, use only one source (default behavior) MergeStrategyNone MergeStrategy = "none" // MergeStrategyRemotePriority - Remote config is primary, local fills gaps (recommended) // Use case: Config server has authority, local provides defaults MergeStrategyRemotePriority MergeStrategy = "remote_priority" // MergeStrategyLocalPriority - Local config is primary, remote fills gaps // Use case: Local development with remote fallbacks MergeStrategyLocalPriority MergeStrategy = "local_priority" )
type ResolvedConfigurationValue ¶
type ResolvedConfigurationValue struct {
Type ConfigurationValueType `json:"type"`
Value string `json:"value"`
SecretRef *SecretRef `json:"secret_ref,omitempty"`
StoreInVault bool `json:"store_in_vault,omitempty"`
}
ResolvedConfigurationValue represents a configuration value with the actual resolved content