Documentation ¶
Overview ¶
Package code implements a Go code service backed by a repository store.
Index ¶
- func NewGitHandler(code *Service, reposDir, gitHooksDir string, events events.ExternalService, ...) (*gitHandler, error)
- func WriteModuleZip(w io.Writer, m module.Version, r vcs.Repository, id vcs.CommitID) error
- type Directory
- type ModuleHandler
- type Package
- type Service
- func (s *Service) CreateRepo(ctx context.Context, repoSpec, description string) error
- func (s *Service) GetDirectory(_ context.Context, importPath string) (*Directory, error)
- func (s *Service) ListDirectories(context.Context) ([]*Directory, error)
- func (s *Service) Rediscover(repoRoot string) (added, removed []*Directory, err error)
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 ¶
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 ¶
HasLicenseFile reports whether directory d contains a LICENSE file.
func (Directory) IsRepoRoot ¶
IsRepoRoot reports whether directory d corresponds to a repository root.
func (Directory) WithinRepo ¶
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.
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 ¶
CreateRepo creates an empty repository with the specified repoSpec and description. If the directory already exists, os.ErrExist is returned.
func (*Service) GetDirectory ¶
GetDirectory looks up a directory by specified import path. If the directory doesn't exist, os.ErrNotExist is returned.
func (*Service) ListDirectories ¶
ListDirectories lists directories in sorted order.
Directories ¶
Path | Synopsis |
---|---|
Package httpclient contains code.Service implementation over HTTP.
|
Package httpclient contains code.Service implementation over HTTP. |
Package httphandler contains an API handler for code.Service.
|
Package httphandler contains an API handler for code.Service. |
Package httproute contains route paths for httpclient, httphandler.
|
Package httproute contains route paths for httpclient, httphandler. |