Documentation
¶
Index ¶
- func GetBinaryPath() string
- func IsServerRunning() bool
- type Artifact
- type ArtifactInfo
- type ArtifactType
- type DownloadOptions
- type DownloadedArtifact
- type Downloader
- type HealthCheckOptions
- type HealthVerifier
- type InstallOptions
- type Installer
- type Manager
- func (m *Manager) CheckForUpdate(ctx context.Context, artifactType ArtifactType) (bool, string, error)
- func (m *Manager) GetCurrentVersion(ctx context.Context) (VersionInfo, error)
- func (m *Manager) GetLatestVersion(ctx context.Context, artifactType ArtifactType) (string, error)
- func (m *Manager) Rollback(ctx context.Context) error
- func (m *Manager) UpgradeArtifact(ctx context.Context, artifact Artifact) error
- func (m *Manager) UpgradeServer(ctx context.Context, artifact Artifact) error
- func (m *Manager) WithDownloader(d Downloader) *Manager
- func (m *Manager) WithHealthVerifier(v HealthVerifier) *Manager
- func (m *Manager) WithInstaller(i Installer) *Manager
- type ManagerOptions
- type Metadata
- type NoOpHealthVerifier
- type ProgressWriter
- type SemVer
- type VersionInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsServerRunning ¶
func IsServerRunning() bool
IsServerRunning checks if the miren server is currently running as a systemd service
Types ¶
type Artifact ¶
type Artifact struct {
Type ArtifactType
Version string // Branch name (e.g., "main") or version tag
Arch string
Platform string
}
Artifact represents a downloadable Miren component
func NewArtifact ¶
func NewArtifact(artifactType ArtifactType, version string) Artifact
NewArtifact creates a new artifact descriptor with current platform defaults
func (Artifact) GetChecksumURL ¶
GetChecksumURL returns the checksum URL for this artifact
func (Artifact) GetDownloadURL ¶
GetDownloadURL returns the asset service URL for this artifact
type ArtifactInfo ¶
type ArtifactInfo struct {
Name string `json:"name"` // Artifact filename
SHA256 string `json:"sha256"` // SHA256 checksum
Size int64 `json:"size,omitempty"` // File size in bytes (optional)
Platform string `json:"platform,omitempty"` // Target platform (optional)
Arch string `json:"arch,omitempty"` // Target architecture (optional)
}
ArtifactInfo contains information about a release artifact
type ArtifactType ¶
type ArtifactType string
ArtifactType represents the type of release artifact
const ( // ArtifactTypeBinary contains just the miren binary (.tar.gz) ArtifactTypeBinary ArtifactType = "binary" // ArtifactTypeBase contains miren plus supporting binaries (.tar.gz, Linux only) ArtifactTypeBase ArtifactType = "base" // ArtifactTypeRelease is deprecated, use ArtifactTypeBase ArtifactTypeRelease ArtifactType = "release" )
type DownloadOptions ¶
type DownloadOptions struct {
// TargetDir is where to download the artifact
TargetDir string
// ProgressWriter receives progress updates (optional)
ProgressWriter io.Writer
// SkipChecksum skips checksum verification (not recommended)
SkipChecksum bool
// ExpectedChecksum allows providing a known checksum from metadata
ExpectedChecksum string
}
DownloadOptions contains options for downloading artifacts
type DownloadedArtifact ¶
DownloadedArtifact represents a successfully downloaded artifact
type Downloader ¶
type Downloader interface {
Download(ctx context.Context, artifact Artifact, opts DownloadOptions) (*DownloadedArtifact, error)
GetLatestVersion(ctx context.Context, artifactType ArtifactType) (string, error)
GetVersionMetadata(ctx context.Context, version string) (*Metadata, error)
}
Downloader handles artifact downloads from the asset service
func NewDownloader ¶
func NewDownloader() Downloader
NewDownloader creates a new asset service downloader
type HealthCheckOptions ¶
type HealthCheckOptions struct {
// ServiceName is the systemd service name
ServiceName string
// HealthEndpoint is the HTTP health check endpoint
HealthEndpoint string
// MaxRetries is the maximum number of health check retries
MaxRetries int
// RetryDelay is the delay between retries
RetryDelay time.Duration
}
HealthCheckOptions contains options for health verification
func DefaultHealthCheckOptions ¶
func DefaultHealthCheckOptions() HealthCheckOptions
DefaultHealthCheckOptions returns default health check options
type HealthVerifier ¶
HealthVerifier checks service health after upgrade
func NewHealthVerifier ¶
func NewHealthVerifier(opts HealthCheckOptions) HealthVerifier
NewHealthVerifier creates a new health verifier
type InstallOptions ¶
type InstallOptions struct {
// InstallPath is where to install the binary
InstallPath string
// BackupSuffix is the suffix for backup files
BackupSuffix string
}
InstallOptions contains options for installation
func DefaultInstallOptions ¶
func DefaultInstallOptions() InstallOptions
DefaultInstallOptions returns default installation options
type Installer ¶
type Installer interface {
Install(ctx context.Context, downloaded *DownloadedArtifact) error
Backup(ctx context.Context) error
Rollback(ctx context.Context) error
GetCurrentVersion(ctx context.Context) (VersionInfo, error)
HasBackup() bool
}
Installer manages the installation and rollback of artifacts
func NewInstaller ¶
func NewInstaller(opts InstallOptions) Installer
NewInstaller creates a new binary installer
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager orchestrates the upgrade process
func NewManager ¶
func NewManager(opts ManagerOptions) *Manager
NewManager creates a new upgrade manager
func (*Manager) CheckForUpdate ¶
func (m *Manager) CheckForUpdate(ctx context.Context, artifactType ArtifactType) (bool, string, error)
CheckForUpdate checks if an update is available
func (*Manager) GetCurrentVersion ¶
func (m *Manager) GetCurrentVersion(ctx context.Context) (VersionInfo, error)
GetCurrentVersion returns the current installed version
func (*Manager) GetLatestVersion ¶
GetLatestVersion returns the latest available version
func (*Manager) UpgradeArtifact ¶
UpgradeArtifact performs a complete upgrade operation
func (*Manager) UpgradeServer ¶
UpgradeServer upgrades the server binary and restarts the service
func (*Manager) WithDownloader ¶
func (m *Manager) WithDownloader(d Downloader) *Manager
WithDownloader sets a custom downloader
func (*Manager) WithHealthVerifier ¶
func (m *Manager) WithHealthVerifier(v HealthVerifier) *Manager
WithHealthVerifier sets a custom health verifier
func (*Manager) WithInstaller ¶
WithInstaller sets a custom installer
type ManagerOptions ¶
type ManagerOptions struct {
// InstallPath is where to install binaries
InstallPath string
// TempDir is where to store temporary files
TempDir string
// ServiceName is the systemd service name
ServiceName string
// HealthTimeout is the timeout for health checks
HealthTimeout time.Duration
// SkipHealthCheck skips post-upgrade health verification
SkipHealthCheck bool
// AutoRollback enables automatic rollback on health check failure
AutoRollback bool
}
ManagerOptions contains options for the upgrade manager
func DefaultManagerOptions ¶
func DefaultManagerOptions() ManagerOptions
DefaultManagerOptions returns default manager options
type Metadata ¶
type Metadata struct {
Version string `json:"version"` // Version string (e.g., "main:abc123")
Commit string `json:"commit"` // Full commit SHA
Branch string `json:"branch"` // Branch name
BuildDate time.Time `json:"build_date"` // Build timestamp
Artifacts []ArtifactInfo `json:"artifacts"` // List of available artifacts
}
Metadata contains version metadata for a release
func ParseMetadata ¶
ParseMetadata parses JSON metadata
func (*Metadata) FindArtifact ¶
func (m *Metadata) FindArtifact(name string) (*ArtifactInfo, bool)
FindArtifact finds an artifact by name
func (*Metadata) GetArtifactChecksum ¶
GetArtifactChecksum returns the SHA256 checksum for an artifact
func (*Metadata) GetVersionString ¶
GetVersionString returns the version string for display
func (*Metadata) HasArtifact ¶
HasArtifact checks if an artifact exists in the metadata
type NoOpHealthVerifier ¶
type NoOpHealthVerifier struct{}
NoOpHealthVerifier is a health verifier that always succeeds (for testing)
func (*NoOpHealthVerifier) VerifyHealth ¶
VerifyHealth always returns success
type ProgressWriter ¶
type ProgressWriter struct {
// contains filtered or unexported fields
}
ProgressWriter writes download progress to an output stream
func NewProgressWriter ¶
func NewProgressWriter(w io.Writer) *ProgressWriter
NewProgressWriter creates a new progress writer
func (*ProgressWriter) SetTotal ¶
func (p *ProgressWriter) SetTotal(total int64)
SetTotal sets the total expected bytes
type SemVer ¶
type SemVer struct {
Major int
Minor int
Patch int
Prerelease string // e.g., "test.1", "rc.1"
Original string // Original version string
}
SemVer represents a semantic version
func ParseSemVer ¶
ParseSemVer parses a semantic version string Examples: "v1.2.3", "v0.1.0-test.1", "1.0.0-rc.1"
func (*SemVer) IsPrerelease ¶
IsPrerelease returns true if this is a prerelease version
type VersionInfo ¶
type VersionInfo struct {
Version string `json:"version"`
Commit string `json:"commit"`
BuildDate time.Time `json:"build_date"`
}
VersionInfo contains version information for a binary
func GetCurrentVersion ¶
func GetCurrentVersion(binaryPath string) (VersionInfo, error)
GetCurrentVersion gets the version info of the currently installed binary
func (VersionInfo) IsNewer ¶
func (v VersionInfo) IsNewer(other VersionInfo) bool
IsNewer returns true if this version is newer than the other