workspace

package
v0.0.0-...-d13d548 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: MIT Imports: 11 Imported by: 1

Documentation

Overview

Package workspace contains a pipeline for processing a Go workspace.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LocalRepo

type LocalRepo struct {
	Path string // Full path to repository on disk.
	Root string // Import path corresponding to the root of the repository.
	VCS  *vcs.Cmd
}

LocalRepo represents a local repository on disk.

type Pipeline

type Pipeline struct {

	// Packages is the working list of Go packages.
	// It's implemented as two slices and a map kept in sync, protected by a mutex.
	Packages struct {
		sync.Mutex
		Active  []*RepoPresentation          // Active repo presentations, latest at the end.
		History []*RepoPresentation          // Historical repo presentations, latest at the end.
		ByRoot  map[string]*RepoPresentation // Map key is repoRoot.
	}
	// contains filtered or unexported fields
}

Pipeline for processing a Go workspace, where each repo has local and remote components.

func NewPipeline

func NewPipeline(wd string) *Pipeline

NewPipeline creates a Pipeline with working directory wd. Working directory is used to resolve relative import paths.

First, available presenters should be registered via RegisterPresenter. Then Go packages can be added via various means. Call Done once done adding. Processing begins as soon as Go packages are added to the pipeline. Results can be accessed via RepoPresentations at any time, as often as needed.

func (*Pipeline) AddImportPath

func (p *Pipeline) AddImportPath(importPath string)

AddImportPath adds a package with specified import path for processing.

func (*Pipeline) AddPresented

func (p *Pipeline) AddPresented(r *RepoPresentation)

AddPresented adds a RepoPresentation the pipeline. It enables mocks to directly add presented repos.

func (*Pipeline) AddRepository

func (p *Pipeline) AddRepository(r LocalRepo)

AddRepository adds the specified repository for processing.

func (*Pipeline) AddRevision

func (p *Pipeline) AddRevision(importPath string, revision string)

AddRevision adds a package with specified import path and revision for processing.

func (*Pipeline) AddRevisionLatest

func (p *Pipeline) AddRevisionLatest(root, revision, latest string)

AddRevisionLatest adds a package with specified root, revision and latest.

func (*Pipeline) AddSubrepo

func (p *Pipeline) AddSubrepo(s Subrepo)

AddSubrepo adds the specified Subrepo for processing.

func (*Pipeline) Done

func (p *Pipeline) Done()

Done should be called after the workspace is finished being populated.

func (*Pipeline) RegisterPresenter

func (p *Pipeline) RegisterPresenter(pr presenter.Presenter)

RegisterPresenter registers a presenter. Presenters are consulted in the same order that they were registered.

func (*Pipeline) RepoPresentations

func (p *Pipeline) RepoPresentations() <-chan *RepoPresentation

RepoPresentations returns a channel of all repo presentations. Repo presentations that are ready will be sent immediately. The remaining repo presentations will be sent onto the channel as they become available. Once all repo presentations have been sent, the channel will be closed. Therefore, iterating over the channel may block until all processing is done, but it will effectively return all repo presentations as soon as possible.

It's safe to call RepoPresentations at any time and concurrently to get multiple such channels.

type RepoPresentation

type RepoPresentation struct {
	Repo         *gps.Repo
	Presentation *presenter.Presentation

	UpdateState UpdateState
}

RepoPresentation represents a repository update presentation.

type Subrepo

type Subrepo struct {
	Root      string
	RemoteVCS vcsstate.RemoteVCS // RemoteVCS allows getting the remote state of the VCS.
	RemoteURL string             // RemoteURL is the remote URL, including scheme.
	Revision  string
}

Subrepo represents a "virtual" sub-repository inside a larger actual VCS repository.

type UpdateState

type UpdateState uint8

UpdateState represents the state of an update.

TODO: Dedup.

const (
	// Available represents an available update.
	Available UpdateState = iota

	// Updating represents an update in progress.
	Updating

	// Updated represents a completed update.
	Updated
)

Jump to

Keyboard shortcuts

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