util

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// Maximum number of allowed SSH host keys
	MaxAllowedHostKeys = 100
	// Maximum size of a single SSH public key file (in bytes)
	MaxKeyFileSize = 16 * 1024 // 16KB should be more than enough for any SSH key
)

Variables

This section is empty.

Functions

func Contains

func Contains(slice []string, s string) bool

Method to check if a string exists in a slice

func CreateSSHClient added in v0.16.0

func CreateSSHClient(config *SSHConfig) (*ssh.ClientConfig, error)

CreateSSHClient creates a complete SSH client configuration

func GenerateInstanceName

func GenerateInstanceName(podName, sandboxID string, podvmNameMax int) string

func NodeLabels

func NodeLabels(ctx context.Context, name string) (map[string]string, error)

func ReadAndValidatePrivateKey added in v0.16.0

func ReadAndValidatePrivateKey(path string) (string, error)

ReadAndValidatePrivateKey reads and validates a private key file

func ReadAndValidatePublicKey added in v0.16.0

func ReadAndValidatePublicKey(path string) (string, error)

ReadAndValidatePublicKey reads and validates a public key file

func RedactStruct

func RedactStruct(struc interface{}, fields ...string) interface{}

func SendFileViaSFTP added in v0.16.0

func SendFileViaSFTP(address string, sshConfig *ssh.ClientConfig, remotePath string, content []byte) error

SendFileViaSFTP sends file content to a remote path via SFTP

func SendFileViaSFTPWithContext added in v0.16.0

func SendFileViaSFTPWithContext(ctx context.Context, address string, sshConfig *ssh.ClientConfig, remotePath string, content []byte) error

SendFileViaSFTPWithContext sends file content to a remote path via SFTP with context support

func ValidateSSHPrivateKey added in v0.16.0

func ValidateSSHPrivateKey(privKey string) error

ValidateSSHPrivateKey validates that the provided string is a valid SSH private key

func ValidateSSHPublicKey added in v0.16.0

func ValidateSSHPublicKey(pubKey string) error

ValidateSSHPublicKey validates that the provided string is a valid SSH public key

Types

type SSHConfig added in v0.16.0

type SSHConfig struct {
	// Key content (populated from files or generated)
	PublicKey  string
	PrivateKey string

	// Key file paths (for loading)
	PublicKeyPath  string
	PrivateKeyPath string

	// SSH client configuration
	Username            string
	Timeout             time.Duration
	HostKeyAllowlistDir string

	// Internal settings
	EnableSFTP bool
}

SSHConfig holds the SSH configuration for connecting to pod VM

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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