Documentation
¶
Overview ¶
Package golang is the format of Go module repositories (decision 0035). It reads the GOPROXY paths a request names, checks the path of every version file a client deploys, chooses what @v/list and @latest answer, and keeps the package index. In the index a module is a package, and each of its versions links whichever of the version's .zip, .mod and .info are stored.
Index ¶
- Constants
- Variables
- func CheckInfo(f File, body []byte) error
- func Latest(versions []string) (latest string, ok bool)
- func ListTime(v types.PackageVersion) time.Time
- func Listed(versions []types.PackageVersion) []string
- func Republished(f File) *format.RejectionError
- func Serves(t repo.PackageType) bool
- type File
- type Handler
- func (h Handler) Admit(ctx context.Context, env format.Env, c repo.Config, w format.Write) (format.Write, error)
- func (Handler) Classify(_ repo.Config, p string) format.Class
- func (Handler) Deleted(ctx context.Context, env format.Env, c repo.Config, removed []types.Item) error
- func (Handler) Deleting(context.Context, format.Env, repo.Config, types.Item) error
- func (Handler) Deployed(ctx context.Context, env format.Env, c repo.Config, it types.Item) error
- func (Handler) Reindex(ctx context.Context, env format.Env, c repo.Config) error
- type InvalidPathError
- type Kind
- type Request
Constants ¶
const ( ExtZip = "zip" ExtMod = "mod" ExtInfo = "info" )
Extensions of a version's files.
const MaxInfo = 64 << 10
MaxInfo is the largest .info a Go deploy may carry: 64 KiB, far above the two fields the go command reads.
Variables ¶
var ErrNoOperation = errors.New("golang: no go module operation")
ErrNoOperation is a path that names no GOPROXY operation. Every method answers it 404.
Functions ¶
func CheckInfo ¶
CheckInfo applies decision 0035's check to the body of a .info deployed through the Go API: a JSON object of at most MaxInfo bytes whose Version is f's version and whose Time, when present, is RFC 3339, so the go command can read what @latest and .info serve. The fields are matched as the GOPROXY protocol spells them.
func Latest ¶
Latest returns the version @latest answers among a module's visible versions, chosen as the go command prefers: the highest release; when there is none, the highest pre-release that is not a pseudo-version; when there is none, the pseudo-version with the latest time it encodes. ok is false when versions is empty. The go command asks @latest only when it finds no release or pre-release in @v/list, so the last rule is what resolves a module published only at pseudo-versions.
func ListTime ¶
func ListTime(v types.PackageVersion) time.Time
ListTime is the time @v/list gives version v: its stored .info's Time, or else when its first file was stored, which a synthesised .info gives.
func Listed ¶
func Listed(versions []types.PackageVersion) []string
Listed returns the lines @v/list answers for a module's visible versions, in ascending order: each version, pseudo-versions included, with its ListTime in RFC 3339. Artifactory dates each line from the version's .info since 7.8.1 (RTFACT-21670). The go command reads the time only to choose @latest among pseudo-versions when @latest itself fails, and leaves pseudo-versions out of go list -m -versions whatever the list says, so listing them changes no version it picks.
func Republished ¶
func Republished(f File) *format.RejectionError
Republished is the refusal of different content over f, a stored .zip or .mod, whichever API carried it.
Types ¶
type File ¶
type File struct {
Module, Version, Ext string
}
File is one file of a module version.
func ParseFile ¶
ParseFile reads the stored path of a version file and applies the path checks of decision 0035, which decide whether the file is indexed. A stored path is never case-decoded: a file deployed through the item routes at an encoded path fails module.Check, as "!" cannot appear in a module path, and belongs to no version.
type Handler ¶
type Handler struct {
// The generic format admits writes under every package type's deploy
// policy.
generic.Handler
}
Handler is the format of Go repositories, which the item service calls on every write and delete in them, whichever API carried it. It keeps the package index of decision 0035. A module is a package, and a version is a version while any of its .zip, .mod and .info is stored. The version links exactly those files, is dated by the first of them stored, and keeps the Time its stored .info gives as its metadata. A file whose path fails the path checks belongs to no version.
func (Handler) Admit ¶
func (h Handler) Admit( ctx context.Context, env format.Env, c repo.Config, w format.Write, ) (format.Write, error)
Admit applies the deploy policy of every package type, then the republishing rule of decision 0035 to every write that lands content: a deploy by any API, and the target of a copy or a move. go.sum and the checksum database pin a version's .zip and .mod forever, so different content over a stored one is refused, even for a caller who may delete, while the same content and any .info pass.
func (Handler) Classify ¶
Classify reports a version's .info as metadata, since it may be replaced under the same path, and every other file, a .zip and a .mod included, as unique.
func (Handler) Deleted ¶
func (Handler) Deleted( ctx context.Context, env format.Env, c repo.Config, removed []types.Item, ) error
Deleted settles each version a delete or a move took files from. A version that keeps a file may now date from a later one. A version left with none is gone already: the item service pruned it, and its module if that was the module's last version.
func (Handler) Deleting ¶
Deleting runs before a file is removed. The item service drops the file's version link with it, and Deleted settles the rest.
type InvalidPathError ¶
type InvalidPathError struct{ Message string }
InvalidPathError is a path that names a Go operation but fails its checks. A read answers it 404, and a PUT 400 with the message.
func (*InvalidPathError) Error ¶
func (e *InvalidPathError) Error() string
type Kind ¶
type Kind int
Kind is the GOPROXY operation a request path names.
const ( // KindList is <module>/@v/list. KindList Kind = iota + 1 // KindInfo, KindMod and KindZip are <module>/@v/<version>.info, .mod and .zip. KindInfo KindMod KindZip // KindLatest is <module>/@latest, and <module>/@v/latest.info, which jf go // asks for. KindLatest )
Operations under /artifactory/api/go/{repoKey}/.
type Request ¶
Request is a GOPROXY request path after the repository key, with its module path and version decoded.
func ParseRequest ¶
ParseRequest reads a GOPROXY request path. A module path or version that contains "!" is case-decoded, and anything else is taken as written: the go command sends the encoded form and jf the plain one, and both name the same version. The split is at the last "/@v/", which is unambiguous because a module path cannot contain "@". The checks are those a PUT applies (decision 0035): a version file's extension is zip, mod or info, and its module path and version pass module.Check with the version canonical, which also turns a .info request for a branch name away.