upstream

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2019 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPathTransforms = map[string]Transform{
	"github.com": NewDomainPathTransform("ELEM1/ELEM2/archive/VERSION.zip"),
	"gitlab.com": NewDomainPathTransform("ELEM1/ELEM2/-/archive/VERSION/ELEM2-VERSION.zip"),
	"":           NewDomainPathTransform(""),
}

DefaultPathTransforms provides a set of default Transform types which create the Request.Path for a known set of VCSs systems in the open source world (i.e. github and gitlab). Additional Transforms should be specified via NewSetPathTransform, which accepts a map of domain to Transform, for internally hosed code.

Functions

This section is empty.

Types

type DomainHeaderTransform

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

A DomainHeaderTransform is used to set the header for a request. Typically one of these will be used to set the authentication key for https requests to an internal VCS system.

func (*DomainHeaderTransform) Modify

func (t *DomainHeaderTransform) Modify(r *Request) (*Request, error)

type DomainPathTransform

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

A DomainPathTransform is used to generate or rewrite the URL path of the module archive that is to be fetched per the domain of desired module of the Request. Default path rewriting rules are provided for repositories ultimately hosted in github or gitlab. Additional path transformations should be defined for internally hosed VCSs.

e.g. github:

https://github.com/ELEM1/ELEM2/archive/VERSION.zip

e.g. gitlab:

https://gitlab.com/ELEM1/ELEM2/-/archive/VERSOIN/ELEM2-v2.0.1.zip

func (*DomainPathTransform) Modify

func (t *DomainPathTransform) Modify(r *Request) (*Request, error)

type DomainTransportTransform

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

func (*DomainTransportTransform) Modify

func (t *DomainTransportTransform) Modify(r *Request) (*Request, error)

type GoGetTransform

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

The GoGetTransform triggers an http request to the domain to simply do a "?go-get=1" lookup for the real domain of where the module is being hosted.

Additional domains can be specified via configuration. The known go-get redirectors in the wild include: - golang.org - google.golang.org - cloud.google.com - gopkg.in - contrib.go.opencensus.io - go.uber.org

func (*GoGetTransform) Modify

func (t *GoGetTransform) Modify(r *Request) (*Request, error)

type Namespace

type Namespace []string

type Request

type Request struct {
	Transport     string
	Domain        string
	Namespace     Namespace
	Version       string
	Path          string
	GoGetRedirect bool
	Headers       map[string]string
}

func NewRequest

func NewRequest(mod coordinates.Module) (*Request, error)

NewRequest creates a default Request from the given module. This initial Request is likely useless, as it only becomes useful after a set of Transform operations are applied to it, which then compute correct URI for the module it represents.

func (*Request) String

func (r *Request) String() string

func (*Request) URI

func (r *Request) URI() string

The URI is only valid AFTER a Request has passed through all of the Transform functors.

type Resolver

type Resolver interface {
	// Resolve applies any underlying Transform operations
	// and returns the resulting Request, or an error if
	// one of the Transform operations does not work.
	Resolve(coordinates.Module) (*Request, error)
}

A Resolver is able to turn the globally unique identifier of a Go module (which includes a Source and a Version) and applies a set of Transform operations until a Request is created that can later be used to fetch the module from some source, which is typically a VCS host (e.g. github).

func NewResolver

func NewResolver(transforms ...Transform) Resolver

NewResolver creates a Resolver which will apply the given set of Transform operations in the order in which they appear.

type SetPathTransform

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

A SetPathTransform is a collection of transforms which set the Path of a Request given a domain. Think of it as a map from a domain to a DomainPathTransform, which can be used in the general case rather than specifying an explicit list of DomainPathTransform.

func (*SetPathTransform) Modify

func (t *SetPathTransform) Modify(r *Request) (*Request, error)

type StaticRedirectTransform

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

A StaticRedirectTransform is used to directly convert one domain to another. For example, if your organization internally keeps packages organized like

${GOPATH}/company/...

but the internal VCS is only addressable in a way like

code.internal.company.net/...

then the StaticRedirectTransform can be used to automatically acquire modules prefixed with name "company/" from the internal VCS of the different domain name.

func (*StaticRedirectTransform) Modify

func (t *StaticRedirectTransform) Modify(r *Request) (*Request, error)

type Transform

type Transform interface {
	Modify(*Request) (*Request, error)
}

A Transform is one operation that is applied to a Request, which creates a new Request with zero or more parameters of the input Request having been modified. A Transform can be used to handle things like static domain name redirection, indirect domain name redirect (i.e. accommodate go-get meta URIs), domain-based path rewriting, etc.

As time goes on, more and more Transform implementations will be added, to support additional use cases for enterprise environments which tend to have special needs.

func NewAutomaticGoGetTransform added in v0.0.11

func NewAutomaticGoGetTransform() Transform

NewAutomaticGoGetTransform creates a GoGetTransform where any module URI will be redirected to wherever the go-get meta HTML tag in the domain indicates.

func NewDomainHeaderTransform

func NewDomainHeaderTransform(domain string, headers map[string]string) Transform

func NewDomainPathTransform

func NewDomainPathTransform(pathFmt string) Transform

func NewDomainTransportTransform

func NewDomainTransportTransform(domain, transport string) Transform

func NewGoGetTransform

func NewGoGetTransform(domains []string) Transform

NewGoGetTransform creates a GoGetTransform where any module URIs found in the given list of domains will be first redirected to wherever the go-get meta HTML tag in the domain indicates.

Read more about this functionality here:

https://golang.ir/cmd/go/#hdr-Remote_import_paths

func NewSetPathTransform

func NewSetPathTransform(customDomainPathTransforms map[string]Transform) Transform

func NewStaticRedirectTransform

func NewStaticRedirectTransform(original, substitution string) Transform

NewStaticRedirectTransform creates a Transform which will convert domains of the original name to become the substitution name.

Currently only exact matches on the domain are supported.

Directories

Path Synopsis
Package upstreamtest contains autogenerated mocks.
Package upstreamtest contains autogenerated mocks.

Jump to

Keyboard shortcuts

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