config

package
v0.9.17 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTextCollection  = "WeaveDocs"
	DefaultImageCollection = "WeaveImages"
	DefaultDatabaseType    = "weaviate-cloud"
	DefaultLocalURL        = "http://localhost:8080"
	DefaultBatchWorkers    = 3
	DefaultRetryAttempts   = 3
	DefaultLLMModel        = "gpt-4o"
	DefaultLLMTimeout      = 300
	DefaultBatchChunkSize  = 500
	DefaultImageQuality    = 85
	DefaultMaxImageSize    = 2048
	DefaultEmbeddingDim    = 384
	DefaultTimeout         = 10 // Default timeout in seconds for vector DB operations
)

Default configuration values

View Source
const (
	// GlobalConfigDirName is the directory name for global config
	GlobalConfigDirName = ".weave-cli"
	// EnvFileName is the name of the environment file
	EnvFileName = ".env"
	// ConfigFileName is the name of the YAML config file
	ConfigFileName = "config.yaml"
)

Variables

This section is empty.

Functions

func DryRun added in v0.9.17

func DryRun(results []FixResult)

DryRun shows what would be changed without actually changing anything

func EnsureGlobalConfigDir added in v0.3.12

func EnsureGlobalConfigDir() (bool, error)

EnsureGlobalConfigDir creates ~/.weave-cli directory if it doesn't exist Returns true if directory was created, false if it already existed

func FormatConfigError added in v0.3.6

func FormatConfigError(err error) string

FormatConfigError formats a configuration error with helpful tips

func GetConfigFile

func GetConfigFile() string

GetConfigFile returns the path to the config file being used

func GetEnvFile

func GetEnvFile() string

GetEnvFile returns the path to the env file being used

func GetFieldSuggestions added in v0.9.17

func GetFieldSuggestions(field, value string) []string

GetFieldSuggestions returns smart suggestions based on common mistakes

func GetGlobalConfigDir added in v0.3.12

func GetGlobalConfigDir() (string, error)

GetGlobalConfigDir returns the path to ~/.weave-cli directory

func GetGlobalConfigPath added in v0.3.12

func GetGlobalConfigPath() (string, error)

GetGlobalConfigPath returns the path to ~/.weave-cli/config.yaml

func GetGlobalEnvPath added in v0.3.12

func GetGlobalEnvPath() (string, error)

GetGlobalEnvPath returns the path to ~/.weave-cli/.env

func GetValidationHint added in v0.9.17

func GetValidationHint(field string, err error) string

GetValidationHint returns a helpful hint for validation errors

func HasGlobalConfig added in v0.3.12

func HasGlobalConfig() (bool, error)

HasGlobalConfig returns true if global .env or config.yaml exists

func HasLocalConfig added in v0.3.12

func HasLocalConfig() bool

HasLocalConfig returns true if local .env or config.yaml exists

func InteractiveConfigFix added in v0.3.6

func InteractiveConfigFix(envFileExists bool) error

InteractiveConfigFix runs the interactive configuration fix process

func InterpolateString

func InterpolateString(s string) string

InterpolateString interpolates environment variables in a string

func PrintValidationResult added in v0.9.13

func PrintValidationResult(result *ValidationResult)

PrintValidationResult prints validation warnings and errors to stderr Only prints if there are issues to report (quiet by default)

func PromptToFixConfig added in v0.3.6

func PromptToFixConfig(err *ConfigError) (bool, error)

PromptToFixConfig prompts the user to fix configuration interactively

func ValidateFieldValue added in v0.9.17

func ValidateFieldValue(field, value string) error

ValidateFieldValue validates a field value based on its name and type

Types

type Collection added in v0.0.4

type Collection struct {
	Name        string `yaml:"name"`
	Type        string `yaml:"type"`
	Description string `yaml:"description,omitempty"`
}

Collection represents a collection configuration

type Config

type Config struct {
	Databases  DatabasesConfig `yaml:"databases"`
	SchemasDir string          `yaml:"schemas_dir,omitempty"`
	Logging    LoggingConfig   `yaml:"logging,omitempty"`
}

func LoadConfig

func LoadConfig(configFile, envFile string) (*Config, error)

func LoadConfigWithOptions added in v0.1.6

func LoadConfigWithOptions(opts LoadConfigOptions) (*Config, error)

func (*Config) GetAllSchemas added in v0.2.6

func (c *Config) GetAllSchemas() []SchemaDefinition

GetAllSchemas returns all configured schema definitions

func (*Config) GetDatabase added in v0.0.4

func (c *Config) GetDatabase(name string) (*VectorDBConfig, error)

GetDatabase returns a specific vector database configuration by name Supports shortcut names that resolve to -cloud variants:

weaviate -> weaviate-cloud
milvus -> milvus-cloud
chroma -> chroma-cloud
neo4j -> neo4j-cloud
qdrant -> qdrant-cloud

func (*Config) GetDatabaseNames added in v0.0.4

func (c *Config) GetDatabaseNames() map[string]VectorDBType

GetDatabaseNames returns a map of database names to their types

func (*Config) GetDefaultDatabase added in v0.0.4

func (c *Config) GetDefaultDatabase() (*VectorDBConfig, error)

GetDefaultDatabase returns the default vector database configuration

func (*Config) GetSchema added in v0.2.5

func (c *Config) GetSchema(name string) (*SchemaDefinition, error)

GetSchema returns a specific schema definition by name

func (*Config) ListDatabases added in v0.0.4

func (c *Config) ListDatabases() []string

ListDatabases returns a list of all configured database names

func (*Config) ListSchemas added in v0.2.5

func (c *Config) ListSchemas() []string

ListSchemas returns a list of all configured schema names

type ConfigError added in v0.3.6

type ConfigError struct {
	Message          string
	MissingVars      []string
	EnvFileExists    bool
	ConfigFileExists bool
	Tips             []string
}

ConfigError represents a configuration error with helpful information

func CheckREPLRequiredEnvVars added in v0.3.6

func CheckREPLRequiredEnvVars() *ConfigError

CheckREPLRequiredEnvVars checks if REPL-specific environment variables are set

func CheckRequiredEnvVars added in v0.3.6

func CheckRequiredEnvVars() *ConfigError

CheckRequiredEnvVars checks if required environment variables are set

func (*ConfigError) Error added in v0.3.6

func (e *ConfigError) Error() string

Error implements the error interface

type ConfigIssue added in v0.9.17

type ConfigIssue struct {
	Type         IssueType // error or warning
	Path         string    // Full path like "databases.vector_databases[2].database_url"
	DatabaseName string    // Database name like "mongodb-cloud"
	DatabaseIdx  int       // Index in vector_databases array (-1 if not applicable)
	Field        string    // Field name like "database_url"
	Message      string    // Human-readable description
	Hint         string    // Fix suggestion
	CurrentValue string    // Current value (empty if missing)
}

ConfigIssue represents a configuration validation issue that can be fixed

func ParseValidationOutput added in v0.9.17

func ParseValidationOutput(output string) ([]ConfigIssue, error)

ParseValidationOutput parses validation error/warning output into ConfigIssue list Expected format from validation:

"⚠️  Configuration Errors:"
"  • databases.vector_databases[2] (mongodb-cloud).database_url: MongoDB database_url is required"
"    💡 Set 'database_url' field with MongoDB Atlas connection string"

func (ConfigIssue) GetFieldExample added in v0.9.17

func (i ConfigIssue) GetFieldExample() string

GetFieldExample returns an example value for this field

func (ConfigIssue) GetFixPromptOptions added in v0.9.17

func (i ConfigIssue) GetFixPromptOptions() []string

GetFixPromptOptions returns the available fix options for this issue

func (ConfigIssue) IsSecretField added in v0.9.17

func (i ConfigIssue) IsSecretField() bool

IsSecretField returns true if the field should be treated as a secret

func (ConfigIssue) String added in v0.9.17

func (i ConfigIssue) String() string

String returns a human-readable representation of the issue

type ConfigPaths added in v0.3.12

type ConfigPaths struct {
	EnvPath    string
	ConfigPath string
	Location   string // "local" or "global"
}

ConfigPaths holds the paths to configuration files

func FindConfigPaths added in v0.3.12

func FindConfigPaths() (*ConfigPaths, error)

FindConfigPaths finds configuration files with proper precedence: 1. Local directory (current working directory) 2. Global directory (~/.weave-cli)

type DatabasesConfig added in v0.0.4

type DatabasesConfig struct {
	Default         string             `yaml:"default"`
	VectorDatabases []VectorDBConfig   `yaml:"vector_databases"`
	Schemas         []SchemaDefinition `yaml:"schemas,omitempty"`
}

DatabasesConfig holds multiple databases configuration

type FixAction added in v0.9.17

type FixAction string

FixAction represents what to do to fix an issue

const (
	FixActionSetValue FixAction = "set_value"
	FixActionSkip     FixAction = "skip"
	FixActionRemove   FixAction = "remove"
	FixActionDisable  FixAction = "disable"
	FixActionQuit     FixAction = "quit"
)

func MapOptionToAction added in v0.9.17

func MapOptionToAction(choice int, issue ConfigIssue) FixAction

MapOptionToAction maps user's numeric choice to FixAction

type FixApplier added in v0.9.17

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

FixApplier applies fixes to a config file

func NewFixApplier added in v0.9.17

func NewFixApplier(configPath string) (*FixApplier, error)

NewFixApplier creates a new fix applier

func (*FixApplier) ApplyFixes added in v0.9.17

func (a *FixApplier) ApplyFixes(results []FixResult, createBackup bool) error

ApplyFixes applies a list of fix results to the config file

func (*FixApplier) GetBackupPath added in v0.9.17

func (a *FixApplier) GetBackupPath() string

GetBackupPath returns the path to the backup file

type FixResult added in v0.9.17

type FixResult struct {
	Issue  ConfigIssue
	Action FixAction
	Value  string // New value (if action is set_value)
	Error  error
}

FixResult tracks the outcome of fixing an issue

type InteractiveFixer added in v0.9.17

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

InteractiveFixer handles interactive fixing of configuration issues

func NewInteractiveFixer added in v0.9.17

func NewInteractiveFixer(issues []ConfigIssue) *InteractiveFixer

NewInteractiveFixer creates a new interactive fixer

func (*InteractiveFixer) Run added in v0.9.17

func (f *InteractiveFixer) Run() ([]FixResult, error)

Run executes the interactive fix flow

type IssueType added in v0.9.17

type IssueType string

IssueType represents the severity of a configuration issue

const (
	IssueTypeError   IssueType = "error"
	IssueTypeWarning IssueType = "warning"
)

type LoadConfigOptions added in v0.1.6

type LoadConfigOptions struct {
	ConfigFile     string
	EnvFile        string
	VectorDBType   string
	WeaviateAPIKey string
	WeaviateURL    string
	Timeout        string // Timeout as duration string (e.g., "5s", "10s") or empty for default
}

LoadConfig loads configuration from files and environment variables LoadConfigOptions holds options for loading configuration

type LoggingConfig added in v0.9.12

type LoggingConfig struct {
	Level string `yaml:"level,omitempty"` // debug, info, warn, error
	File  string `yaml:"file,omitempty"`  // log file path (empty = stderr)
}

Config holds the complete application configuration LoggingConfig holds logging configuration

type MockCollection

type MockCollection struct {
	Name        string `yaml:"name"`
	Type        string `yaml:"type"`
	Description string `yaml:"description"`
}

MockCollection represents a mock collection (for backward compatibility)

type MockConfig

type MockConfig struct {
	Enabled            bool             `yaml:"enabled"`
	SimulateEmbeddings bool             `yaml:"simulate_embeddings"`
	EmbeddingDimension int              `yaml:"embedding_dimension"`
	Collections        []MockCollection `yaml:"collections"`
}

MockConfig holds mock database configuration (for backward compatibility)

type SchemaDefinition added in v0.2.5

type SchemaDefinition struct {
	Name     string                 `yaml:"name"`
	Schema   map[string]interface{} `yaml:"schema"`
	Metadata map[string]interface{} `yaml:"metadata,omitempty"`
}

SchemaDefinition represents a named schema that can be used to create collections

type ValidationResult added in v0.9.13

type ValidationResult struct {
	Warnings []ValidationWarning
	Errors   []ValidationWarning
}

ValidationResult contains all validation findings

func ValidateConfig added in v0.9.13

func ValidateConfig(cfg *Config) *ValidationResult

ValidateConfig performs comprehensive configuration validation Returns warnings but doesn't block execution (errors are only for critical issues)

type ValidationWarning added in v0.9.13

type ValidationWarning struct {
	Field      string
	Message    string
	Suggestion string
}

ValidationWarning represents a non-critical configuration issue

type VectorDBConfig

type VectorDBConfig struct {
	Name               string       `yaml:"name"`
	Type               VectorDBType `yaml:"type"`
	URL                string       `yaml:"url,omitempty"`
	APIKey             string       `yaml:"api_key,omitempty"`
	DatabaseURL        string       `yaml:"database_url,omitempty"`      // For Supabase
	DatabaseKey        string       `yaml:"database_key,omitempty"`      // For Supabase
	Database           string       `yaml:"database,omitempty"`          // For MongoDB, Milvus, Chroma
	Tenant             string       `yaml:"tenant,omitempty"`            // For Chroma Cloud
	VectorDimensions   int          `yaml:"vector_dimensions,omitempty"` // For MongoDB, Milvus
	SimilarityMetric   string       `yaml:"similarity_metric,omitempty"` // For MongoDB, Milvus
	Address            string       `yaml:"address,omitempty"`           // For Milvus
	Username           string       `yaml:"username,omitempty"`          // For Milvus Cloud
	Password           string       `yaml:"password,omitempty"`          // For Milvus Cloud
	OpenAIAPIKey       string       `yaml:"openai_api_key,omitempty"`
	Timeout            int          `yaml:"timeout,omitempty"` // Timeout in seconds for DB operations
	Enabled            bool         `yaml:"enabled,omitempty"`
	SimulateEmbeddings bool         `yaml:"simulate_embeddings,omitempty"`
	EmbeddingDimension int          `yaml:"embedding_dimension,omitempty"`
	Collections        []Collection `yaml:"collections"`
}

VectorDBConfig holds vector database configuration

type VectorDBType

type VectorDBType string

VectorDBType represents the type of vector database

const (
	VectorDBTypeCloud           VectorDBType = "weaviate-cloud"
	VectorDBTypeLocal           VectorDBType = "weaviate-local"
	VectorDBTypeMock            VectorDBType = "mock"
	VectorDBTypeSupabase        VectorDBType = "supabase" // Legacy
	VectorDBTypeSupabaseCloud   VectorDBType = "supabase-cloud"
	VectorDBTypeSupabaseLocal   VectorDBType = "supabase-local"
	VectorDBTypeMongoDB         VectorDBType = "mongodb" // Legacy
	VectorDBTypeMongoDBCloud    VectorDBType = "mongodb-cloud"
	VectorDBTypeMilvusLocal     VectorDBType = "milvus-local"
	VectorDBTypeMilvusCloud     VectorDBType = "milvus-cloud"
	VectorDBTypeChromaLocal     VectorDBType = "chroma-local"
	VectorDBTypeChromaCloud     VectorDBType = "chroma-cloud"
	VectorDBTypeQdrantLocal     VectorDBType = "qdrant-local"
	VectorDBTypeQdrantCloud     VectorDBType = "qdrant-cloud"
	VectorDBTypeNeo4jLocal      VectorDBType = "neo4j-local"
	VectorDBTypeNeo4jCloud      VectorDBType = "neo4j-cloud"
	VectorDBTypeOpenSearchLocal VectorDBType = "opensearch-local"
	VectorDBTypeOpenSearchCloud VectorDBType = "opensearch-cloud"
)

type YAMLEditor added in v0.9.17

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

YAMLEditor provides utilities for editing YAML files while preserving structure

func NewYAMLEditor added in v0.9.17

func NewYAMLEditor(filePath string) (*YAMLEditor, error)

NewYAMLEditor creates a new YAML editor for the given file

func (*YAMLEditor) DisableArrayElement added in v0.9.17

func (e *YAMLEditor) DisableArrayElement(path string, index int) error

DisableArrayElement comments out an array element (marks it as disabled)

func (*YAMLEditor) RemoveArrayElement added in v0.9.17

func (e *YAMLEditor) RemoveArrayElement(path string, index int) error

RemoveArrayElement removes an element from an array at the given path

func (*YAMLEditor) Save added in v0.9.17

func (e *YAMLEditor) Save() error

Save writes the modified YAML back to the file

func (*YAMLEditor) SaveToFile added in v0.9.17

func (e *YAMLEditor) SaveToFile(filePath string) error

SaveToFile saves the modified YAML to a different file

func (*YAMLEditor) SetValue added in v0.9.17

func (e *YAMLEditor) SetValue(path string, value string) error

SetValue sets a value at the given path (e.g., "databases.vector_databases[2].database_url")

Jump to

Keyboard shortcuts

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