modresolve

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Location

type Location struct {
	// Host holds the host or host:port of the registry.
	Host string
	// Prefix holds a prefix to be added to the path.
	Prefix string
	// Insecure holds whether an insecure connection
	// should be used when connecting to the registry.
	Insecure bool
}

Location represents the location for a given path.

type Resolver

type Resolver interface {
	Resolve(path string) Location
}

Resolve resolves a module path (a.k.a. OCI repository name) to the location for that path. Invalid paths will map to the default location.

func ParseCUERegistry

func ParseCUERegistry(s string, catchAllDefault string) (Resolver, error)

ParseCUERegistry parses a registry routing specification that maps module prefixes to the registry that should be used to fetch that module.

The specification consists of an order-independent, comma-separated list.

Each element either maps a module prefix to the registry that will be used for all modules that have that prefix (prefix=registry), or a catch-all registry to be used for modules that do not match any prefix (registry).

For example:

myorg.com=myregistry.com/m,catchallregistry.example.org

Any module with a matching prefix will be routed to the given registry. A prefix only matches whole path elements. In the above example, module myorg.com/foo/bar@v0 will be looked up in myregistry.com in the repository m/myorg.com/foo/bar, whereas github.com/x/y will be looked up in catchallregistry.example.com.

The registry part is syntactically similar to a docker reference except that the repository is optional and no tag or digest is allowed. Additionally, a +secure or +insecure suffix may be used to indicate whether to use a secure or insecure connection. Without that, localhost, 127.0.0.1 and [::1] will default to insecure, and anything else to secure.

If s does not declare a catch-all registry location, catchAllDefault is used. It is an error if s fails to declares a catch-all registry location and no catchAllDefault is provided.

Jump to

Keyboard shortcuts

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