Documentation
¶
Index ¶
- Constants
- func CheckWritePermission(dir string) error
- func DetectPackageManager(binaryPath string) (string, bool)
- func DownloadArchive(httpClient *http.Client, url, dir string, isTTY bool) (string, error)
- func ExtractBinary(archivePath, outDir, binaryName string) (string, error)
- func IsDevBuild(version string) bool
- func IsPrerelease(version string) bool
- func ReplaceBinary(targetPath, newPath string) error
- func ResolveBinaryPath() (string, string, error)
- func ShouldUpdate(current, latest string, crossChannel bool) bool
- func VerifyCosignBundle(httpClient *http.Client, archivePath, bundleURL string) error
- func VerifySHA256(path, expected string) error
- type Asset
- type ChannelIndex
- type Client
- type ReleaseEntry
- type VersionMetadata
Constants ¶
const ( ChannelStable = "stable" ChannelPrerelease = "prerelease" )
Variables ¶
This section is empty.
Functions ¶
func CheckWritePermission ¶
CheckWritePermission checks if the directory is writable by attempting to create a temporary file.
func DetectPackageManager ¶
DetectPackageManager checks if the binary path is inside a known package-managed prefix. Returns the manager name and whether it was detected.
func DownloadArchive ¶
DownloadArchive downloads a file from url to a temp file in dir. Returns the path to the downloaded file. If isTTY is true, displays a progress bar; otherwise uses line-based progress. Checks Content-Length header and caps streaming at maxArchiveSizeLimit.
func ExtractBinary ¶
ExtractBinary extracts the named binary from a .tar.gz archive to a temp file in outDir. Validates that the extracted path contains no separators or traversal components.
func IsDevBuild ¶
IsDevBuild returns true if the version is not a valid semver string, or is a non-canonical short version like "0.0", or has a git describe suffix like "0.1.0-alpha.7-3-gabcdef".
func IsPrerelease ¶
IsPrerelease returns true if the version is a valid semver string with a prerelease suffix (e.g., "0.1.0-alpha.7").
func ReplaceBinary ¶
ReplaceBinary atomically replaces the binary at targetPath with the new binary at newPath using os.Rename (atomic on POSIX). Preserves the original file permissions.
func ResolveBinaryPath ¶
ResolveBinaryPath returns the absolute path to the currently running binary, resolving any symlinks. It also returns the original (unresolved) path, which is useful for package manager detection where symlinks (e.g. /snap/bin/foo -> /usr/bin/snap) would cause incorrect prefix matching.
func ShouldUpdate ¶
ShouldUpdate returns true if the binary should be updated from current to latest. If crossChannel is true, the update is always offered (the user explicitly chose to switch channels). Dev builds always get offered updates.
func VerifyCosignBundle ¶
VerifyCosignBundle verifies the cosign bundle for the archive at archivePath. Downloads the bundle from bundleURL and verifies against Sigstore's public good instance.
Verification checks: - Certificate issuer: https://token.actions.githubusercontent.com - Certificate SAN (prefix): https://github.com/bernd/vibepit/.github/workflows/build.yml
func VerifySHA256 ¶
VerifySHA256 checks that the SHA256 hash of the file at path matches the expected hex-encoded checksum.
Types ¶
type Asset ¶
type Asset struct {
OS string `json:"os"`
Arch string `json:"arch"`
URL string `json:"url"`
SHA256 string `json:"sha256"`
CosignBundleURL string `json:"cosign_bundle_url"`
}
Asset represents a platform-specific release asset.
type ChannelIndex ¶
type ChannelIndex struct {
Latest string `json:"latest"`
Releases []ReleaseEntry `json:"releases"`
}
ChannelIndex represents a channel index file (e.g., stable.json).
type Client ¶
Client fetches release metadata from vibepit.dev.
func (*Client) FetchChannelIndex ¶
func (c *Client) FetchChannelIndex(channel string) (*ChannelIndex, bool, error)
FetchChannelIndex fetches and parses a channel index file. Returns the index and a boolean indicating whether the file was found.
func (*Client) FetchVersionMetadata ¶
func (c *Client) FetchVersionMetadata(version string) (*VersionMetadata, error)
FetchVersionMetadata fetches and parses a version metadata file.
func (*Client) ResolveChannel ¶
func (c *Client) ResolveChannel(preferPre bool) (*ChannelIndex, string, error)
ResolveChannel determines which channel to use and fetches the index. Implements fallback logic: if stable is not found and --pre was not explicitly set, falls back to prerelease.
type ReleaseEntry ¶
ReleaseEntry is a single entry in the channel index releases array.