Documentation
¶
Index ¶
- Constants
- func BuildDistGitURL(template, packageName string) (string, error)
- func BuildLookasideURL(template, packageName, fileName, hashType, hash string) (string, error)
- func FormatSourcesEntry(filename string, hashType fileutils.HashType, hash string) string
- type ExtractOption
- type FedoraSourceDownloader
- type FedoraSourceDownloaderImpl
- type SourcesFileEntry
- type SourcesFileLine
Constants ¶
const ( // PlaceholderPkg is replaced with the package name. PlaceholderPkg = "$pkg" // PlaceholderFilename is replaced with the source file name. PlaceholderFilename = "$filename" // PlaceholderHashType is replaced with the lowercase hash algorithm (e.g., "sha512"). PlaceholderHashType = "$hashtype" // PlaceholderHash is replaced with the hash value. PlaceholderHash = "$hash" )
Lookaside URI template placeholders supported by BuildLookasideURL.
const SourcesFileName = "sources"
SourcesFileName is the name of the Fedora/RHEL 'sources' metadata file.
Variables ¶
This section is empty.
Functions ¶
func BuildDistGitURL ¶ added in v0.2.0
BuildDistGitURL constructs a dist-git repository URL by substituting the PlaceholderPkg placeholder in the URI template with the provided package name.
The package name is URL path-escaped via url.PathEscape so that reserved characters such as /, ?, #, and % do not alter the URL structure.
Returns an error if the package name contains a placeholder string, or if the resulting URL is not valid.
func BuildLookasideURL ¶
BuildLookasideURL constructs a lookaside cache URL by substituting placeholders in the URI template with the provided values. Supported placeholders are PlaceholderPkg, PlaceholderFilename, PlaceholderHashType, and PlaceholderHash. Placeholders not present in the template are simply ignored.
Substituted values are URL path-escaped via url.PathEscape so that reserved characters such as /, ?, #, and % do not alter the URL structure.
Returns an error if any of the provided values contain a placeholder string, as this would cause ambiguous substitution results depending on replacement order, or if the resulting URL is not valid.
func FormatSourcesEntry ¶ added in v0.2.0
FormatSourcesEntry formats a 'sources' file entry in the modern Fedora/RHEL format. Example output: "SHA512 (example-1.0.tar.gz) = a1b2c3d4e5f6..."
The [hashType] must be a canonical fileutils.HashType constant. The hash value is included as-is without case normalization.
Types ¶
type ExtractOption ¶ added in v0.2.0
type ExtractOption func(*extractOptions)
ExtractOption is a functional option for [ExtractSourcesFromRepo].
func WithOutputDir ¶ added in v0.2.0
func WithOutputDir(dir string) ExtractOption
WithOutputDir specifies a separate directory for downloaded files. When set, the 'sources' file is read from repoDir but files are downloaded into outputDir instead.
type FedoraSourceDownloader ¶
type FedoraSourceDownloader interface {
// ExtractSourcesFromRepo processes a git repository by downloading any required
// lookaside cache files into the repository directory. Files whose names appear
// in skipFilenames are not downloaded (e.g., files already fetched separately).
// Optional [ExtractOption] values can override default behavior.
ExtractSourcesFromRepo(
ctx context.Context, repoDir string, packageName string,
lookasideBaseURI string, skipFilenames []string,
opts ...ExtractOption,
) error
}
type FedoraSourceDownloaderImpl ¶
type FedoraSourceDownloaderImpl struct {
// contains filtered or unexported fields
}
FedoraSourceDownloaderImpl is an implementation of GitRepoExtractor.
func NewFedoraRepoExtractorImpl ¶
func NewFedoraRepoExtractorImpl( dryRunnable opctx.DryRunnable, fileSystem opctx.FS, downloader downloader.Downloader, retryCfg retry.Config, ) (*FedoraSourceDownloaderImpl, error)
NewFedoraRepoExtractorImpl creates a new instance of FedoraRepoExtractorImpl with the provided downloader.
func (*FedoraSourceDownloaderImpl) ExtractSourcesFromRepo ¶
func (g *FedoraSourceDownloaderImpl) ExtractSourcesFromRepo( ctx context.Context, repoDir string, packageName string, lookasideBaseURI string, skipFileNames []string, opts ...ExtractOption, ) error
ExtractSourcesFromRepo processes the git repository by downloading any required lookaside cache files into the repository directory.
type SourcesFileEntry ¶ added in v0.2.0
SourcesFileEntry represents a parsed entry from a Fedora/RHEL 'sources' file. This struct is used for both reading existing 'sources' files and generating new entries.
type SourcesFileLine ¶ added in v0.2.0
type SourcesFileLine struct {
// Raw is the original line as it appeared in the file (without the
// terminating newline).
Raw string
// Entry is the parsed entry for this line, or nil for blank/comment lines.
Entry *SourcesFileEntry
}
SourcesFileLine represents a single line of a Fedora/RHEL 'sources' file in the form returned by ReadSourcesFile. The original line text is always preserved in SourcesFileLine.Raw so that comments and blank lines can be emitted verbatim during in-place merges. SourcesFileLine.Entry is non-nil only when the line contains a valid 'sources' entry.
func ReadSourcesFile ¶ added in v0.2.0
func ReadSourcesFile(content string) ([]SourcesFileLine, error)
ReadSourcesFile parses the content of a Fedora/RHEL 'sources' file and returns every line in order, preserving comments and blank lines verbatim alongside parsed entries. It supports both the modern format (e.g., "SHA512 (file.tar.gz) = abc123...") and the legacy MD5 format (e.g., "abc123... file.tar.gz").
A duplicate filename in the input is treated as an error: a 'sources' file with two entries for the same filename is malformed and silently picking one would be unsafe. A trailing empty element produced by a final newline in [content] is dropped so that callers can re-join lines with "\n" plus a single terminating newline without producing a doubled trailing blank line.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package fedorasource_test is a generated GoMock package.
|
Package fedorasource_test is a generated GoMock package. |