utils

package
v0.0.0-...-e4490c7 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloneRepo

func CloneRepo(repoAddress, privateKey, version, targetDir string) (string, string, error)

func ConnectSFTP

func ConnectSFTP(serverAddress, username, privateKey string) (*sftp.Client, error)

ConnectSFTP 连接到SFTP服务器

func ConnectToSSHServer

func ConnectToSSHServer(serverAddress, publicKey, username string) (*ssh.Client, error)

ConnectToSSHServer 使用SSH私钥连接到SSH服务器

func ExecuteSSHCommand

func ExecuteSSHCommand(client *ssh.Client, commands ...string) (string, error)

ExecuteSSHCommand 在SSH会话中执行命令并返回输出结果

func GenerateRSAKeys

func GenerateRSAKeys() (privateKeyPEM string, publicKeySSH string, err error)

GenerateRSAKeys 生成2048位的RSA密钥对,并以OpenSSH格式返回公钥和PEM格式返回私钥

func SyncDir

func SyncDir(client *sftp.Client, localDir, remoteDir string) error

SyncDir 使用SFTP同步本地目录到远程目录

func SyncFile

func SyncFile(client *sftp.Client, localFilePath, remoteFilePath string) error

SyncFile 使用SFTP同步本地文件到远程目录

func ZipFolder

func ZipFolder(source, target string) error

ZipFolder compresses the specified folder into a zip file, maintaining the folder's structure

Types

type RepoInfo

type RepoInfo struct {
	Commit   string
	Comment  string
	Branches []string
	Tags     []string
}

func CloneRepoBranchOrCommit

func CloneRepoBranchOrCommit(repoURL, publicKey, branchOrCommit, destDir string) (RepoInfo, error)

CloneRepoBranchOrCommit 克隆指定分支或提交

Jump to

Keyboard shortcuts

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