feat: complete Tasks 1-3 (setup, models+storage, config management)
- Task 1: Project setup (go.mod, Makefile, .gitignore, main.go) - Task 2: Core data models (Host, KeyPair, Snippet, AppConfig) + JSON storage layer - Task 3: Configuration management with cross-platform path support (macOS/Linux/Windows) - Updated PROJECT_STATE.md with progress tracking
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Host represents an SSH host connection configuration
|
||||
type Host struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Hostname string `json:"hostname"`
|
||||
Port int `json:"port"`
|
||||
Username string `json:"username"`
|
||||
Auth AuthConfig `json:"auth"`
|
||||
Group string `json:"group,omitempty"`
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
Notes string `json:"notes,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
LastUsedAt *time.Time `json:"last_used_at,omitempty"`
|
||||
}
|
||||
|
||||
// AuthConfig represents authentication configuration
|
||||
type AuthConfig struct {
|
||||
Type string `json:"type"` // "password", "key", "both"
|
||||
Password string `json:"password,omitempty"`
|
||||
KeyID string `json:"key_id,omitempty"` // Reference to KeyPair ID
|
||||
}
|
||||
|
||||
// KeyPair represents an SSH key pair
|
||||
type KeyPair struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"` // "rsa", "ed25519", "ecdsa"
|
||||
PrivateKey string `json:"private_key"`
|
||||
PublicKey string `json:"public_key,omitempty"`
|
||||
Passphrase string `json:"passphrase,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// Snippet represents a command snippet
|
||||
type Snippet struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Command string `json:"command"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// AppConfig represents the application configuration
|
||||
type AppConfig struct {
|
||||
Version string `json:"version"`
|
||||
DefaultPort int `json:"default_port"`
|
||||
ConnectionTimeout int `json:"connection_timeout"` // in seconds
|
||||
Theme string `json:"theme"`
|
||||
Editor string `json:"editor"`
|
||||
AutoSync bool `json:"auto_sync"`
|
||||
SyncProvider string `json:"sync_provider,omitempty"`
|
||||
}
|
||||
|
||||
// DefaultConfig returns the default application configuration
|
||||
func DefaultConfig() *AppConfig {
|
||||
return &AppConfig{
|
||||
Version: "1.0.0",
|
||||
DefaultPort: 22,
|
||||
ConnectionTimeout: 30,
|
||||
Theme: "dark",
|
||||
Editor: "vim",
|
||||
AutoSync: false,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user