provider

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionType

type ActionType string

ActionType represents what to do with a file during sync

const (
	ActionDownload ActionType = "download"
	ActionDelete   ActionType = "delete"
	ActionSkip     ActionType = "skip"
	ActionUpdate   ActionType = "update"
)

type FailedFile

type FailedFile struct {
	Path     string
	URL      string
	Error    string
	Attempts int
}

FailedFile records a file that failed all retries

type NameSetter

type NameSetter interface {
	SetName(name string)
}

NameSetter is an optional interface that providers can implement to allow their name to be overridden with the user-chosen config name.

type Provider

type Provider interface {
	// Name returns the provider identifier (e.g., "epel", "ocp-binaries")
	Name() string

	// Type returns the provider content type (e.g., "rpm_repo", "binary")
	Type() string

	// Configure loads provider-specific settings from the unified config
	Configure(cfg ProviderConfig) error

	// Plan compares upstream manifest against local state, returns
	// a list of actions (download, delete, skip) without executing them
	Plan(ctx context.Context) (*SyncPlan, error)

	// Sync executes the plan — downloads, validates, retries
	Sync(ctx context.Context, plan *SyncPlan, opts SyncOptions) (*SyncReport, error)

	// Validate checks integrity of all local content against manifests
	Validate(ctx context.Context) (*ValidationReport, error)
}

Provider is the core interface that all content types implement

type ProviderConfig

type ProviderConfig = config.ProviderConfig

ProviderConfig is an alias for config.ProviderConfig to avoid import cycles Both packages define the same underlying type: map[string]interface{}

type Registry

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

Registry holds all registered providers

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new provider registry

func (*Registry) All

func (r *Registry) All() map[string]Provider

All returns all registered providers

func (*Registry) Get

func (r *Registry) Get(name string) (Provider, bool)

Get returns a provider by name

func (*Registry) Names

func (r *Registry) Names() []string

Names returns all registered provider names

func (*Registry) Register

func (r *Registry) Register(p Provider)

Register adds a provider to the registry using its Name().

func (*Registry) RegisterAs

func (r *Registry) RegisterAs(name string, p Provider)

RegisterAs adds a provider under an explicit name, overriding p.Name(). Use this when the user-chosen config name differs from the provider's built-in type name (e.g. config name "epel-10" vs provider name "epel"). If the provider implements NameSetter, its internal name is also updated so that logs and reports use the config name consistently.

func (*Registry) Remove

func (r *Registry) Remove(name string)

Remove deletes a provider from the registry by name.

type SyncAction

type SyncAction struct {
	Path      string // relative path within provider output dir (used as DB key)
	LocalPath string // absolute filesystem path for downloads
	Action    ActionType
	Size      int64
	Checksum  string            // expected SHA256
	Reason    string            // human-readable reason (e.g. "new file", "checksum mismatch")
	URL       string            // download URL (for download/update actions)
	Headers   map[string]string // optional HTTP headers required for URL fetch (e.g. Authorization)
}

SyncAction represents a single file operation in a sync plan

type SyncOptions

type SyncOptions struct {
	DryRun     bool
	Force      bool // re-download everything regardless of checksum
	MaxWorkers int
	RetryCount int
}

SyncOptions controls how Sync() executes

type SyncPlan

type SyncPlan struct {
	Provider   string
	Actions    []SyncAction
	TotalSize  int64 // bytes to download
	TotalFiles int
	Timestamp  time.Time
}

SyncPlan is the output of Plan() — what will change without executing

type SyncReport

type SyncReport struct {
	Provider         string
	StartTime        time.Time
	EndTime          time.Time
	Downloaded       int
	Deleted          int
	Skipped          int
	Failed           []FailedFile
	BytesTransferred int64
}

SyncReport is the result of Sync()

type ValidationProgressFn

type ValidationProgressFn func(checked, total int, path string, valid bool)

ValidationProgressFn is called during validation for each file checked. checked is the count so far, total is the expected total, path is the current file, valid indicates whether it passed validation.

type ValidationProgressSetter

type ValidationProgressSetter interface {
	SetValidationProgress(fn ValidationProgressFn)
}

ValidationProgressSetter is an optional interface that providers can implement to report per-file progress during validation.

type ValidationReport

type ValidationReport struct {
	Provider     string
	TotalFiles   int
	ValidFiles   int
	InvalidFiles []ValidationResult
	Timestamp    time.Time
}

ValidationReport is the result of Validate()

type ValidationResult

type ValidationResult struct {
	Path      string
	LocalPath string // absolute filesystem path
	Expected  string
	Actual    string
	Valid     bool
	Size      int64
	URL       string // download URL for retry if invalid
}

ValidationResult represents one file's validation outcome

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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