ssh_config_file

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxBackups     = 10
	TempSuffix     = ".tmp"
	BackupSuffix   = "lazyssh.backup"
	SSHConfigPerms = 0o600
)

Variables

This section is empty.

Functions

func NewRepository

func NewRepository(logger *zap.SugaredLogger, configPath, metaDataPath string) ports.ServerRepository

NewRepository creates a new SSH config repository.

func NewRepositoryWithFS

func NewRepositoryWithFS(logger *zap.SugaredLogger, configPath string, metaDataPath string, fs FileSystem) ports.ServerRepository

NewRepositoryWithFS creates a new SSH config repository with a custom filesystem.

Types

type DefaultFileSystem

type DefaultFileSystem struct{}

DefaultFileSystem implements FileSystem using standard os package.

func (DefaultFileSystem) Chmod

func (fs DefaultFileSystem) Chmod(path string, perms os.FileMode) error

func (DefaultFileSystem) Create

func (fs DefaultFileSystem) Create(name string) (io.WriteCloser, error)

func (DefaultFileSystem) IsNotExist

func (fs DefaultFileSystem) IsNotExist(err error) bool

func (DefaultFileSystem) Open

func (fs DefaultFileSystem) Open(name string) (io.ReadCloser, error)

func (DefaultFileSystem) OpenFile

func (fs DefaultFileSystem) OpenFile(path string, i int, perms os.FileMode) (*os.File, error)

func (DefaultFileSystem) ReadDir

func (fs DefaultFileSystem) ReadDir(dir string) ([]os.DirEntry, error)

func (DefaultFileSystem) Remove

func (fs DefaultFileSystem) Remove(file string) error

func (DefaultFileSystem) Rename

func (fs DefaultFileSystem) Rename(file string, path string) error

func (DefaultFileSystem) Stat

func (fs DefaultFileSystem) Stat(name string) (os.FileInfo, error)

type FileSystem

type FileSystem interface {
	Open(name string) (io.ReadCloser, error)
	Create(name string) (io.WriteCloser, error)
	Stat(name string) (os.FileInfo, error)
	IsNotExist(err error) bool
	Remove(file string) error
	Rename(file string, path string) error
	Chmod(path string, perms os.FileMode) error
	OpenFile(path string, i int, perms os.FileMode) (*os.File, error)
	ReadDir(dir string) ([]os.DirEntry, error)
}

FileSystem interface for file operations to enable testing.

type Repository

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

Repository implements ServerRepository interface for SSH config file operations.

func (*Repository) AddServer

func (r *Repository) AddServer(server domain.Server) error

AddServer adds a new server to the SSH config.

func (*Repository) DeleteServer

func (r *Repository) DeleteServer(server domain.Server) error

DeleteServer removes a server from the SSH config.

func (*Repository) ListServers

func (r *Repository) ListServers(query string) ([]domain.Server, error)

ListServers returns all servers matching the query pattern. Empty query returns all servers.

func (*Repository) RecordSSH

func (r *Repository) RecordSSH(alias string) error

RecordSSH increments the SSH access count and updates the last seen timestamp for a server.

func (*Repository) SetPinned

func (r *Repository) SetPinned(alias string, pinned bool) error

SetPinned sets or unsets the pinned status of a server.

func (*Repository) UpdateServer

func (r *Repository) UpdateServer(server domain.Server, newServer domain.Server) error

UpdateServer updates an existing server in the SSH config.

type ServerMetadata

type ServerMetadata struct {
	Tags     []string `json:"tags,omitempty"`
	LastSeen string   `json:"last_seen,omitempty"`
	PinnedAt string   `json:"pinned_at,omitempty"`
	SSHCount int      `json:"ssh_count,omitempty"`
}

Jump to

Keyboard shortcuts

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