Documentation
¶
Index ¶
- Variables
- func FetchLocalComponent(dryRunnable opctx.DryRunnable, eventListener opctx.EventListener, ...) error
- func ResolveLocalSourceIdentity(filesystem opctx.FS, specDir string) (string, error)
- type ComponentSourceProvider
- type FedoraSourcesProviderImpl
- type FetchComponentOption
- type FetchComponentOptions
- type FileSourceProvider
- type Provider
- type RPMContentsProviderImpl
- type ResolvedDistro
- type SourceIdentityProvider
- type SourceManager
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("file not handled by this provider")
ErrNotFound is returned by a FileSourceProvider when it does not handle the given file reference. The source manager tries the next registered provider on this error, eventually falling back to lookaside cache and configured origins.
Functions ¶
func FetchLocalComponent ¶
func FetchLocalComponent( dryRunnable opctx.DryRunnable, eventListener opctx.EventListener, fileSystem opctx.FS, component components.Component, destDirPath string, resolveRequiredFiles bool, ) error
FetchLocalComponent retrieves the `.spec` file and any sidecar files for the specified component from the local filesystem, placing the fetched files in the provided directory. If resolveRequiredFiles is true, files referenced by the spec's contents (e.g., patches, additional sources) will be searched for recursively in the source directory.
func ResolveLocalSourceIdentity ¶ added in v0.2.0
ResolveLocalSourceIdentity computes a SHA256 hash over all files in the given spec directory (spec file + sidecar files like patches and scripts). Files are sorted by path for determinism. Returns an empty string if the directory contains no files.
Types ¶
type ComponentSourceProvider ¶
type ComponentSourceProvider interface {
Provider
SourceIdentityProvider
// GetComponent retrieves the `.spec` for the specified component along with any sidecar
// files stored along with it, placing the fetched files in the provided directory.
GetComponent(
ctx context.Context, component components.Component, destDirPath string,
opts ...FetchComponentOption,
) error
}
ComponentSourceProvider is an abstract interface implemented by a source provider that can retrieve the full file contents of a given component or calculate an identity.
type FedoraSourcesProviderImpl ¶
type FedoraSourcesProviderImpl struct {
// contains filtered or unexported fields
}
FedoraSourcesProviderImpl implements ComponentSourceProvider for Git repositories.
func NewFedoraSourcesProviderImpl ¶
func NewFedoraSourcesProviderImpl( fs opctx.FS, dryRunnable opctx.DryRunnable, gitProvider git.GitProvider, downloader fedorasource.FedoraSourceDownloader, distro ResolvedDistro, retryCfg retry.Config, ) (*FedoraSourcesProviderImpl, error)
func (*FedoraSourcesProviderImpl) GetComponent ¶
func (g *FedoraSourcesProviderImpl) GetComponent( ctx context.Context, component components.Component, destDirPath string, opts ...FetchComponentOption, ) (err error)
func (*FedoraSourcesProviderImpl) ResolveIdentity ¶ added in v0.2.0
func (g *FedoraSourcesProviderImpl) ResolveIdentity( ctx context.Context, component components.Component, ) (string, error)
ResolveIdentity implements SourceIdentityProvider by resolving the upstream commit hash for the component. Ignores projectconfig.ComponentLockData — callers that want the cached locked commit should read projectconfig.ComponentLockData.UpstreamCommit directly.
When projectconfig.SpecSource.UpstreamCommit is pinned, returns that commit directly without contacting upstream. Otherwise, clones the dist-git repo to resolve the commit via snapshot time or branch HEAD.
type FetchComponentOption ¶ added in v0.2.0
type FetchComponentOption func(*FetchComponentOptions)
FetchComponentOption is a functional option for configuring component fetch behavior.
func WithPreserveGitDir ¶ added in v0.2.0
func WithPreserveGitDir() FetchComponentOption
WithPreserveGitDir returns a FetchComponentOption that instructs the provider to preserve the upstream .git directory in the fetched component sources.
func WithSkipLookaside ¶ added in v0.2.0
func WithSkipLookaside() FetchComponentOption
WithSkipLookaside returns a FetchComponentOption that skips lookaside cache downloads during component fetching. Git-tracked files are still fetched.
type FetchComponentOptions ¶ added in v0.2.0
type FetchComponentOptions struct {
// PreserveGitDir, when true, instructs the provider to keep the upstream .git directory
// in the fetched component sources instead of deleting it. This is required for building
// synthetic git history from overlay blame metadata.
PreserveGitDir bool
// SkipLookaside, when true, skips all lookaside cache downloads during component
// fetching. Git-tracked files (spec, patches, scripts) are still fetched from the
// upstream clone. The sources manifest file remains available for validation.
SkipLookaside bool
}
FetchComponentOptions holds optional parameters for component fetching operations.
type FileSourceProvider ¶
type FileSourceProvider interface {
Provider
// GetFile retrieves a single source file and places it in destDirPath.
// Implementations must return [ErrNotFound] (or an error wrapping it) when the
// provider does not handle the given file reference, so the manager can try the
// next registered provider before falling back to lookaside and configured origins.
GetFile(
ctx context.Context,
component components.Component,
fileRef projectconfig.SourceFileReference,
destDirPath string,
) error
}
FileSourceProvider is an abstract interface implemented by a source provider that can retrieve individual source files.
type Provider ¶
type Provider interface{}
Provider is an abstract interface implemented by a source provider.
type RPMContentsProviderImpl ¶
type RPMContentsProviderImpl struct {
// contains filtered or unexported fields
}
RPMContentsProviderImpl implements ComponentSourceProvider. It relies on rpmprovider.RPMProvider to download the RPM file.
func NewRPMContentsProviderImpl ¶
func NewRPMContentsProviderImpl( extractor rpm.RPMExtractor, rpmProvider rpmprovider.RPMProvider, ) (*RPMContentsProviderImpl, error)
NewRPMContentsProviderImpl creates a new instance of RPMContentsProviderImpl.
func (*RPMContentsProviderImpl) GetComponent ¶
func (r *RPMContentsProviderImpl) GetComponent( ctx context.Context, component components.Component, destDirPath string, _ ...FetchComponentOption, ) (err error)
GetComponent downloads the source RPM for a component and extracts its contents in the provided destination path.
func (*RPMContentsProviderImpl) ResolveIdentity ¶ added in v0.2.0
func (r *RPMContentsProviderImpl) ResolveIdentity( ctx context.Context, component components.Component, ) (identity string, err error)
ResolveIdentity implements SourceIdentityProvider by downloading the source RPM and computing its SHA256 hash. This is a heavyweight operation since it requires a full RPM download.
type ResolvedDistro ¶
type ResolvedDistro struct {
// Ref is the effective distro reference (component override or project default).
// Contains the snapshot time used for commit selection.
Ref projectconfig.DistroReference
// Definition is the resolved distro definition containing base URIs.
Definition projectconfig.DistroDefinition
// Version is the resolved distro version definition containing branch info.
Version projectconfig.DistroVersionDefinition
}
ResolvedDistro holds the fully resolved distro configuration for a component. This is resolved once at the call site and passed through the source manager to providers, so each consumer can derive only what it needs.
func ResolveDistro ¶
func ResolveDistro(env *azldev.Env, component components.Component) (ResolvedDistro, error)
ResolveDistro resolves the effective distro for a component, falling back to the project's default distro when the component doesn't specify one. Returns an error if no effective distro can be resolved.
type SourceIdentityProvider ¶ added in v0.2.0
type SourceIdentityProvider interface {
// ResolveIdentity returns a deterministic identity string for the component's source.
// Returns an error if the identity cannot be determined (e.g., network failure for upstream sources).
// Upstream components must return the resolved commit hash from the dist-git provider, local components
// must return a content hash of the spec directory (must be stable, but exact format and algorithm
// are up to the provider).
ResolveIdentity(ctx context.Context, component components.Component) (string, error)
}
SourceIdentityProvider resolves a reproducible identity string for a component's source. The identity changes whenever the source content would change — the exact representation depends on the source type (e.g., a commit hash for dist-git, a content hash for local files).
Consumers should treat the returned string as opaque; it is only meaningful for equality comparison between two runs.
type SourceManager ¶
type SourceManager interface {
// FetchFiles fetches the given source files, placing the files in the provided directory.
FetchFiles(ctx context.Context, component components.Component, destDirPath string) error
// FetchComponent fetches an entire upstream component, including its `.spec` file and any sidecar files.
// Optional [FetchComponentOption] values may be passed to control provider behavior (e.g., preserving
// the upstream .git directory).
FetchComponent(
ctx context.Context, component components.Component, destDirPath string,
opts ...FetchComponentOption,
) error
// ResolveSourceIdentity returns a deterministic identity string for the component's source.
// For local components, this is a content hash of the spec directory.
// For upstream components, this is the resolved commit hash from the dist-git provider.
ResolveSourceIdentity(ctx context.Context, component components.Component) (string, error)
}
SourceManager is an abstract interface for a facility that can fetch arbitrary component sources.
func NewSourceManager ¶
func NewSourceManager(env *azldev.Env, distro ResolvedDistro) (SourceManager, error)
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
fedorasource_test
Package fedorasource_test is a generated GoMock package.
|
Package fedorasource_test is a generated GoMock package. |
|
Package sourceproviders_test is a generated GoMock package.
|
Package sourceproviders_test is a generated GoMock package. |