projectrepo

package
v2.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoFactoryFound = errors.New("factory not found for url")

ErrNoFactoryFound is returned when there is no factory that can be used for a given URL.

View Source
var ErrNoRepoFound = errors.New("repo not found")

ErrNoRepoFound is returned when a factory cannot create a Repo for a given URL.

View Source
var ErrRepoInaccessible = errors.New("repo inaccessible")

ErrRepoInaccessible is returned when a the Repo may exist, but is unable to access the repository for some reason.

Functions

This section is empty.

Types

type Factory

type Factory interface {
	// New returns a new instance of Repo for the supplied URL.
	//
	// If the project can not be found, the error NoRepoFound will be returned.
	//
	// If the project is not valid for use, or there is any other issue creating
	// the Repo, Repo will be nil and an error will be returned.
	New(context.Context, *url.URL) (Repo, error)

	// Match returns true if this factory can create a new instance of Repo
	// repository for the given repository URL.
	Match(*url.URL) bool
}

Factory is used to obtain new instances of Repo.

type Repo

type Repo interface {
	URL() *url.URL
}

Repo is the core interface representing a project's source repository.

type Resolver

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

Resolver is used to resolve a Repo url against a set of Factory instances registered with the resolver.

func (*Resolver) Register

func (r *Resolver) Register(f Factory)

Register adds the factory f to the set of factories that can be used for resolving a url to a Repo.

func (*Resolver) Resolve

func (r *Resolver) Resolve(ctx context.Context, u *url.URL) (Repo, error)

Resolve takes a url u and returns a corresponding instance of Repo if a matching factory has been registered.

If a matching factory can not be found an ErrorNotFound will be returned.

The factory may also return an error.

Jump to

Keyboard shortcuts

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