utils

package
v0.0.0-...-35696f1 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultSSHPort = 22
)

Variables

This section is empty.

Functions

func ExportFS

func ExportFS(fsys fs.ReadDirFS, path string) error

func GetEnvOrDefault

func GetEnvOrDefault(k, d string) string

func GetLoggerFromContext

func GetLoggerFromContext(ctx context.Context) (*log.Entry, bool)

func GetLoggerFromContextOrDefault

func GetLoggerFromContextOrDefault(ctx context.Context) *log.Entry

func GetLoggerFromContextOrDiscard

func GetLoggerFromContextOrDiscard(ctx context.Context) *log.Entry

func GetServiceLogs

func GetServiceLogs(input *SSHJournalctlInput, startTime time.Time, stdout, stderr io.Writer) error

GetServiceLogs retrieves log entries stored in journal by systemd via ssh.

func SetLoggerForContext

func SetLoggerForContext(ctx context.Context, l *log.Entry) context.Context

Types

type LoggerContextKeyType

type LoggerContextKeyType string
const LoggerContextKey LoggerContextKeyType = "TestEnvContextLogger"

type SSHForwardCallback

type SSHForwardCallback func(ctx context.Context, err error) error

type SSHForwardInput

type SSHForwardInput struct {
	PrivateKey    []byte
	User          string
	Host          string
	Port          int
	LocalPort     int
	RemoteAddress string
	RemotePort    int

	Callback SSHForwardCallback
}

func (*SSHForwardInput) HostAddressPort

func (i *SSHForwardInput) HostAddressPort() string

func (*SSHForwardInput) LocalAddressPort

func (i *SSHForwardInput) LocalAddressPort() string

func (*SSHForwardInput) RemoteAddressPort

func (i *SSHForwardInput) RemoteAddressPort() string

type SSHJournalctlInput

type SSHJournalctlInput struct {
	PrivateKey []byte
	PublicKey  []byte
	User       string
	Host       string
	WorkDir    string
	Service    string
}

type SSHKeyPair

type SSHKeyPair struct {
	PublicKey  []byte
	PrivateKey []byte
}

func GenerateSSHKeyPair

func GenerateSSHKeyPair() (*SSHKeyPair, error)

GenerateSSHKeyPair generates a new SSH key pair.

func (*SSHKeyPair) Load

func (p *SSHKeyPair) Load(privKeyFile, pubKeyFile string) error

Load is responsible for loading the ssh keypair from filesystem into SSHKeyPair.

func (*SSHKeyPair) Save

func (p *SSHKeyPair) Save(privKeyFile, pubKeyFile string) error

Save is responsible for writing the SSHKeyPair to the filesystem.

type SSHPortForward

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

func NewSSHPortForward

func NewSSHPortForward(input *SSHForwardInput) (*SSHPortForward, error)

func (*SSHPortForward) Start

func (f *SSHPortForward) Start(ctx context.Context) error

func (*SSHPortForward) Stop

func (f *SSHPortForward) Stop()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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