Help us shape the future of Go! Take the 2026 Go Developer Survey

processor

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplyStage

type ApplyStage interface {
	Stage
	Apply(ctx context.Context, p Processor) error
}

ApplyStage applies modifications

type BaseProcessor

type BaseProcessor struct {
	// Core fields
	FilePath    string
	PackageName string
	Logger      *slog.Logger

	// Configuration
	Config       *melange.Configuration
	OriginalYAML []byte
	CurrentYAML  []byte

	// Version state
	CurrentVersion string
	LatestVersion  string
	VersionChanged bool
	OldVersion     string
	NewVersion     string

	// Epoch state
	CurrentEpoch int64
	NewEpoch     int64
	EpochChanged bool
	OldEpoch     int64

	// Change tracking
	Changes  []Change
	Messages []string
	Errors   []error

	// Options
	Options ProcessorOptions

	// Extensibility
	Context map[string]any
}

BaseProcessor provides a base implementation that can be embedded

func NewBaseProcessor

func NewBaseProcessor(filePath, packageName, currentVersion string, currentEpoch int64) *BaseProcessor

NewBaseProcessor creates a new base processor

func (*BaseProcessor) AddChange

func (bp *BaseProcessor) AddChange(change Change)

func (*BaseProcessor) AddError

func (bp *BaseProcessor) AddError(err error)

func (*BaseProcessor) AddMessage

func (bp *BaseProcessor) AddMessage(message string)

func (*BaseProcessor) GetChanges

func (bp *BaseProcessor) GetChanges() []Change

func (*BaseProcessor) GetConfig

func (bp *BaseProcessor) GetConfig() *melange.Configuration

func (*BaseProcessor) GetContext

func (bp *BaseProcessor) GetContext(key string) any

func (*BaseProcessor) GetCurrentEpoch

func (bp *BaseProcessor) GetCurrentEpoch() int64

func (*BaseProcessor) GetCurrentVersion

func (bp *BaseProcessor) GetCurrentVersion() string

func (*BaseProcessor) GetCurrentYAML

func (bp *BaseProcessor) GetCurrentYAML() []byte

func (*BaseProcessor) GetErrors

func (bp *BaseProcessor) GetErrors() []error

func (*BaseProcessor) GetFilePath

func (bp *BaseProcessor) GetFilePath() string

Implementation of Processor interface

func (*BaseProcessor) GetLatestVersion

func (bp *BaseProcessor) GetLatestVersion() string

func (*BaseProcessor) GetLogger

func (bp *BaseProcessor) GetLogger() *slog.Logger

func (*BaseProcessor) GetMessages

func (bp *BaseProcessor) GetMessages() []string

func (*BaseProcessor) GetNewEpoch

func (bp *BaseProcessor) GetNewEpoch() int64

func (*BaseProcessor) GetOptions

func (bp *BaseProcessor) GetOptions() ProcessorOptions

func (*BaseProcessor) GetOriginalYAML

func (bp *BaseProcessor) GetOriginalYAML() []byte

func (*BaseProcessor) GetPackageName

func (bp *BaseProcessor) GetPackageName() string

func (*BaseProcessor) HasChanges

func (bp *BaseProcessor) HasChanges() bool

func (*BaseProcessor) HasFileChanges

func (bp *BaseProcessor) HasFileChanges() bool

func (*BaseProcessor) IsEpochChanged

func (bp *BaseProcessor) IsEpochChanged() bool

func (*BaseProcessor) IsVersionChanged

func (bp *BaseProcessor) IsVersionChanged() bool

func (*BaseProcessor) SetContext

func (bp *BaseProcessor) SetContext(key string, value any)

func (*BaseProcessor) SetCurrentYAML

func (bp *BaseProcessor) SetCurrentYAML(yaml []byte)

func (*BaseProcessor) SetEpochUpdate

func (bp *BaseProcessor) SetEpochUpdate(old, new int64)

func (*BaseProcessor) SetOptions

func (bp *BaseProcessor) SetOptions(opts ProcessorOptions)

func (*BaseProcessor) SetVersionUpdate

func (bp *BaseProcessor) SetVersionUpdate(old, new string)

type BaseStage

type BaseStage struct {
	StageName        string
	StageDescription string
}

BaseStage provides common functionality for stages

func (*BaseStage) Description

func (bs *BaseStage) Description() string

func (*BaseStage) Name

func (bs *BaseStage) Name() string

func (*BaseStage) ShouldRun

func (bs *BaseStage) ShouldRun(ctx context.Context, p Processor) (bool, error)

DefaultShouldRun implementation - always run unless overridden

type Change

type Change struct {
	Type        string `json:"type"`        // "version", "epoch", "pipeline", "security"
	Field       string `json:"field"`       // specific field changed
	OldValue    string `json:"old_value"`   // previous value
	NewValue    string `json:"new_value"`   // new value
	Description string `json:"description"` // human-readable description
	Reason      string `json:"reason"`      // why the change was made
}

Change represents a modification made to the package

type CheckStage

type CheckStage interface {
	Stage
	Check(ctx context.Context, p Processor) error
}

CheckStage performs checks without modifications

type ExecutableStage

type ExecutableStage interface {
	Stage
	Execute(ctx context.Context, p Processor) error
}

ExecutableStage is a stage that can be executed (generic execution)

type Pipeline

type Pipeline struct {
	Name     string
	Stages   []Stage
	Options  PipelineOptions
	Registry *StageRegistry
}

Pipeline represents a sequence of stages that operate on a processor

func NewPipeline

func NewPipeline(name string) *Pipeline

NewPipeline creates a new pipeline

func (*Pipeline) AddStage

func (p *Pipeline) AddStage(stage Stage)

AddStage adds a stage to the pipeline

func (*Pipeline) AddStages

func (p *Pipeline) AddStages(stages ...Stage)

AddStages adds multiple stages to the pipeline

func (*Pipeline) Execute

func (p *Pipeline) Execute(ctx context.Context, processor Processor) error

Execute runs the pipeline on the given processor

func (*Pipeline) SetOptions

func (p *Pipeline) SetOptions(opts PipelineOptions)

SetOptions configures pipeline execution options

type PipelineOptions

type PipelineOptions struct {
	StopOnError       bool // Stop execution if a stage fails
	SkipValidation    bool // Skip validation stages
	ParallelExecution bool // Enable parallel execution of independent stages (future enhancement)
}

PipelineOptions configures pipeline behavior

type Processor

type Processor interface {
	// Identity
	GetFilePath() string
	GetPackageName() string
	GetLogger() *slog.Logger

	// Configuration
	GetConfig() *melange.Configuration
	GetOriginalYAML() []byte
	GetCurrentYAML() []byte
	SetCurrentYAML([]byte)

	// Version tracking
	GetCurrentVersion() string
	GetLatestVersion() string
	SetVersionUpdate(old, new string)
	IsVersionChanged() bool

	// Epoch tracking
	GetCurrentEpoch() int64
	GetNewEpoch() int64
	SetEpochUpdate(old, new int64)
	IsEpochChanged() bool

	// Change tracking
	AddChange(Change)
	GetChanges() []Change
	HasChanges() bool
	HasFileChanges() bool

	// Messaging
	AddMessage(string)
	AddError(error)
	GetMessages() []string
	GetErrors() []error

	// Options
	GetOptions() ProcessorOptions
	SetOptions(ProcessorOptions)

	// Context for custom data
	GetContext(key string) any
	SetContext(key string, value any)
}

Processor defines the core interface for all package processors

type ProcessorOptions

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

ProcessorOptions contains configuration for package processing

type Stage

type Stage interface {
	Name() string
	Description() string

	// Conditional execution - stages can decide if they should run
	ShouldRun(ctx context.Context, p Processor) (bool, error)
}

Stage represents a single processing step

type StageRegistry

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

StageRegistry manages available stages and provides stage construction

func NewStageRegistry

func NewStageRegistry() *StageRegistry

NewStageRegistry creates a new stage registry

func (*StageRegistry) Create

func (r *StageRegistry) Create(name string) (Stage, error)

Create instantiates a stage by name

func (*StageRegistry) ListStages

func (r *StageRegistry) ListStages() []string

ListStages returns all registered stage names

func (*StageRegistry) Register

func (r *StageRegistry) Register(name string, constructor func() Stage)

Register adds a stage constructor to the registry

type ValidatingStage

type ValidatingStage interface {
	Stage
	Validate(ctx context.Context, p Processor) error
}

ValidatingStage can validate its preconditions before execution

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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