Documentation
¶
Overview ¶
Package deploy implements a lightweight continuous deployment agent. It supports two modes:
- webhook: an HTTP daemon on the server that GitHub Actions triggers via POST.
- ssh: generates a shell script that GitHub Actions runs via SSH on the server.
Usage:
d := deploy.New(keys, mgr, downloader, checker, files)
d.Run("deploy.yaml")
Index ¶
- func CreateDefaultConfig(path string) error
- func CreateShortcut(linkPath, targetPath, workDir string) error
- func SSHCommand(sshKey, sshUser, sshHost, script string) string
- func SSHScript(app AppConfig, downloadURL, githubPAT string) string
- type AppConfig
- type Checker
- type Config
- type ConfigUpdater
- type Deploy
- type Downloader
- type HMACValidator
- type HTTPDownloader
- type Handler
- type HealthChecker
- type HealthStatus
- type KeyManager
- type ProcessManager
- type RetryConfig
- type RollbackConfig
- type SystemKeyManager
- type UpdateRequest
- type WindowsManager
- type Wizard
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateDefaultConfig ¶ added in v0.0.3
CreateDefaultConfig creates a default config file at the given path.
func CreateShortcut ¶ added in v0.0.3
CreateShortcut creates a Windows shortcut (.lnk) at linkPath pointing to targetPath.
func SSHCommand ¶ added in v0.0.3
SSHCommand returns the ssh command string to run the generated script on a remote host. Intended for GitHub Actions step generation / documentation.
func SSHScript ¶ added in v0.0.3
SSHScript generates a shell script that a GitHub Action runs via SSH to deploy a new binary version directly on the server.
The generated script:
- Downloads the release asset from GitHub
- Stops the service (systemctl or pkill)
- Replaces the binary (with backup)
- Starts the service
- Checks health URL
Types ¶
type AppConfig ¶ added in v0.0.3
type AppConfig struct {
Name string `yaml:"name"`
Version string `yaml:"version"`
Executable string `yaml:"executable"`
Path string `yaml:"path"`
Port int `yaml:"port"`
HealthEndpoint string `yaml:"health_endpoint"`
HealthTimeout time.Duration `yaml:"health_timeout"`
StartupDelay time.Duration `yaml:"startup_delay"`
BusyRetryInterval time.Duration `yaml:"busy_retry_interval"` // default: 10s
BusyTimeout time.Duration `yaml:"busy_timeout"` // default: 5m
Rollback RollbackConfig `yaml:"rollback"`
}
AppConfig represents a single application configuration.
type Checker ¶ added in v0.0.3
type Checker struct {
// contains filtered or unexported fields
}
func NewChecker ¶ added in v0.0.3
func NewChecker() *Checker
type Config ¶ added in v0.0.3
type Config struct {
Updater ConfigUpdater `yaml:"updater"`
Apps []AppConfig `yaml:"apps"`
}
Config represents the application configuration.
type ConfigUpdater ¶ added in v0.0.3
type ConfigUpdater struct {
Port int `yaml:"port"` // default: 8080
LogLevel string `yaml:"log_level"`
LogFile string `yaml:"log_file"`
TempDir string `yaml:"temp_dir"`
Retry RetryConfig `yaml:"retry"`
}
ConfigUpdater holds updater-specific configuration.
type Deploy ¶
type Deploy struct {
Keys KeyManager
Process ProcessManager
Downloader Downloader
Checker HealthChecker
ConfigPath string
}
type Downloader ¶ added in v0.0.3
type HMACValidator ¶ added in v0.0.3
type HMACValidator struct {
// contains filtered or unexported fields
}
func NewHMACValidator ¶ added in v0.0.3
func NewHMACValidator(secret string) *HMACValidator
func (*HMACValidator) ValidateRequest ¶ added in v0.0.3
func (v *HMACValidator) ValidateRequest(payload []byte, signature string) error
type HTTPDownloader ¶ added in v0.0.3
type HTTPDownloader struct {
// contains filtered or unexported fields
}
func NewDownloader ¶ added in v0.0.3
func NewDownloader() *HTTPDownloader
func (*HTTPDownloader) Download ¶ added in v0.0.3
func (d *HTTPDownloader) Download(url, dest, token string) error
type Handler ¶ added in v0.0.3
type Handler struct {
Config *Config
ConfigPath string
Validator *HMACValidator
Downloader Downloader
Process ProcessManager
Checker HealthChecker // Use interface
Keys KeyManager
}
func (*Handler) HandleUpdate ¶ added in v0.0.3
func (h *Handler) HandleUpdate(w http.ResponseWriter, r *http.Request)
type HealthChecker ¶ added in v0.0.3
type HealthChecker interface {
Check(url string) (*HealthStatus, error)
}
type HealthStatus ¶ added in v0.0.3
func ParseHealthResponse ¶ added in v0.0.3
func ParseHealthResponse(r io.Reader) (*HealthStatus, error)
type KeyManager ¶ added in v0.0.3
type KeyManager interface {
Get(service, user string) (string, error)
Set(service, user, password string) error
}
KeyManager defines the interface for managing secrets.
type ProcessManager ¶ added in v0.0.3
ProcessManager defines the interface for managing processes.
func NewProcessManager ¶ added in v0.0.3
func NewProcessManager() ProcessManager
type RetryConfig ¶ added in v0.0.3
type RetryConfig struct {
MaxAttempts int `yaml:"max_attempts"`
Delay time.Duration `yaml:"delay"`
}
RetryConfig holds retry configuration.
type RollbackConfig ¶ added in v0.0.3
type RollbackConfig struct {
Enabled bool `yaml:"enabled"`
KeepVersions int `yaml:"keep_versions"` // Only -older
AutoRollbackOnFailure bool `yaml:"auto_rollback_on_failure"`
}
RollbackConfig holds rollback configuration.
type SystemKeyManager ¶ added in v0.0.3
type SystemKeyManager struct{}
SystemKeyManager implements KeyManager using the system keyring.
func NewSystemKeyManager ¶ added in v0.0.3
func NewSystemKeyManager() *SystemKeyManager
NewSystemKeyManager creates a new SystemKeyManager.
func (*SystemKeyManager) Get ¶ added in v0.0.3
func (m *SystemKeyManager) Get(service, user string) (string, error)
func (*SystemKeyManager) Set ¶ added in v0.0.3
func (m *SystemKeyManager) Set(service, user, password string) error
type UpdateRequest ¶ added in v0.0.3
type WindowsManager ¶ added in v0.0.3
type WindowsManager struct{}
func (*WindowsManager) Start ¶ added in v0.0.3
func (m *WindowsManager) Start(exePath string) error
func (*WindowsManager) Stop ¶ added in v0.0.3
func (m *WindowsManager) Stop(exeName string) error