version

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package version provides version management functionality for LacyLights. It interfaces with the update-repos.sh script to check and update component versions.

Index

Constants

View Source
const (
	// UpdateScriptPath is the path to the update-repos.sh script on the Pi
	UpdateScriptPath = "/opt/lacylights/scripts/update-repos.sh"
	// SelfUpdateScriptPath is the path to the self-update wrapper for updating lacylights-go itself
	SelfUpdateScriptPath = "/opt/lacylights/scripts/self-update.sh"
	// RunUpdateScriptPath is the path to the secure update runner script
	// This script validates inputs before running updates, preventing command injection
	RunUpdateScriptPath = "/opt/lacylights/scripts/run-update.sh"
	// UpdateLogPath is the path to the update log file
	UpdateLogPath = "/opt/lacylights/logs/update.log"
)

Variables

This section is empty.

Functions

func ResetBuildInfoForTesting added in v0.2.12

func ResetBuildInfoForTesting()

ResetBuildInfoForTesting resets the build info to defaults for testing purposes. This function is thread-safe and can be called from concurrent tests. WARNING: This should only be called from test code.

func SetBuildInfo added in v0.2.12

func SetBuildInfo(version, gitCommit, buildTimeVal string)

SetBuildInfo sets the build information (called from main package at startup). Uses sync.Once to ensure initialization happens exactly once, and RWMutex for thread-safe access. Empty string values are ignored to preserve default values during development builds.

func SetTestInstalledRepos added in v0.2.26

func SetTestInstalledRepos(repos []string)

SetTestInstalledRepos allows tests to override which repositories are "installed". Pass nil to reset to default behavior (check actual files). This function is thread-safe and can be called from concurrent tests. WARNING: This should only be called from test code.

Types

type BuildInfo added in v0.2.12

type BuildInfo struct {
	Version   string
	GitCommit string
	BuildTime string
}

BuildInfo contains server build information for version verification

func GetBuildInfo added in v0.2.12

func GetBuildInfo() BuildInfo

GetBuildInfo returns the current build information. Thread-safe for concurrent access.

type RepositoryVersion

type RepositoryVersion struct {
	Repository      string
	Installed       string
	Latest          string
	UpdateAvailable bool
}

RepositoryVersion contains version information for a single repository

type Service

type Service struct{}

Service provides version management functionality

func NewService

func NewService() *Service

NewService creates a new version management service

func (*Service) GetAvailableVersions

func (s *Service) GetAvailableVersions(repository string) ([]string, error)

GetAvailableVersions returns available versions for a specific repository

func (*Service) GetSystemVersions

func (s *Service) GetSystemVersions() (*SystemVersionInfo, error)

GetSystemVersions returns version information for all repositories

func (*Service) IsSupported

func (s *Service) IsSupported() bool

IsSupported checks if version management is available on this system

func (*Service) UpdateAllRepositories

func (s *Service) UpdateAllRepositories() ([]*UpdateResult, error)

UpdateAllRepositories updates all repositories to their latest versions

func (*Service) UpdateRepository

func (s *Service) UpdateRepository(repository string, version *string) (*UpdateResult, error)

UpdateRepository updates a specific repository to a specific version

type SystemVersionInfo

type SystemVersionInfo struct {
	Repositories               []*RepositoryVersion
	LastChecked                string
	VersionManagementSupported bool
}

SystemVersionInfo contains version information for all repositories

type UpdateResult

type UpdateResult struct {
	Success         bool
	Repository      string
	PreviousVersion string
	NewVersion      string
	Message         string
	Error           string
}

UpdateResult contains the result of an update operation

Jump to

Keyboard shortcuts

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