deploy

package
v0.0.0-...-e8be5e5 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package deploy provides deployment utilities for gorp framework. Provides lightweight SSH command execution helper for deploy workflows. Hides session lifecycle management, returns merged stdout/stderr output.

部署包提供 gorp 框架的部署工具能力。 为部署流程提供轻量级 SSH 命令执行 helper。 把 session 生命周期管理隐藏在一个小工具函数后面。

Package deploy provides deployment utilities for gorp framework. This file provides recursive directory upload support for deploy workflows. Mirrors local directory structures onto remote Unix-like paths through SFTP.

部署包提供 gorp 框架的部署工具能力。 本文件为部署流程提供递归目录上传能力。 通过 SFTP 把本地目录结构镜像到远端 Unix 风格路径。

Package deploy provides deployment utilities for gorp framework. This file provides legacy direct SSH dial helper for older deploy flows. Supports key-based SSH connection setup with known_hosts verification.

部署包提供 gorp 框架的部署工具能力。 本文件为旧部署流程提供直接 SSH 连接 helper。 支持基于私钥和 known_hosts 校验的 SSH 建连。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DialSSH

func DialSSH(h SSHHost, timeout time.Duration) (*ssh.Client, error)

DialSSH dials one SSH host with key-based authentication.

DialSSH 使用私钥认证连接一个 SSH 主机。

func RunRemote

func RunRemote(client *ssh.Client, cmd string) (string, error)

RunRemote runs one shell command on the remote host and returns the merged output.

RunRemote 在远端机器上执行一条 shell 命令,并返回合并输出。

中文说明: - 每次调用都会新建一个 ssh session,用完即关。 - 返回结果为 stdout/stderr 合并输出,便于上层直接记录部署日志。

func UploadDir

func UploadDir(client *ssh.Client, localDir, remoteDir string) error

UploadDir recursively uploads one local directory to the remote directory.

UploadDir 递归把本地目录上传到远端目录。

中文说明: - 它会遍历 localDir 下全部子目录和文件,并在远端按相对路径重建目录树。 - 远端路径统一按 Unix 风格处理,避免受到本地 Windows 分隔符影响。 - 当前实现适合 deploy 场景下的中小规模目录覆盖上传。

Types

type SSHConfig

type SSHConfig struct {
	TimeoutSec int                `mapstructure:"timeout_sec"`
	Hosts      map[string]SSHHost `mapstructure:"hosts"`
}

SSHConfig is the legacy SSH config model used by deploy helpers.

SSHConfig 是 deploy 旧路径使用的 SSH 配置结构。

中文说明: - 新代码应优先使用 framework/provider/ssh 中的配置结构和服务。 - 这里仅用于兼容旧调用路径。

type SSHHost

type SSHHost struct {
	Host       string `mapstructure:"host"`
	Port       int    `mapstructure:"port"`
	Username   string `mapstructure:"username"`
	KeyPath    string `mapstructure:"key_path"`
	KnownHosts string `mapstructure:"known_hosts"`
}

SSHHost describes one SSH host entry.

SSHHost 描述一条 SSH 主机配置。

Jump to

Keyboard shortcuts

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