mirror

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultOCPBaseURL   = "https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp"
	DefaultRHCOSBaseURL = "https://mirror.openshift.com/pub/openshift-v4/x86_64/dependencies/rhcos"
)

Variables

View Source
var EPELArchitectures = []string{"x86_64", "aarch64", "ppc64le", "s390x"}

EPELArchitectures lists the CPU architectures supported by EPEL repositories.

View Source
var EPELVersions = []int{7, 8, 9, 10}

EPELVersions lists the EPEL major versions to discover mirrors for.

Functions

This section is empty.

Types

type Discovery

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

Discovery provides methods to discover mirrors and versions for EPEL, OCP, and RHCOS, with an in-memory cache to avoid redundant upstream requests.

func NewDiscovery

func NewDiscovery(logger *slog.Logger) *Discovery

NewDiscovery creates a new Discovery service with sensible defaults.

func (*Discovery) EPELMirrors

func (d *Discovery) EPELMirrors(ctx context.Context, version int, arch string) ([]MirrorInfo, error)

EPELMirrors fetches and parses the metalink for the given EPEL version and architecture, returning discovered mirrors sorted by preference. Results are cached.

func (*Discovery) EPELVersions

func (d *Discovery) EPELVersions() []EPELVersionInfo

EPELVersions returns the known EPEL versions with their supported architectures.

func (*Discovery) OCPVersions

func (d *Discovery) OCPVersions(ctx context.Context) ([]OCPVersion, error)

OCPVersions fetches and parses the OCP directory listing, returning available versions. Results are cached.

func (*Discovery) RHCOSVersions

func (d *Discovery) RHCOSVersions(ctx context.Context) ([]RHCOSVersion, error)

RHCOSVersions fetches the RHCOS directory listing, discovers minor versions, then fetches builds for each minor version. Results are cached. If fetching builds for a specific minor version fails, a warning is logged and that minor is included with an empty builds list.

func (*Discovery) SpeedTest

func (d *Discovery) SpeedTest(ctx context.Context, urls []string, topN int) []SpeedResult

SpeedTest measures latency and throughput for the given mirror URLs, returning the top N results sorted by throughput descending (errors last).

type EPELVersionInfo

type EPELVersionInfo struct {
	Version       int      `json:"version"`
	Architectures []string `json:"architectures"`
}

EPELVersionInfo describes an EPEL repository version and its supported architectures.

type MirrorInfo

type MirrorInfo struct {
	URL        string `json:"url"`
	Country    string `json:"country"`
	Protocol   string `json:"protocol"`
	Preference int    `json:"preference"`
}

MirrorInfo represents a single mirror endpoint discovered from a metalink or mirror list.

type OCPVersion

type OCPVersion struct {
	Version string `json:"version"`
	Channel string `json:"channel"`
}

OCPVersion identifies an OpenShift Container Platform release.

type RHCOSVersion

type RHCOSVersion struct {
	Minor  string   `json:"minor"`
	Builds []string `json:"builds"`
}

RHCOSVersion identifies a Red Hat CoreOS version and its available builds.

type SpeedResult

type SpeedResult struct {
	URL            string  `json:"url"`
	LatencyMs      int     `json:"latency_ms"`
	ThroughputKBps float64 `json:"throughput_kbps"`
	Error          string  `json:"error,omitempty"`
}

SpeedResult holds the outcome of a mirror speed test.

Jump to

Keyboard shortcuts

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