binresolver

package
v0.0.0-...-fc2e20f Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MustGatherClean = BinarySpec{
	Name:                "must-gather-clean",
	Source:              &GitHubSource{Owner: "openshift", Repo: "must-gather-clean"},
	AssetPattern:        "{name}-{os}-{arch}.tar.gz",
	WindowsAssetPattern: "{name}-{os}-{arch}.exe.zip",
	ChecksumAsset:       "SHA256_SUM",
}

MustGatherClean is the BinarySpec for the openshift/must-gather-clean tool.

Functions

func Resolve

func Resolve(ctx context.Context, spec BinarySpec, explicitPath, cacheDir string) (string, error)

Resolve returns the path to the binary. It checks in order: 1. An explicit path provided by the user (verified to exist). 2. The locally cached binary, if its version matches the latest release. 3. The latest release, downloaded and cached when a newer version is available. 4. A previously cached binary as a fallback when the source is unreachable.

cacheDir overrides the default cache directory. If empty, HCPCTL_CACHE_DIR env var is checked, then the OS user cache directory is used.

func ResolveMustGatherClean

func ResolveMustGatherClean(ctx context.Context, explicitPath, version, cacheDir string) (string, error)

ResolveMustGatherClean resolves the path to the must-gather-clean binary. If explicitPath is non-empty, it verifies the file exists and returns it. Otherwise, it downloads the release and caches it locally. version pins to a specific release (empty uses latest). cacheDir overrides the default cache directory (empty uses default).

Types

type BinarySpec

type BinarySpec struct {
	Name                string // binary name, e.g. "must-gather-clean"
	Source              Source // where to download from (e.g. GitHubSource)
	AssetPattern        string // template for non-Windows: "{name}-{os}-{arch}.tar.gz"
	WindowsAssetPattern string // template for Windows: "{name}-{os}-{arch}.exe.zip"
	ChecksumAsset       string // release asset containing SHA256 checksums (e.g. "SHA256_SUM")
	PinnedVersion       string // pin to a specific version (e.g. "v0.0.3") via --must-gather-clean-version; empty means use latest
}

BinarySpec defines a downloadable binary.

type GitHubSource

type GitHubSource struct {
	Owner string // GitHub organization, e.g. "openshift"
	Repo  string // GitHub repository, e.g. "must-gather-clean"

	APIBaseURL      string
	DownloadBaseURL string
	// contains filtered or unexported fields
}

GitHubSource downloads binaries from GitHub releases.

func (*GitHubSource) Download

func (s *GitHubSource) Download(ctx context.Context, version, asset string, w io.Writer) error

func (*GitHubSource) LatestTagName

func (s *GitHubSource) LatestTagName(ctx context.Context) (string, error)

type Source

type Source interface {
	LatestTagName(ctx context.Context) (string, error)
	Download(ctx context.Context, version, asset string, w io.Writer) error
}

Source provides methods to query and download binaries from a release source.

Jump to

Keyboard shortcuts

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