Documentation
¶
Index ¶
- Variables
- func InitializeTemplates(fs embed.FS) error
- func RegisterTemplate(name string, template Template)
- type BaseTemplate
- type DefaultPortChecker
- type DefaultServiceStarter
- func (s *DefaultServiceStarter) GetServiceStatus(ctx context.Context, service string) (ServiceStatus, error)
- func (s *DefaultServiceStarter) StartService(ctx context.Context, service string, config ServiceConfig) error
- func (s *DefaultServiceStarter) StopService(ctx context.Context, service string) error
- type DockerCompose
- type DockerNetwork
- type DockerService
- type DockerVolume
- type Generator
- type HealthCheck
- type Logger
- type ModelInfo
- type ModelManager
- type ModelRequirement
- type PortAllocation
- type PortChecker
- type PortManager
- func (pm *PortManager) AllocatePort(service string, preferred int) (int, error)
- func (pm *PortManager) AllocateTemplatePorts(services []string, options SetupOptions) (*PortAllocation, error)
- func (pm *PortManager) GetAllocatedPorts() map[int]string
- func (pm *PortManager) GetServicePort(service string) (int, bool)
- func (pm *PortManager) ReleasePort(port int)
- type ProgressHandler
- type ServiceConfig
- type ServiceStarter
- type ServiceStatus
- type SetupContext
- type SetupOptions
- type SetupWizard
- type SystemChecker
- type SystemResources
- type Template
- type TemplateError
- type TemplateInfo
- type TemplateMetadata
- type TemplateRegistry
- type TemplateVars
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
var DefaultPorts = map[string]int{
"ollama": 11434,
"postgres": 5432,
"redis": 6379,
"minio": 9000,
"minio-console": 9001,
"api": 8080,
"frontend": 3000,
"localllama": 8081,
}
DefaultPorts contains default ports for services
var ( // TemplatesFS should be set by main package TemplatesFS embed.FS )
Functions ¶
func RegisterTemplate ¶
RegisterTemplate registers a template
Types ¶
type BaseTemplate ¶
type BaseTemplate struct {
// contains filtered or unexported fields
}
BaseTemplate provides common functionality for all templates
func NewBaseTemplate ¶
func NewBaseTemplate(name string, templatesFS embed.FS) (*BaseTemplate, error)
NewBaseTemplate creates a new base template
func (*BaseTemplate) Generate ¶
func (t *BaseTemplate) Generate(projectPath string, options SetupOptions) error
Generate creates the project structure
func (*BaseTemplate) GetMetadata ¶
func (t *BaseTemplate) GetMetadata() TemplateMetadata
GetMetadata returns template metadata
func (*BaseTemplate) PostSetup ¶
func (t *BaseTemplate) PostSetup() error
PostSetup runs post-installation tasks
func (*BaseTemplate) Validate ¶
func (t *BaseTemplate) Validate(resources SystemResources) error
Validate checks if system resources meet requirements
type DefaultPortChecker ¶
type DefaultPortChecker struct{}
DefaultPortChecker implements basic port checking
func (*DefaultPortChecker) CheckPort ¶
func (d *DefaultPortChecker) CheckPort(port int) bool
CheckPort checks if a port is available
type DefaultServiceStarter ¶
type DefaultServiceStarter struct {
}
DefaultServiceStarter provides default service management
func (*DefaultServiceStarter) GetServiceStatus ¶
func (s *DefaultServiceStarter) GetServiceStatus(ctx context.Context, service string) (ServiceStatus, error)
GetServiceStatus gets service status
func (*DefaultServiceStarter) StartService ¶
func (s *DefaultServiceStarter) StartService(ctx context.Context, service string, config ServiceConfig) error
StartService starts a Docker service
func (*DefaultServiceStarter) StopService ¶
func (s *DefaultServiceStarter) StopService(ctx context.Context, service string) error
StopService stops a Docker service
type DockerCompose ¶
type DockerCompose struct {
Version string `yaml:"version"`
Services map[string]DockerService `yaml:"services"`
Networks map[string]DockerNetwork `yaml:"networks,omitempty"`
Volumes map[string]DockerVolume `yaml:"volumes,omitempty"`
}
DockerCompose represents docker-compose.yml structure
type DockerNetwork ¶
type DockerNetwork struct {
Driver string `yaml:"driver,omitempty"`
}
DockerNetwork represents a network in docker-compose
type DockerService ¶
type DockerService struct {
Image string `yaml:"image"`
ContainerName string `yaml:"container_name,omitempty"`
Ports []string `yaml:"ports,omitempty"`
Environment map[string]string `yaml:"environment,omitempty"`
Volumes []string `yaml:"volumes,omitempty"`
Networks []string `yaml:"networks,omitempty"`
DependsOn []string `yaml:"depends_on,omitempty"`
Restart string `yaml:"restart,omitempty"`
Command []string `yaml:"command,omitempty"`
HealthCheck *HealthCheck `yaml:"healthcheck,omitempty"`
}
DockerService represents a service in docker-compose
type DockerVolume ¶
type DockerVolume struct {
Driver string `yaml:"driver,omitempty"`
DriverOpts map[string]string `yaml:"driver_opts,omitempty"`
}
DockerVolume represents a volume in docker-compose
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator handles template file generation
func NewGenerator ¶
NewGenerator creates a new template generator
type HealthCheck ¶
type HealthCheck struct {
Test []string `yaml:"test"`
Interval string `yaml:"interval"`
Timeout string `yaml:"timeout"`
Retries int `yaml:"retries"`
}
HealthCheck represents docker health check
type Logger ¶
type Logger interface {
Debug(msg string, args ...interface{})
Info(msg string, args ...interface{})
Warn(msg string, args ...interface{})
Error(msg string, args ...interface{})
}
Logger interface for template logging
type ModelManager ¶
type ModelManager interface {
ListModels() ([]ModelInfo, error)
PullModel(name string) error
GetModelInfo(name string) (*ModelInfo, error)
}
ModelManager interface for AI model management
type ModelRequirement ¶
type ModelRequirement struct {
Name string `yaml:"name"`
Size int64 `yaml:"size"` // Size in bytes
MinRAM int64 `yaml:"minRAM"` // Minimum RAM for this model
Recommended bool `yaml:"recommended"` // Is this the recommended model
Default bool `yaml:"default"` // Is this the default model
}
ModelRequirement specifies AI model requirements
type PortAllocation ¶
type PortAllocation struct {
API int `json:"api_port"`
Frontend int `json:"frontend_port"`
Database int `json:"database_port"`
Cache int `json:"cache_port"`
Storage int `json:"storage_port"`
StorageUI int `json:"storage_ui_port"`
AI int `json:"ai_port"`
Custom map[string]int `json:"custom_ports"`
}
PortAllocation represents port assignments for a template
type PortChecker ¶
PortChecker interface for checking port availability
type PortManager ¶
type PortManager struct {
// contains filtered or unexported fields
}
PortManager manages port allocation for services
func NewPortManagerWithChecker ¶
func NewPortManagerWithChecker(checker PortChecker) *PortManager
NewPortManagerWithChecker creates a port manager with custom checker
func (*PortManager) AllocatePort ¶
func (pm *PortManager) AllocatePort(service string, preferred int) (int, error)
AllocatePort finds an available port for a service
func (*PortManager) AllocateTemplatePorts ¶
func (pm *PortManager) AllocateTemplatePorts(services []string, options SetupOptions) (*PortAllocation, error)
AllocateTemplatePorts allocates all required ports for a template
func (*PortManager) GetAllocatedPorts ¶
func (pm *PortManager) GetAllocatedPorts() map[int]string
GetAllocatedPorts returns all allocated ports
func (*PortManager) GetServicePort ¶
func (pm *PortManager) GetServicePort(service string) (int, bool)
GetServicePort returns the allocated port for a service
func (*PortManager) ReleasePort ¶
func (pm *PortManager) ReleasePort(port int)
ReleasePort releases a previously allocated port
type ProgressHandler ¶
type ProgressHandler interface {
Start(total int)
Update(current int, message string)
Complete()
Error(err error)
}
ProgressHandler interface for setup progress updates
type ServiceConfig ¶
type ServiceConfig struct {
Name string
Image string
Ports map[string]string
Environment map[string]string
Volumes []string
Networks []string
HealthCheck *HealthCheck
RestartPolicy string
}
ServiceConfig contains service configuration
type ServiceStarter ¶
type ServiceStarter interface {
StartService(ctx context.Context, service string, config ServiceConfig) error
StopService(ctx context.Context, service string) error
GetServiceStatus(ctx context.Context, service string) (ServiceStatus, error)
}
ServiceStarter interface for starting services
type ServiceStatus ¶
ServiceStatus represents service status
type SetupContext ¶
type SetupContext struct {
Context context.Context
ProjectPath string
Options SetupOptions
Resources SystemResources
Logger Logger
ProgressHandler ProgressHandler
}
SetupContext contains context for template setup
type SetupOptions ¶
type SetupOptions struct {
ProjectName string
APIPort int
FrontendPort int
DatabasePort int
ModelName string
DatabasePassword string
SkipDocker bool // Generate files only, don't start services
Force bool // Overwrite existing directory
}
SetupOptions contains user-provided setup configuration
type SetupWizard ¶
type SetupWizard struct {
// contains filtered or unexported fields
}
SetupWizard handles interactive template setup
func NewSetupWizard ¶
func NewSetupWizard(template Template, systemCheck SystemChecker, portManager *PortManager, modelManager ModelManager, generator *Generator) *SetupWizard
NewSetupWizard creates a new setup wizard
func (*SetupWizard) Run ¶
func (w *SetupWizard) Run(ctx context.Context, templateName string, options SetupOptions) error
Run executes the setup wizard
type SystemChecker ¶
type SystemChecker interface {
GetSystemInfo() (system.SystemInfo, error)
CheckRequirements(minRAM, minDisk int64) error
RecommendModel(models []system.ModelSpec, availableRAM int64) *system.ModelSpec
}
SystemChecker interface for system resource checking
type SystemResources ¶
type SystemResources struct {
TotalRAM int64
AvailableRAM int64
TotalDisk int64
AvailableDisk int64
CPUCount int
DockerInstalled bool
DockerVersion string
OllamaInstalled bool
LocalLlamaInstalled bool
Platform string // darwin, linux, windows
Architecture string // amd64, arm64
}
SystemResources contains information about the host system
type Template ¶
type Template interface {
// GetMetadata returns template information
GetMetadata() TemplateMetadata
// Validate checks if system resources meet template requirements
Validate(resources SystemResources) error
// Generate creates the project structure and files
Generate(projectPath string, options SetupOptions) error
// PostSetup runs any post-installation scripts or tasks
PostSetup() error
}
Template defines the interface that all templates must implement
func GetTemplate ¶
GetTemplate retrieves a template by name
type TemplateError ¶
type TemplateError struct {
Template string
Stage string // validate, generate, postsetup
Err error
}
TemplateError represents a template-related error
func (*TemplateError) Error ¶
func (e *TemplateError) Error() string
type TemplateInfo ¶
type TemplateInfo struct {
Name string
Description string
Version string
MinRAM string
MinDisk string
Services int
}
TemplateInfo contains template information for listing
func ListTemplates ¶
func ListTemplates() []TemplateInfo
ListTemplates returns all available templates
type TemplateMetadata ¶
type TemplateMetadata struct {
Name string `yaml:"name"`
Description string `yaml:"description"`
Version string `yaml:"version"`
MinRAM int64 `yaml:"minRAM"` // Minimum RAM in bytes
MinDisk int64 `yaml:"minDisk"` // Minimum disk space in bytes
Services []string `yaml:"services"` // Required services (ollama, postgres, etc.)
Models []ModelRequirement `yaml:"models"`
}
TemplateMetadata contains information about a template
type TemplateRegistry ¶
type TemplateRegistry struct {
// contains filtered or unexported fields
}
TemplateRegistry manages available templates
func NewTemplateRegistry ¶
func NewTemplateRegistry() *TemplateRegistry
NewTemplateRegistry creates a new template registry
func (*TemplateRegistry) Get ¶
func (r *TemplateRegistry) Get(name string) (Template, bool)
Get retrieves a template by name
func (*TemplateRegistry) List ¶
func (r *TemplateRegistry) List() map[string]Template
List returns all registered templates
func (*TemplateRegistry) Register ¶
func (r *TemplateRegistry) Register(name string, template Template)
Register adds a template to the registry
type TemplateVars ¶
type TemplateVars struct {
ProjectName string
APIPort int
FrontendPort int
DatabasePort int
CachePort int
StoragePort int
StorageUIPort int
AIPort int
ModelName string
DatabasePassword string
DatabaseUser string
DatabaseName string
JWTSecret string
// Computed values
APIBaseURL string
FrontendURL string
// Additional custom variables
Custom map[string]interface{}
}
TemplateVars contains variables for template substitution
type ValidationError ¶
ValidationError represents a validation failure
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string