updater

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 24 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPipeline

func NewPipeline(orchestrator *UpdateOrchestrator) *processor.Pipeline

NewPipeline creates the updater pipeline using the shared processor architecture

Types

type ApplyResult

type ApplyResult struct {
	PackageName    string   `json:"package_name" yaml:"package_name"`
	FilePath       string   `json:"file_path" yaml:"file_path"`
	OldVersion     string   `json:"old_version" yaml:"old_version"`
	NewVersion     string   `json:"new_version" yaml:"new_version"`
	OldEpoch       int64    `json:"old_epoch" yaml:"old_epoch"`
	NewEpoch       int64    `json:"new_epoch" yaml:"new_epoch"`
	UpdatesApplied []string `json:"updates_applied" yaml:"updates_applied"`
	SharedUpdates  []string `json:"shared_updates,omitempty" yaml:"shared_updates,omitempty"`
	BackupCreated  string   `json:"backup_created,omitempty" yaml:"backup_created,omitempty"`
	FileWasWritten bool     `json:"file_was_written" yaml:"file_was_written"`
	IsManual       bool     `json:"is_manual" yaml:"is_manual"`
	Error          string   `json:"error,omitempty" yaml:"error,omitempty"`
}

ApplyResult represents the result of an update application (used by CLI)

type ChecksumHelper

type ChecksumHelper struct {
	// contains filtered or unexported fields
}

ChecksumHelper handles SHA256 calculation for URLs

func NewChecksumHelperWithClient

func NewChecksumHelperWithClient(client *http.Client) *ChecksumHelper

NewChecksumHelperWithClient creates a checksum helper with custom HTTP client

func (*ChecksumHelper) CalculateSHA256FromURL

func (ch *ChecksumHelper) CalculateSHA256FromURL(ctx context.Context, url string) (string, error)

CalculateSHA256FromURL downloads content from a URL and calculates its SHA256

type PipelineChange

type PipelineChange struct {
	Type        string `json:"type" yaml:"type"`               // "insert", "update", "remove"
	Index       int    `json:"index" yaml:"index"`             // pipeline index
	Field       string `json:"field" yaml:"field"`             // specific field changed
	OldValue    string `json:"old_value" yaml:"old_value"`     // previous value
	NewValue    string `json:"new_value" yaml:"new_value"`     // new value
	Description string `json:"description" yaml:"description"` // human-readable description
	Reason      string `json:"reason" yaml:"reason"`           // why the change was made
}

PipelineChange represents a modification made to a pipeline

type PipelineProcessor

type PipelineProcessor struct {
	processor.BaseStage
	// contains filtered or unexported fields
}

PipelineProcessor implements ApplyStage for pipeline modifications

func NewPipelineProcessor

func NewPipelineProcessor(orchestrator *UpdateOrchestrator) *PipelineProcessor

func (*PipelineProcessor) Apply

func (*PipelineProcessor) ShouldRun

func (pp *PipelineProcessor) ShouldRun(ctx context.Context, p processor.Processor) (bool, error)

type ProcessorOptions

type ProcessorOptions struct {
	DryRun       bool   `json:"dry_run" yaml:"dry_run"`
	Force        bool   `json:"force" yaml:"force"`
	BackupSuffix string `json:"backup_suffix" yaml:"backup_suffix"`
	TempDir      string `json:"temp_dir" yaml:"temp_dir"`
}

ProcessorOptions configures processor behavior

type UpdateOrchestrator

type UpdateOrchestrator struct {
	// contains filtered or unexported fields
}

UpdateOrchestrator manages the package update pipeline using a stage-based architecture It replaces the previous Updater with a cleaner separation of concerns and proper logging context throughout the entire process.

func NewOrchestratorWithTimeout

func NewOrchestratorWithTimeout(httpTimeout time.Duration) *UpdateOrchestrator

NewOrchestratorWithTimeout creates a new update orchestrator with a custom HTTP timeout

func (*UpdateOrchestrator) GetServiceClients

func (o *UpdateOrchestrator) GetServiceClients() (anitya *anitya.Client, github *githubClient.Client, git *git.Client, http *http.Client)

GetServiceClients returns the service clients for use by stages

func (*UpdateOrchestrator) GetVersionComponents

func (o *UpdateOrchestrator) GetVersionComponents() (*VersionFilter, *VersionComparator)

GetVersionComponents returns the version filtering and comparison components

func (*UpdateOrchestrator) ProcessMultipleApplies

func (o *UpdateOrchestrator) ProcessMultipleApplies(ctx context.Context, filePaths []string, options ProcessorOptions) ([]*UpdaterProcessor, error)

ProcessMultipleApplies processes multiple packages for updates

func (*UpdateOrchestrator) ProcessMultipleChecks

func (o *UpdateOrchestrator) ProcessMultipleChecks(ctx context.Context, filePaths []string) ([]*UpdaterProcessor, error)

ProcessMultipleChecks processes multiple packages for update checking

func (*UpdateOrchestrator) ProcessPackageApply

func (o *UpdateOrchestrator) ProcessPackageApply(ctx context.Context, filePath string, options ProcessorOptions) (*UpdaterProcessor, error)

ProcessPackageApply runs the full pipeline (check + apply) for a package This includes checking for updates and applying them if found

func (*UpdateOrchestrator) ProcessPackageCheck

func (o *UpdateOrchestrator) ProcessPackageCheck(ctx context.Context, filePath string) (*UpdaterProcessor, error)

ProcessPackageCheck runs only the check pipeline for a package This loads the configuration and determines if updates are available

type UpdateResult

type UpdateResult struct {
	PackageName    string `json:"package_name" yaml:"package_name"`
	FilePath       string `json:"file_path" yaml:"file_path"`
	CurrentVersion string `json:"current_version" yaml:"current_version"`
	LatestVersion  string `json:"latest_version" yaml:"latest_version"`
	HasUpdate      bool   `json:"has_update" yaml:"has_update"`
	UpdateSource   string `json:"update_source" yaml:"update_source"`
	IsManual       bool   `json:"is_manual" yaml:"is_manual"`
	Error          string `json:"error,omitempty" yaml:"error,omitempty"`
}

UpdateResult represents the result of an update check (used by CLI)

type UpdaterProcessor

type UpdaterProcessor struct {
	processor.BaseProcessor

	// Update-specific state
	UpdateAvailable bool             `json:"update_available"`
	CurrentVersion  string           `json:"current_version"`
	LatestVersion   string           `json:"latest_version"`
	UpdateSource    string           `json:"update_source"`
	IsManual        bool             `json:"is_manual"`
	VersionChanged  bool             `json:"version_changed"`
	PipelineChanges []PipelineChange `json:"pipeline_changes"`
}

UpdaterProcessor extends BaseProcessor for updater-specific functionality

func NewUpdaterProcessor

func NewUpdaterProcessor(filePath, packageName, currentVersion string, currentEpoch int64) *UpdaterProcessor

NewUpdaterProcessor creates a new updater processor extending BaseProcessor

func (*UpdaterProcessor) AddPipelineChange

func (p *UpdaterProcessor) AddPipelineChange(change PipelineChange)

AddPipelineChange records a pipeline modification

func (*UpdaterProcessor) GetCurrentVersion

func (p *UpdaterProcessor) GetCurrentVersion() string

GetCurrentVersion returns the current version (override to use local field)

func (*UpdaterProcessor) GetLatestVersion

func (p *UpdaterProcessor) GetLatestVersion() string

GetLatestVersion returns the latest version

func (*UpdaterProcessor) GetNewEpoch

func (p *UpdaterProcessor) GetNewEpoch() int64

GetNewEpoch returns the new epoch (delegate to base processor)

func (*UpdaterProcessor) HasChanges

func (p *UpdaterProcessor) HasChanges() bool

HasChanges returns true if any changes were made to the package

func (*UpdaterProcessor) IsVersionChanged

func (p *UpdaterProcessor) IsVersionChanged() bool

IsVersionChanged returns true if version was changed

func (*UpdaterProcessor) SetUpdateResult

func (p *UpdaterProcessor) SetUpdateResult(hasUpdate bool, latestVersion, source string, isManual bool)

SetUpdateResult updates the processor with check results

func (*UpdaterProcessor) SetVersionUpdate

func (p *UpdaterProcessor) SetVersionUpdate(old, new string)

SetVersionUpdate marks that the version was updated (implements Processor interface)

func (*UpdaterProcessor) Summary

func (p *UpdaterProcessor) Summary() string

Summary returns a brief summary of the processing results

type VersionApplier

type VersionApplier struct {
	processor.BaseStage
}

VersionApplier implements ApplyStage for version updates

func NewVersionApplier

func NewVersionApplier() *VersionApplier

func (*VersionApplier) Apply

func (*VersionApplier) ShouldRun

func (va *VersionApplier) ShouldRun(ctx context.Context, p processor.Processor) (bool, error)

type VersionChecker

type VersionChecker struct {
	processor.BaseStage
	// contains filtered or unexported fields
}

VersionChecker implements CheckStage for the shared processor architecture

func NewVersionChecker

func NewVersionChecker(orchestrator *UpdateOrchestrator) *VersionChecker

func (*VersionChecker) Check

type VersionComparator

type VersionComparator struct {
}

VersionComparator handles version comparison logic

func NewVersionComparator

func NewVersionComparator() *VersionComparator

NewVersionComparator creates a new version comparator

func (*VersionComparator) ApplyTransform

func (vc *VersionComparator) ApplyTransform(version, match, replace string) (string, error)

ApplyTransform applies a regex-based transformation to a version string

func (*VersionComparator) Compare

func (vc *VersionComparator) Compare(v1, v2 string) (int, error)

Compare compares two versions, returning: -1 if v1 < v2

0 if v1 == v2
1 if v1 > v2

func (*VersionComparator) IsNewer

func (vc *VersionComparator) IsNewer(currentVersion, newVersion string) (bool, error)

IsNewer returns true if newVersion is newer than currentVersion

func (*VersionComparator) IsValidVersion

func (vc *VersionComparator) IsValidVersion(version string, allowPreRelease bool) bool

IsValidVersion checks if a version is valid semver and handles pre-release filtering

func (*VersionComparator) MatchesIgnorePattern

func (vc *VersionComparator) MatchesIgnorePattern(version string, patterns []string) (bool, error)

MatchesIgnorePattern checks if a version matches any of the ignore patterns

type VersionFilter

type VersionFilter struct {
	// contains filtered or unexported fields
}

VersionFilter handles version filtering logic based on update configuration

func NewVersionFilter

func NewVersionFilter() *VersionFilter

NewVersionFilter creates a new version filter

func (*VersionFilter) ProcessVersion

func (vf *VersionFilter) ProcessVersion(ctx context.Context, version string, updateConfig *melange.Update) (string, bool, error)

ProcessVersion processes a single version through all the update configuration rules, logging intermediate decisions against the logger carried on ctx (see internal/logging) so they carry the caller's file/package/stage attribution.

Jump to

Keyboard shortcuts

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