code

package
v0.0.0-...-e98364e Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2021 License: MIT Imports: 40 Imported by: 0

Documentation

Overview

Package code implements a Go code service backed by a repository store.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGitHandler

func NewGitHandler(code *Service, reposDir, gitHooksDir string, events events.ExternalService, users users.Service, gitUsers map[string]users.User, authenticate func(*http.Request) *http.Request) (*gitHandler, error)

NewGitHandler creates a gitHandler. gitHooksDir specifies the directory where to look for git hooks.

func WriteModuleZip

func WriteModuleZip(w io.Writer, m module.Version, r vcs.Repository, id vcs.CommitID) error

WriteModuleZip builds a zip archive for module version m by including all files from repository r at commit id, and writes the result to w.

WriteModuleZip does not support multi-module repositories. A go.mod file may be in root, but not in any other directory.

Unlike "golang.org/x/mod/zip".Create, it does not verify any module zip restrictions. It will produce an invalid module zip if given a commit containing invalid files. It should be used on commits that are known to have files that are all acceptable to include in a module zip.

Types

type Directory

type Directory struct {
	ImportPath   string
	RepoRoot     string // Empty string if directory is not in a repository.
	RepoPackages int    // Number of packages contained by repository (if any, otherwise 0).

	// LicenseRoot is the import path corresponding to this or nearest parent directory
	// that contains a LICENSE file, or empty string if there isn't such a directory.
	LicenseRoot string

	Package *Package
}

Directory represents a directory inside a repository store.

func (Directory) HasLicenseFile

func (d Directory) HasLicenseFile() bool

HasLicenseFile reports whether directory d contains a LICENSE file.

func (Directory) IsRepoRoot

func (d Directory) IsRepoRoot() bool

IsRepoRoot reports whether directory d corresponds to a repository root.

func (Directory) WithinRepo

func (d Directory) WithinRepo() bool

WithinRepo reports whether directory d is contained by a repository.

type ModuleHandler

type ModuleHandler struct {
	// Code is the underlying source of Go code.
	// Each repository root available in it is served as a Go module.
	Code *Service
}

ModuleHandler is a Go module server that implements the module proxy protocol, as specified at https://golang.org/cmd/go/#hdr-Module_proxy_protocol.

At this time, it has various restrictions compared to the general go mod download functionality that extracts module versions from a VCS repository:

• It serves only pseudo-versions derived from commits on master branch. No other versions or module queries are supported at this time.

• It serves a single module corresponding to the root of each repository. Multi-module repositories are not supported at this time.

• It serves only the v0 major version. Major versions other than v0 are not supported at this time.

This may change over time as my needs evolve.

func (ModuleHandler) ServeModule

func (h ModuleHandler) ServeModule(w http.ResponseWriter, req *http.Request) error

ServeModule serves a module proxy protocol HTTP request.

The "$GOPROXY/" prefix must be stripped from req.URL.Path, so that the given req.URL.Path is like "<module>/@v/<version>.info" (no leading slash).

type Package

type Package struct {
	Name     string
	Synopsis string // Package documentation synopsis.
	DocHTML  string // Package documentation HTML.
}

Package represents a Go package inside a repository store.

func (Package) IsCommand

func (p Package) IsCommand() bool

IsCommand reports whether the package is a command.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is a Go code service implementation backed by a repository store.

func NewService

func NewService(reposDir string, notification notification.Service, events events.ExternalService, users users.Service) (*Service, error)

NewService discovers Go code inside the repository store at reposDir, and returns a code service that uses said repository store.

func (*Service) CreateRepo

func (s *Service) CreateRepo(ctx context.Context, repoSpec, description string) error

CreateRepo creates an empty repository with the specified repoSpec and description. If the directory already exists, os.ErrExist is returned.

func (*Service) GetDirectory

func (s *Service) GetDirectory(_ context.Context, importPath string) (*Directory, error)

GetDirectory looks up a directory by specified import path. If the directory doesn't exist, os.ErrNotExist is returned.

func (*Service) ListDirectories

func (s *Service) ListDirectories(context.Context) ([]*Directory, error)

ListDirectories lists directories in sorted order.

func (*Service) Rediscover

func (s *Service) Rediscover(repoRoot string) (added, removed []*Directory, err error)

Rediscover rediscovers code in repoRoot of the repository store. It returns packages that have been added and removed.

Directories

Path Synopsis
Package httpclient contains issues.Service implementation over HTTP.
Package httpclient contains issues.Service implementation over HTTP.
Package httphandler contains an API handler for issues.Service.
Package httphandler contains an API handler for issues.Service.
Package httproute contains route paths for httpclient, httphandler.
Package httproute contains route paths for httpclient, httphandler.

Jump to

Keyboard shortcuts

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