Documentation
¶
Overview ¶
Package platforms holds what the publish drivers share: release asset globs and opening asset files safely inside the repository.
Index ¶
- func CheckAssetGlobs(patterns []string, allowMissing bool) error
- func CheckAssetGlobsFor(patterns []string, allowMissing bool, rule NameRule) error
- func CloseAssets(assets []Asset)
- func Retry(ctx context.Context, delays []time.Duration, transient func(error) bool, ...) error
- type Asset
- type NameRule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckAssetGlobs ¶ added in v0.81.0
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
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
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
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
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). |