release

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBinaryPath

func GetBinaryPath() string

GetBinaryPath returns the path to the miren binary

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

func (a Artifact) GetChecksumURL() string

GetChecksumURL returns the checksum URL for this artifact

func (Artifact) GetDownloadURL

func (a Artifact) GetDownloadURL() string

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

type DownloadedArtifact struct {
	Artifact Artifact
	Path     string
	Checksum string
	Size     int64
}

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

type HealthVerifier interface {
	VerifyHealth(ctx context.Context, timeout time.Duration) error
}

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

func (m *Manager) GetLatestVersion(ctx context.Context, artifactType ArtifactType) (string, error)

GetLatestVersion returns the latest available version

func (*Manager) Rollback

func (m *Manager) Rollback(ctx context.Context) error

Rollback rolls back to the previous version

func (*Manager) UpgradeArtifact

func (m *Manager) UpgradeArtifact(ctx context.Context, artifact Artifact) error

UpgradeArtifact performs a complete upgrade operation

func (*Manager) UpgradeServer

func (m *Manager) UpgradeServer(ctx context.Context, artifact Artifact) error

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

func (m *Manager) WithInstaller(i Installer) *Manager

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

func ParseMetadata(data []byte) (*Metadata, error)

ParseMetadata parses JSON metadata

func (*Metadata) FindArtifact

func (m *Metadata) FindArtifact(name string) (*ArtifactInfo, bool)

FindArtifact finds an artifact by name

func (*Metadata) GetArtifactChecksum

func (m *Metadata) GetArtifactChecksum(name string) (string, bool)

GetArtifactChecksum returns the SHA256 checksum for an artifact

func (*Metadata) GetVersionString

func (m *Metadata) GetVersionString() string

GetVersionString returns the version string for display

func (*Metadata) HasArtifact

func (m *Metadata) HasArtifact(name string) bool

HasArtifact checks if an artifact exists in the metadata

func (*Metadata) ToJSON

func (m *Metadata) ToJSON() ([]byte, error)

ToJSON converts metadata to JSON

type NoOpHealthVerifier

type NoOpHealthVerifier struct{}

NoOpHealthVerifier is a health verifier that always succeeds (for testing)

func (*NoOpHealthVerifier) VerifyHealth

func (n *NoOpHealthVerifier) VerifyHealth(ctx context.Context, timeout time.Duration) error

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) Close

func (p *ProgressWriter) Close() error

Close prints final status

func (*ProgressWriter) SetTotal

func (p *ProgressWriter) SetTotal(total int64)

SetTotal sets the total expected bytes

func (*ProgressWriter) Write

func (p *ProgressWriter) Write(data []byte) (int, error)

Write implements io.Writer and tracks progress

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

func ParseSemVer(version string) (*SemVer, error)

ParseSemVer parses a semantic version string Examples: "v1.2.3", "v0.1.0-test.1", "1.0.0-rc.1"

func (*SemVer) IsNewer

func (s *SemVer) IsNewer(other *SemVer) bool

IsNewer returns true if this semver is newer than other

func (*SemVer) IsPrerelease

func (s *SemVer) IsPrerelease() bool

IsPrerelease returns true if this is a prerelease version

func (*SemVer) String

func (s *SemVer) String() string

String returns the string representation

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

Jump to

Keyboard shortcuts

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