Documentation ¶
Index ¶
- Variables
- type DomainHeaderTransform
- type DomainPathTransform
- type DomainTransportTransform
- type GoGetTransform
- type Namespace
- type Request
- type Resolver
- 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 NewGoGetTransform(domains []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 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
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.
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 ¶
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.
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 ¶ 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 NewDomainPathTransform ¶
func NewGoGetTransform ¶
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 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.
Directories ¶
Path | Synopsis |
---|---|
Package upstreamtest contains autogenerated mocks.
|
Package upstreamtest contains autogenerated mocks. |