direct

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package direct provides a forge.Provider implementation for tools distributed via arbitrary HTTP servers. Asset URLs are constructed from typed Settings and configurable templates; version detection is optional and supports plain text, JSON, YAML, and XML endpoints. GTB config integration lives in SettingsFromConfig.

Index

Constants

View Source
const DefaultTokenEnv = "DIRECT_TOKEN"

DefaultTokenEnv is the well-known environment variable consulted last when resolving a credential, after the config-supplied env reference, keychain entry and literal value. See forge.ResolveToken.

Variables

View Source
var ErrVersionUnknown = errors.New(
	"cannot determine latest version: configure version_url or pinned_version in Params",
)

ErrVersionUnknown is returned when neither version_url nor pinned_version is configured and a version check is requested.

It lives here rather than in the shared contract because it is specific to this provider: it names Params keys (version_url, pinned_version) that mean nothing to a forge-backed provider, which learns its latest version by asking the API. A sentinel in the shared package implies every provider might return it.

Functions

This section is empty.

Types

type DirectReleaseProvider

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

DirectReleaseProvider implements forge.Provider for direct HTTP downloads.

func NewReleaseProvider

func NewReleaseProvider(settings Settings) (*DirectReleaseProvider, error)

NewReleaseProvider constructs a DirectReleaseProvider from explicit typed settings.

Required Params key: url_template. Optional Params keys: version_url, version_format, version_key, pinned_version, checksum_url_template, signature_url_template. Token resolution goes through forge.ResolveToken, which walks the standard chain: auth.env (an environment-variable name) -> auth.keychain -> auth.value -> Settings.TokenFallbackEnv. Direct is the reference implementation, so it takes the same path a third-party provider should.

func (*DirectReleaseProvider) DownloadChecksumManifest

func (p *DirectReleaseProvider) DownloadChecksumManifest(ctx context.Context, rel forge.Release, maxBytes int64) ([]byte, error)

DownloadChecksumManifest implements forge.ChecksumProvider by fetching the checksums manifest from the URL produced by expanding `checksum_url_template` against the release version. Returns forge.ErrNotSupported when `checksum_url_template` is unset, so callers fall back to the default asset-list lookup (which is pointless for Direct but keeps the fallback path consistent across providers).

Size-capping is enforced here against the caller-supplied maxBytes, identically to DownloadSignature — see forge.ChecksumProvider.

func (*DirectReleaseProvider) DownloadReleaseAsset

func (p *DirectReleaseProvider) DownloadReleaseAsset(ctx context.Context, _, _ string, asset forge.ReleaseAsset) (io.ReadCloser, string, error)

DownloadReleaseAsset downloads the asset at its BrowserDownloadURL.

func (*DirectReleaseProvider) DownloadSignature

func (p *DirectReleaseProvider) DownloadSignature(ctx context.Context, rel forge.Release, maxBytes int64) ([]byte, error)

DownloadSignature implements forge.SignatureProvider by fetching the detached signature from the URL produced by expanding `signature_url_template` against the release version. Returns forge.ErrNotSupported when `signature_url_template` is unset, so callers respect the require_signature policy.

Size-capping is enforced here against the caller-supplied maxBytes, identically to DownloadChecksumManifest — see forge.SignatureProvider.

func (*DirectReleaseProvider) GetLatestRelease

func (p *DirectReleaseProvider) GetLatestRelease(ctx context.Context, _, _ string) (forge.Release, error)

GetLatestRelease fetches the latest version from the version endpoint and returns a synthetic forge. Returns ErrVersionUnknown if no version source is configured.

func (*DirectReleaseProvider) GetReleaseByTag

func (p *DirectReleaseProvider) GetReleaseByTag(_ context.Context, _, _, tag string) (forge.Release, error)

GetReleaseByTag constructs a synthetic release for the given tag without any network call.

func (*DirectReleaseProvider) ListReleases

func (p *DirectReleaseProvider) ListReleases(_ context.Context, _, _ string, _ int) ([]forge.Release, error)

ListReleases is not supported for direct HTTP providers.

func (*DirectReleaseProvider) SetToolName

func (p *DirectReleaseProvider) SetToolName(name string)

SetToolName sets the tool name used in URL template expansion. This is called by the setup package when the Props.Tool.Name is available.

type Settings

type Settings struct {
	ReleaseSource forge.ReleaseSourceConfig

	// Auth carries the credential reference resolved by [forge.ResolveToken].
	Auth forge.AuthConfig

	// TokenFallbackEnv names the environment variable consulted last. Empty
	// means no fallback; the registered factory supplies [DefaultTokenEnv].
	TokenFallbackEnv string
}

Settings contains the typed configuration needed to construct a Direct release provider without binding the provider to any config container.

The shape deliberately matches every other provider: a release source, a forge.AuthConfig, and the well-known environment variable to fall back to. Direct is this module's reference implementation, so it demonstrates the same credential path a third-party provider should take rather than a shortcut of its own.

func SettingsFromConfig

func SettingsFromConfig(src forge.ReleaseSourceConfig, cfg forge.Config, tokenFallbackEnv string) Settings

SettingsFromConfig adapts the direct config subtree into typed provider settings, reading the standard `direct.auth.*` layout with a fallback to the legacy `direct.token` scalar.

Jump to

Keyboard shortcuts

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