models

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigProvider

type ConfigProvider interface {
	Load() ([]*Server, error)
	Save(servers []*Server) error
}

ConfigProvider defines the contract for loading and persisting server inventories.

type DirectoryAlias

type DirectoryAlias struct {
	Name        string   `json:"name" yaml:"name"`
	Path        string   `json:"path" yaml:"path"`
	Description string   `json:"description,omitempty" yaml:"description,omitempty"`
	Tags        []string `json:"tags,omitempty" yaml:"tags,omitempty"`
}

DirectoryAlias represents a bookmarked local folder shortcut.

func (*DirectoryAlias) Exists

func (a *DirectoryAlias) Exists() bool

Exists checks if the bookmarked directory exists on the filesystem.

func (*DirectoryAlias) ExpandedPath

func (a *DirectoryAlias) ExpandedPath() string

ExpandedPath expands ~ and environment variables in the alias path.

func (*DirectoryAlias) MatchesQuery

func (a *DirectoryAlias) MatchesQuery(q string) bool

MatchesQuery returns true if the alias matches the search query.

type Endpoint

type Endpoint struct {
	Name             string         `json:"name" yaml:"name"`
	URL              string         `json:"url" yaml:"url"`
	StatusCode       int            `json:"status_code,omitempty" yaml:"status_code,omitempty"`
	Latency          time.Duration  `json:"latency,omitempty" yaml:"latency,omitempty"`
	SSLDaysRemaining int            `json:"ssl_days_remaining,omitempty" yaml:"ssl_days_remaining,omitempty"`
	SSLExpiry        time.Time      `json:"ssl_expiry,omitempty" yaml:"ssl_expiry,omitempty"`
	Status           EndpointStatus `json:"status,omitempty" yaml:"status,omitempty"`
	Error            string         `json:"error,omitempty" yaml:"error,omitempty"`
	LastChecked      time.Time      `json:"last_checked,omitempty" yaml:"last_checked,omitempty"`
}

Endpoint represents an HTTP or HTTPS service to monitor for availability and SSL expiration.

func (*Endpoint) MatchesQuery

func (e *Endpoint) MatchesQuery(q string) bool

MatchesQuery returns true if the endpoint matches the search query.

type EndpointStatus

type EndpointStatus string

EndpointStatus defines the health state of an HTTP/HTTPS endpoint.

const (
	EndpointStatusUp       EndpointStatus = "UP"
	EndpointStatusDegraded EndpointStatus = "DEGRADED"
	EndpointStatusDown     EndpointStatus = "DOWN"
	EndpointStatusChecking EndpointStatus = "CHECKING"
	EndpointStatusUnknown  EndpointStatus = "UNKNOWN"
)

type ExportData

type ExportData struct {
	Servers   []Server          `json:"servers" yaml:"servers"`
	Tunnels   []Tunnel          `json:"tunnels,omitempty" yaml:"tunnels,omitempty"`
	Aliases   []DirectoryAlias  `json:"aliases,omitempty" yaml:"aliases,omitempty"`
	Snippets  []Snippet         `json:"snippets,omitempty" yaml:"snippets,omitempty"`
	Endpoints []Endpoint        `json:"endpoints,omitempty" yaml:"endpoints,omitempty"`
	Tags      []string          `json:"tags,omitempty" yaml:"tags,omitempty"`
	Meta      map[string]string `json:"meta,omitempty" yaml:"meta,omitempty"`
}

ExportData contains the actual exported resources.

type ExportEnvelope

type ExportEnvelope struct {
	Magic      string            `json:"magic"`                // "DECK_EXPORT"
	Version    string            `json:"version"`              // "1.0"
	CreatedAt  time.Time         `json:"created_at"`           // Timestamp
	Encrypted  bool              `json:"encrypted"`            // True if payload is AES-GCM encrypted
	Salt       string            `json:"salt,omitempty"`       // Argon2id salt (base64)
	Nonce      string            `json:"nonce,omitempty"`      // AES-GCM nonce (base64)
	Ciphertext string            `json:"ciphertext,omitempty"` // Encrypted payload (base64)
	Payload    *ExportData       `json:"payload,omitempty"`    // Unencrypted payload if Encrypted is false
	Metadata   map[string]string `json:"metadata,omitempty"`
}

ExportEnvelope represents the top-level serialized container for exports.

type PingResult

type PingResult struct {
	ServerName string
	Status     ServerStatus
	Latency    time.Duration
	Timestamp  time.Time
	Err        error
}

PingResult represents the outcome of a server reachability test.

type Pinger

type Pinger interface {
	Probe(ctx context.Context, server *Server) (*PingResult, error)
	ProbeAll(ctx context.Context, servers []*Server, concurrency int) <-chan *PingResult
}

Pinger defines the contract for checking server reachability and latency.

type SSHExecutor

type SSHExecutor interface {
	Connect(server *Server) error
	FetchStats(ctx context.Context, server *Server) (*ServerStats, error)
}

SSHExecutor handles interactive terminal handoff and background command execution.

type Server

type Server struct {
	Name         string            `json:"name" yaml:"name"`
	Hostname     string            `json:"hostname" yaml:"hostname"`
	User         string            `json:"user,omitempty" yaml:"user,omitempty"`
	Port         int               `json:"port,omitempty" yaml:"port,omitempty"`
	IdentityFile string            `json:"identity_file,omitempty" yaml:"identity_file,omitempty"`
	ProxyJump    string            `json:"proxy_jump,omitempty" yaml:"proxy_jump,omitempty"`
	Tags         []string          `json:"tags,omitempty" yaml:"tags,omitempty"`
	Environment  string            `json:"environment,omitempty" yaml:"environment,omitempty"`
	Description  string            `json:"description,omitempty" yaml:"description,omitempty"`
	Source       string            `json:"source" yaml:"source"` // "ssh_config" or "deck_yaml"
	Status       ServerStatus      `json:"status" yaml:"status"`
	Latency      time.Duration     `json:"latency" yaml:"latency"`
	LastChecked  time.Time         `json:"last_checked" yaml:"last_checked"`
	Stats        *ServerStats      `json:"stats,omitempty" yaml:"stats,omitempty"`
	ExtraOptions map[string]string `json:"extra_options,omitempty" yaml:"extra_options,omitempty"`
}

Server represents an individual SSH host or target in deck.

func (*Server) DisplayAddress

func (s *Server) DisplayAddress() string

DisplayAddress returns user@host:port or host:port.

func (*Server) EffectivePort

func (s *Server) EffectivePort() int

EffectivePort returns the port or default 22.

func (*Server) EffectiveUser

func (s *Server) EffectiveUser() string

EffectiveUser returns the configured user or empty string.

func (*Server) MatchesQuery

func (s *Server) MatchesQuery(q string) bool

MatchesQuery returns true if the server matches the search query.

type ServerStats

type ServerStats struct {
	Uptime      string    `json:"uptime" yaml:"uptime"`
	LoadAvg     string    `json:"load_avg" yaml:"load_avg"`
	MemoryUsed  string    `json:"memory_used" yaml:"memory_used"`
	MemoryTotal string    `json:"memory_total" yaml:"memory_total"`
	MemoryPct   int       `json:"memory_pct" yaml:"memory_pct"`
	DiskUsed    string    `json:"disk_used" yaml:"disk_used"`
	DiskTotal   string    `json:"disk_total" yaml:"disk_total"`
	DiskPct     int       `json:"disk_pct" yaml:"disk_pct"`
	OSInfo      string    `json:"os_info" yaml:"os_info"`
	FetchedAt   time.Time `json:"fetched_at" yaml:"fetched_at"`
	Error       string    `json:"error,omitempty" yaml:"error,omitempty"`
}

ServerStats contains lightweight runtime performance metrics fetched from a remote server.

type ServerStatus

type ServerStatus string

ServerStatus represents the connectivity state of a server.

const (
	StatusOnline   ServerStatus = "online"
	StatusOffline  ServerStatus = "offline"
	StatusChecking ServerStatus = "checking"
	StatusUnknown  ServerStatus = "unknown"
)

type Settings

type Settings struct {
	AutoSyncShellAliases bool   `yaml:"auto_sync_shell_aliases" json:"auto_sync_shell_aliases"`
	Theme                string `yaml:"theme" json:"theme"`
	AutoPingOnLaunch     bool   `yaml:"auto_ping_on_launch" json:"auto_ping_on_launch"`
	PingInterval         int    `yaml:"ping_interval" json:"ping_interval"` // In seconds (0 = disabled)
	DefaultSSHUser       string `yaml:"default_ssh_user" json:"default_ssh_user"`
	ConfirmOnDelete      bool   `yaml:"confirm_on_delete" json:"confirm_on_delete"`
	CheckUpdatesOnStart  bool   `yaml:"check_updates_on_start" json:"check_updates_on_start"`
}

Settings holds configurable user preferences for Deck.

func DefaultSettings

func DefaultSettings() Settings

DefaultSettings returns Deck default settings.

type Snippet

type Snippet struct {
	Name        string   `json:"name" yaml:"name"`
	Command     string   `json:"command" yaml:"command"`
	Description string   `json:"description,omitempty" yaml:"description,omitempty"`
	TargetHost  string   `json:"target_host,omitempty" yaml:"target_host,omitempty"` // empty for local, or SSH host
	Tags        []string `json:"tags,omitempty" yaml:"tags,omitempty"`
}

Snippet represents a reusable terminal command or runbook script.

func (*Snippet) MatchesQuery

func (s *Snippet) MatchesQuery(q string) bool

MatchesQuery returns true if the snippet matches the search query.

type TransferService

type TransferService interface {
	ExportBase64(data *ExportData, password string) (string, error)
	ImportBase64(raw string, password string) (*ExportData, error)
}

TransferService manages serialization, base64 encoding/decoding and selective imports.

type Tunnel

type Tunnel struct {
	Name       string `json:"name" yaml:"name"`
	ServerName string `json:"server_name" yaml:"server_name"`
	LocalPort  int    `json:"local_port" yaml:"local_port"`
	RemoteHost string `json:"remote_host" yaml:"remote_host"`
	RemotePort int    `json:"remote_port" yaml:"remote_port"`
	Type       string `json:"type,omitempty" yaml:"type,omitempty"` // local, remote, dynamic
	Active     bool   `json:"active" yaml:"active"`
	PID        int    `json:"pid,omitempty" yaml:"pid,omitempty"`
	Error      string `json:"error,omitempty" yaml:"error,omitempty"`
}

Tunnel represents an SSH port-forwarding configuration.

func (*Tunnel) MatchesQuery

func (t *Tunnel) MatchesQuery(q string) bool

MatchesQuery returns true if the tunnel matches the search query.

type VaultService

type VaultService interface {
	Encrypt(data []byte, password string) (*ExportEnvelope, error)
	Decrypt(envelope *ExportEnvelope, password string) ([]byte, error)
	IsPasswordProtected() bool
	SetMasterPassword(password string) error
	VerifyMasterPassword(password string) bool
}

VaultService handles secure encryption, key derivation and payload decryption.

Jump to

Keyboard shortcuts

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