platforms

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package platforms holds what the publish drivers share: release asset globs and opening asset files safely inside the repository.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckAssetGlobs added in v0.81.0

func CheckAssetGlobs(patterns []string, allowMissing bool) error

CheckAssetGlobs applies the publish-time asset rules (matchAssets) without opening anything, so a refusal surfaces before anything is committed or pushed: every match must be a regular file inside the repository with a basename no other match has, and, unless allowMissing is set, every pattern must match at least one file (ADR-0076). The latter is wrapped in port.ErrAssetUnmatched so a dry run, where hooks have not built the files, can tell it apart. With allowMissing a pattern matching nothing is left for publishing to warn about.

func CheckAssetGlobsFor added in v0.82.0

func CheckAssetGlobsFor(patterns []string, allowMissing bool, rule NameRule) error

CheckAssetGlobsFor is CheckAssetGlobs for a forge that renames assets: two matches whose names share rule.Key are refused as well, before anything is committed.

func CloseAssets added in v0.82.0

func CloseAssets(assets []Asset)

CloseAssets closes every file OpenAssets returned.

func Retry added in v1.0.1

func Retry(ctx context.Context, delays []time.Duration, transient func(error) bool, op func() error) error

Retry runs op, then runs it again after each of delays while it fails with an error transient accepts: len(delays)+1 attempts at most. It returns op's last error, and stops waiting, without a further attempt, once ctx ends.

Types

type Asset added in v0.82.0

type Asset struct {
	Path string
	Name string
	Size int64
	File *os.File
}

Asset is a release asset opened for upload. Path is the match as the glob returned it, for messages; Name is its basename, the name it is published under. Size comes from the open file.

func OpenAssets added in v0.82.0

func OpenAssets(patterns []string, warn func(string)) ([]Asset, error)

OpenAssets resolves the asset globs with the rules of matchAssets and opens every match, so an upload reads the file that was checked, not whatever the path names by the time it is read (NEW-002, ADR-0077). The open goes through an os.Root on the repository root, which refuses a path that leaves it even if a symlink is swapped in after the check, and os.SameFile and the file type confirm the descriptor is the file that was checked. On success the caller closes the files with CloseAssets; on error none is left open.

type NameRule added in v0.82.0

type NameRule struct {
	Forge string
	Key   func(name string) string
	Valid func(name string) error
}

NameRule describes how a forge turns a file name into the name it publishes: Key maps a basename to a value that is equal for any two basenames the forge would publish as one asset, and Valid, when set, refuses a basename the forge does not accept at all. Forge names the forge in the refusal.

Directories

Path Synopsis
Package github publishes releases and their assets to GitHub and GitHub Enterprise Server through the REST API (go-github, ADR-0077).
Package github publishes releases and their assets to GitHub and GitHub Enterprise Server through the REST API (go-github, ADR-0077).

Jump to

Keyboard shortcuts

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