Documentation
¶
Overview ¶
Package modelctx provides persistent storage for named Docker Model Runner contexts, allowing users to switch between different Model Runner backends without setting environment variables each time.
Index ¶
- Constants
- func ValidateName(name string) error
- type ContextConfig
- type Store
- func (s *Store) Active() (string, error)
- func (s *Store) Create(name string, cfg ContextConfig) error
- func (s *Store) Get(name string) (ContextConfig, error)
- func (s *Store) List() (map[string]ContextConfig, error)
- func (s *Store) Remove(name string) error
- func (s *Store) SetActive(name string) error
- type TLSConfig
Constants ¶
const DefaultContextName = "default"
DefaultContextName is the reserved name for the auto-detected context. It is never written to disk; a missing or empty "current" value implies it.
Variables ¶
This section is empty.
Functions ¶
func ValidateName ¶
ValidateName returns an error if name is reserved or does not match the allowed pattern.
Types ¶
type ContextConfig ¶
type ContextConfig struct {
// Host is the Model Runner API base URL (e.g. "http://192.168.1.100:12434").
Host string `json:"host"`
// TLS holds optional TLS settings.
TLS TLSConfig `json:"tls,omitempty"`
// Description is an optional human-readable note.
Description string `json:"description,omitempty"`
// CreatedAt records when the context was created.
CreatedAt time.Time `json:"createdAt"`
}
ContextConfig is the configuration for a named Model Runner context.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store manages named Model Runner contexts stored in a single JSON file.
func New ¶
New returns a Store that persists contexts in <dockerConfigDir>/model/contexts.json. It creates the parent directory if it does not exist.
func (*Store) Active ¶
Active returns the name of the currently active context, or DefaultContextName if none has been set.
func (*Store) Create ¶
func (s *Store) Create(name string, cfg ContextConfig) error
Create writes a new named context. It returns an error if the name is reserved, fails validation, or already exists.
func (*Store) Get ¶
func (s *Store) Get(name string) (ContextConfig, error)
Get returns the configuration for the named context.
func (*Store) List ¶
func (s *Store) List() (map[string]ContextConfig, error)
List returns all named contexts. The synthetic "default" context is not included.
type TLSConfig ¶
type TLSConfig struct {
// Enabled indicates whether TLS is used for this context.
Enabled bool `json:"enabled"`
// SkipVerify disables TLS server certificate verification.
SkipVerify bool `json:"skipVerify,omitempty"`
// CACert is the absolute path to a custom CA certificate PEM file.
CACert string `json:"caCert,omitempty"`
}
TLSConfig holds optional TLS settings for a named context.