util

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2025 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ContextKeyFilepath = &contextKey{"note-filepath"}
View Source
var ContextKeyProjectId = &contextKey{"project-id"}
View Source
var Logger *logrus.Logger

Functions

func CreateSQLite3Database

func CreateSQLite3Database() (*sql.DB, error)

func ExpandTilde

func ExpandTilde(path string) (string, error)

ExpandTilde expands the tilde in the given path to the user's home directory.

func FixSSHKeyData

func FixSSHKeyData(sshkey string) []byte

func GetNote

func GetNote(db *sql.DB, historyIDs []int, title string, comment string) (string, error)

func GetUsernameProjectIfPresent

func GetUsernameProjectIfPresent(entry string) (string, string, string)

func ReadNote

func ReadNote(username string, pk string, projectId string, ip string, port string) error

func SHA256SUM

func SHA256SUM(data string) string

func SendNote

func SendNote(note string, username string, pk string, projectId string, ip string, port string) error

func SetLogger

func SetLogger(filepath string) *logrus.Logger

Types

type ClientWrapper

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

ClientWrapper provides basic functionality to interact with a SFTP server.

func NewSFTPClientWrapper

func NewSFTPClientWrapper(config SFTPConfig) (*ClientWrapper, error)

New initialises SSH and SFTP clients and returns Client type to use.

func (*ClientWrapper) Close

func (c *ClientWrapper) Close()

Close closes open connections.

func (*ClientWrapper) Create

func (c *ClientWrapper) Create(filePath string) (io.ReadWriteCloser, error)

Create creates a remote/destination file for I/O.

func (*ClientWrapper) Download

func (c *ClientWrapper) Download(filePath string) (io.ReadCloser, error)

Download returns remote/destination file for reading.

func (*ClientWrapper) Info

func (c *ClientWrapper) Info(filePath string) (os.FileInfo, error)

Info gets the details of a file. If the file was not found, an error is returned.

func (*ClientWrapper) Upload

func (c *ClientWrapper) Upload(source io.Reader, destination io.Writer, size int) error

Upload writes local/source file data streams to remote/destination file.

type FormatterHook

type FormatterHook struct {
	Writer    io.Writer
	LogLevels []logrus.Level
	Formatter logrus.Formatter
}

FormatterHook is a hook that writes logs of specified LogLevels with a formatter to specified Writer

func (*FormatterHook) Fire

func (hook *FormatterHook) Fire(entry *logrus.Entry) error

Fire will be called when some logging function is called with current hook It will format log entry and write it to appropriate writer

func (*FormatterHook) Levels

func (hook *FormatterHook) Levels() []logrus.Level

Levels define on which log levels this hook would trigger

type HistoryOutput

type HistoryOutput struct {
	Executable  string
	Command     string
	Environment string
	ExitCode    int
	Stdout      string
	Stderr      string
}

HistoryOutput represents the combined result of history and output tables

type HistorySelection

type HistorySelection struct {
	Id      int
	Command string
}

func GetHistory

func GetHistory(db *sql.DB, limit int) ([]HistorySelection, error)

type SFTPConfig

type SFTPConfig struct {
	Username     string
	Password     string
	PrivateKey   string
	Server       string
	KeyExchanges []string

	Timeout time.Duration
}

SFTPConfig represents SSH connection parameters.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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