Documentation
¶
Index ¶
- Variables
- type DomainHeaderTransform
- type DomainPathTransform
- type DomainTransportTransform
- type GoGetTransform
- type Namespace
- type Request
- type Resolver
- type ResolverMock
- func (m *ResolverMock) MinimockFinish()
- func (m *ResolverMock) MinimockResolveDone() bool
- func (m *ResolverMock) MinimockResolveInspect()
- func (m *ResolverMock) MinimockUseProxyDone() bool
- func (m *ResolverMock) MinimockUseProxyInspect()
- func (m *ResolverMock) MinimockWait(timeout mm_time.Duration)
- func (mmResolve *ResolverMock) Resolve(m1 coordinates.Module) (rp1 *Request, err error)
- func (mmResolve *ResolverMock) ResolveAfterCounter() uint64
- func (mmResolve *ResolverMock) ResolveBeforeCounter() uint64
- func (mmUseProxy *ResolverMock) UseProxy(m1 coordinates.Module) (b1 bool, err error)
- func (mmUseProxy *ResolverMock) UseProxyAfterCounter() uint64
- func (mmUseProxy *ResolverMock) UseProxyBeforeCounter() uint64
- type ResolverMockResolveExpectation
- type ResolverMockResolveParams
- type ResolverMockResolveResults
- type ResolverMockUseProxyExpectation
- type ResolverMockUseProxyParams
- type ResolverMockUseProxyResults
- type SetPathTransform
- type StaticRedirectTransform
- type Transform
- func NewAutomaticGoGetTransform() Transform
- func NewDomainHeaderTransform(domain string, headers map[string]string) Transform
- func NewDomainPathTransform(pathFmt string) Transform
- func NewDomainTransportTransform(domain, transport string) Transform
- func NewSetPathTransform(customDomainPathTransforms map[string]Transform) Transform
- func NewStaticRedirectTransform(original, substitution string) Transform
Constants ¶
This section is empty.
Variables ¶
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.
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
type DomainTransportTransform ¶
type DomainTransportTransform struct {
// contains filtered or unexported fields
}
type GoGetTransform ¶
type GoGetTransform struct {
// contains filtered or unexported fields
}
The GoGetTransform is no longer configurable, it will always automatically do go-get=1 requests, following the redirect as the Go documentation specifies.
type Namespace ¶
type Namespace []string
Namespace is the path elements leading up to the package name of a module.
type Request ¶
type Request struct { Transport string Domain string Namespace Namespace Version string Path string GoGetRedirect bool Headers map[string]string }
A Request for a git-archive of a module.
A Request should only be used in the context of acquiring a module archive from an upstream source (e.g. github, gitlab, etc.) as opposed to acquiring a module from a proxy.
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) Equals ¶ added in v0.6.0
An explicit implementation of equality between two Request objects.
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) // UseProxy indicates whether Module can be downloaded from a generic open // global proxy (e.g. proxy.golang.org) instead of the original upstream // source (e.g. github / gitlab). This is going to be true for any Module // which does not get matched by any configured domain type Transform. The // rational is that any domain type Transform is a flag that the module is // not going to be present an the open source context, and the original // upstream must be used since it is likely a private repository. // // The transforms that prohibit proxy use are: // - StaticRedirectTransform // - DomainTransportTransform // - DomainHeaderTransform UseProxy(coordinates.Module) (bool, 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 ¶
NewResolver creates a Resolver which will apply the given set of Transform operations in the order in which they appear.
type ResolverMock ¶
type ResolverMock struct { ResolveMock mResolverMockResolve UseProxyMock mResolverMockUseProxy // contains filtered or unexported fields }
ResolverMock implements Resolver
func NewResolverMock ¶
func NewResolverMock(t minimock.Tester) *ResolverMock
NewResolverMock returns a mock for Resolver
func (*ResolverMock) MinimockFinish ¶
func (m *ResolverMock) MinimockFinish()
MinimockFinish checks that all mocked methods have been called the expected number of times
func (*ResolverMock) MinimockResolveDone ¶
func (m *ResolverMock) MinimockResolveDone() bool
MinimockResolveDone returns true if the count of the Resolve invocations corresponds the number of defined expectations
func (*ResolverMock) MinimockResolveInspect ¶
func (m *ResolverMock) MinimockResolveInspect()
MinimockResolveInspect logs each unmet expectation
func (*ResolverMock) MinimockUseProxyDone ¶ added in v0.6.0
func (m *ResolverMock) MinimockUseProxyDone() bool
MinimockUseProxyDone returns true if the count of the UseProxy invocations corresponds the number of defined expectations
func (*ResolverMock) MinimockUseProxyInspect ¶ added in v0.6.0
func (m *ResolverMock) MinimockUseProxyInspect()
MinimockUseProxyInspect logs each unmet expectation
func (*ResolverMock) MinimockWait ¶
func (m *ResolverMock) MinimockWait(timeout mm_time.Duration)
MinimockWait waits for all mocked methods to be called the expected number of times
func (*ResolverMock) Resolve ¶
func (mmResolve *ResolverMock) Resolve(m1 coordinates.Module) (rp1 *Request, err error)
Resolve implements Resolver
func (*ResolverMock) ResolveAfterCounter ¶
func (mmResolve *ResolverMock) ResolveAfterCounter() uint64
ResolveAfterCounter returns a count of finished ResolverMock.Resolve invocations
func (*ResolverMock) ResolveBeforeCounter ¶
func (mmResolve *ResolverMock) ResolveBeforeCounter() uint64
ResolveBeforeCounter returns a count of ResolverMock.Resolve invocations
func (*ResolverMock) UseProxy ¶ added in v0.6.0
func (mmUseProxy *ResolverMock) UseProxy(m1 coordinates.Module) (b1 bool, err error)
UseProxy implements Resolver
func (*ResolverMock) UseProxyAfterCounter ¶ added in v0.6.0
func (mmUseProxy *ResolverMock) UseProxyAfterCounter() uint64
UseProxyAfterCounter returns a count of finished ResolverMock.UseProxy invocations
func (*ResolverMock) UseProxyBeforeCounter ¶ added in v0.6.0
func (mmUseProxy *ResolverMock) UseProxyBeforeCounter() uint64
UseProxyBeforeCounter returns a count of ResolverMock.UseProxy invocations
type ResolverMockResolveExpectation ¶
type ResolverMockResolveExpectation struct { Counter uint64 // contains filtered or unexported fields }
ResolverMockResolveExpectation specifies expectation struct of the Resolver.Resolve
func (*ResolverMockResolveExpectation) Then ¶
func (e *ResolverMockResolveExpectation) Then(rp1 *Request, err error) *ResolverMock
Then sets up Resolver.Resolve return parameters for the expectation previously defined by the When method
type ResolverMockResolveParams ¶
type ResolverMockResolveParams struct {
// contains filtered or unexported fields
}
ResolverMockResolveParams contains parameters of the Resolver.Resolve
type ResolverMockResolveResults ¶
type ResolverMockResolveResults struct {
// contains filtered or unexported fields
}
ResolverMockResolveResults contains results of the Resolver.Resolve
type ResolverMockUseProxyExpectation ¶ added in v0.6.0
type ResolverMockUseProxyExpectation struct { Counter uint64 // contains filtered or unexported fields }
ResolverMockUseProxyExpectation specifies expectation struct of the Resolver.UseProxy
func (*ResolverMockUseProxyExpectation) Then ¶ added in v0.6.0
func (e *ResolverMockUseProxyExpectation) Then(b1 bool, err error) *ResolverMock
Then sets up Resolver.UseProxy return parameters for the expectation previously defined by the When method
type ResolverMockUseProxyParams ¶ added in v0.6.0
type ResolverMockUseProxyParams struct {
// contains filtered or unexported fields
}
ResolverMockUseProxyParams contains parameters of the Resolver.UseProxy
type ResolverMockUseProxyResults ¶ added in v0.6.0
type ResolverMockUseProxyResults struct {
// contains filtered or unexported fields
}
ResolverMockUseProxyResults contains results of the Resolver.UseProxy
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.
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.
type Transform ¶
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 ¶
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 NewDomainPathTransform ¶
func NewSetPathTransform ¶
func NewStaticRedirectTransform ¶
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.