Documentation
¶
Index ¶
- type ArchiveInfo
- type ArchiveReader
- type ArchiveWriter
- type Backend
- type Cataloger
- type Checker
- type Deleter
- type Getter
- type Lister
- type Module
- type Origin
- type Reader
- type Release
- type ReleaseFile
- type ReleaseList
- type ReleaseStorage
- type RevInfo
- type Saver
- type SizeReadCloser
- type ToolchainStorage
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArchiveInfo ¶ added in v0.20.0
type ArchiveInfo struct {
ReleaseFile
Stable bool `json:"stable"`
SavedAt time.Time `json:"saved_at"`
}
ArchiveInfo describes a verified archive saved by Athens.
type ArchiveReader ¶ added in v0.20.0
type ArchiveReader interface {
Archive(ctx context.Context, source, filename string) (ArchiveInfo, SizeReadCloser, error)
ListArchives(ctx context.Context, source string) ([]ArchiveInfo, error)
}
ArchiveReader reads only complete, verified archives from a distribution. Source is a stable distribution identity, not a physical storage path.
type ArchiveWriter ¶ added in v0.20.0
type ArchiveWriter interface {
SaveArchive(ctx context.Context, source string, info ArchiveInfo, body io.Reader) error
DeleteArchive(ctx context.Context, source, filename string) error
}
ArchiveWriter publishes and deletes archives. SaveArchive checks size and SHA-256 before publication. An identical save is idempotent; different bytes for an existing filename return KindAlreadyExists. Failed saves stay invisible.
type Backend ¶
Backend is a complete storage backend (i.e. file system, database) implementation - a lister, reader and saver.
type Cataloger ¶ added in v0.3.0
type Cataloger interface {
// Catalog gets all the modules / versions.
Catalog(ctx context.Context, token string, pageSize int) ([]paths.AllPathParams, string, error)
}
Cataloger is the interface that lists all the modules and version contained in the storage.
type Checker ¶
type Checker interface {
// Exists checks whether or not module in specified version is present
// in the backing storage.
Exists(ctx context.Context, module, version string) (bool, error)
}
Checker is the interface that checks if the version of the module exists.
func WithChecker ¶ added in v0.9.0
WithChecker wraps the backend with a Checker implementation.
type Deleter ¶
type Deleter interface {
// Delete must return ErrNotFound if the module/version are not
// found.
Delete(ctx context.Context, module, vsn string) error
}
Deleter deletes module metadata and its source from underlying storage.
type Getter ¶
type Getter interface {
Info(ctx context.Context, module, vsn string) ([]byte, error)
GoMod(ctx context.Context, module, vsn string) ([]byte, error)
Zip(ctx context.Context, module, vsn string) (SizeReadCloser, error)
}
Getter gets module metadata and its source from underlying storage.
type Lister ¶
type Lister interface {
// List gets all the versions for the given baseURL & module.
// It returns ErrNotFound if the module isn't found
List(ctx context.Context, module string) ([]string, error)
}
Lister is the interface that lists versions of a specific baseURL & module.
type Module ¶
type Module struct {
// TODO(marwan-at-work): ID is a mongo-specific field, it should not be
// in the generic storage.Module struct.
ID bson.ObjectID `bson:"_id,omitempty"`
Module string `bson:"module"`
Version string `bson:"version"`
Mod []byte `bson:"mod"`
Info []byte `bson:"info"`
}
Module represents a vgo module saved in a storage backend.
type Origin ¶ added in v0.12.0
type Origin struct {
VCS string `json:",omitempty"` // "git" etc
URL string `json:",omitempty"` // URL of repository
Subdir string `json:",omitempty"` // subdirectory in repo
// If TagSum is non-empty, then the resolution of this module version
// depends on the set of tags present in the repo, specifically the tags
// of the form TagPrefix + a valid semver version.
// If the matching repo tags and their commit hashes still hash to TagSum,
// the Origin is still valid (at least as far as the tags are concerned).
// The exact checksum is up to the Repo implementation; see (*gitRepo).Tags.
TagPrefix string `json:",omitempty"`
TagSum string `json:",omitempty"`
// If Ref is non-empty, then the resolution of this module version
// depends on Ref resolving to the revision identified by Hash.
// If Ref still resolves to Hash, the Origin is still valid (at least as far as Ref is concerned).
// For Git, the Ref is a full ref like "refs/heads/main" or "refs/tags/v1.2.3",
// and the Hash is the Git object hash the ref maps to.
// Other VCS might choose differently, but the idea is that Ref is the name
// with a mutable meaning while Hash is a name with an immutable meaning.
Ref string `json:",omitempty"`
Hash string `json:",omitempty"`
// If RepoSum is non-empty, then the resolution of this module version
// failed due to the repo being available but the version not being present.
// This depends on the entire state of the repo, which RepoSum summarizes.
// For Git, this is a hash of all the refs and their hashes.
RepoSum string `json:",omitempty"`
}
Origin is taken from https://pkg.go.dev/cmd/go/internal/modfetch/codehost#Origin.
type Release ¶ added in v0.20.0
type Release struct {
Version string `json:"version"`
Stable bool `json:"stable"`
Files []ReleaseFile `json:"files"`
}
Release describes a Go release in the go.dev/dl JSON format.
type ReleaseFile ¶ added in v0.20.0
type ReleaseFile struct {
Filename string `json:"filename"`
OS string `json:"os"`
Arch string `json:"arch"`
Version string `json:"version"`
SHA256 string `json:"sha256"`
Size int64 `json:"size"`
Kind string `json:"kind"`
}
ReleaseFile identifies an archive or installer and its upstream checksum.
func (ReleaseFile) Validate ¶ added in v0.20.0
func (f ReleaseFile) Validate() error
Validate checks that a file's identity, size and checksum describe the same Go release archive. Both upstream discovery and storage publication use it.
type ReleaseList ¶ added in v0.20.0
type ReleaseList struct {
Releases []Release `json:"releases"`
FetchedAt time.Time `json:"fetched_at"`
}
ReleaseList is a persisted upstream listing and the time it was fetched.
type ReleaseStorage ¶ added in v0.20.0
type ReleaseStorage interface {
Releases(ctx context.Context, source string) (*ReleaseList, error)
SaveReleases(ctx context.Context, source string, list *ReleaseList) error
}
ReleaseStorage persists discovery metadata independently of archive inventory. Saving an older listing must not replace a newer one.
type RevInfo ¶
type RevInfo struct {
Origin *Origin
Name string // complete ID in underlying repository
Short string // shortened ID, for use in pseudo-version
Version string // version used in lookup
Time time.Time // commit time
Tags []string // known tags for commit
}
RevInfo is json-encodable into the response body for GET baseURL/module/@v/version.info from https://pkg.go.dev/cmd/go/internal/modfetch/codehost#RevInfo.
type Saver ¶
type Saver interface {
// Save saves the module metadata and its source to the storage.
//
// The caller MAY call zipMD5 with a nil value if the checksum is not available.
// The storage implementation MAY use the zipMD5 to verify the integrity of the zip file.
Save(ctx context.Context, module, version string, mod []byte, zip io.Reader, zipMD5, info []byte) error
}
Saver saves module metadata and its source to underlying storage.
type SizeReadCloser ¶ added in v0.11.0
type SizeReadCloser interface {
io.ReadCloser
Size() int64
}
SizeReadCloser extends io.ReadCloser with a Size() method that tells you the length of the io.ReadCloser if read in full.
func NewSizer ¶ added in v0.11.0
func NewSizer(rc io.ReadCloser, size int64) SizeReadCloser
NewSizer is a helper wrapper to return an implementation of ReadCloserSizer.
type ToolchainStorage ¶ added in v0.20.0
type ToolchainStorage interface {
ArchiveReader
ArchiveWriter
ReleaseStorage
}
ToolchainStorage is an optional capability of a module storage backend. Release archives are kept outside the module catalog and checksum database.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package gcp provides a storage driver to upload module files to a google cloud platform storage bucket.
|
Package gcp provides a storage driver to upload module files to a google cloud platform storage bucket. |
|
internal
|
|
|
toolchain
Package toolchain implements the private storage layout for Go releases.
|
Package toolchain implements the private storage layout for Go releases. |
|
Package s3 provides a storage driver to upload module files to amazon s3 storage bucket.
|
Package s3 provides a storage driver to upload module files to amazon s3 storage bucket. |