modresolve

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegistryConfigSchema added in v0.8.0

func RegistryConfigSchema() string

RegistryConfigSchema returns the CUE schema for the configuration parsed by ParseConfig.

Types

type Host added in v0.8.0

type Host struct {
	// Name holds the IP host name of the registry.
	// If it's an IP v6 address, it will be surrounded with
	// square brackets ([, ]).
	Name string
	// Insecure holds whether this host should be connected
	// to insecurely (with an HTTP rather than HTTP connection).
	Insecure bool
}

Host represents a registry host name.

type Location

type Location struct {
	// Host holds the host or host:port of the registry.
	Host string

	// Insecure holds whether an insecure connection
	// should be used when connecting to the registry.
	Insecure bool

	// Repository holds the repository to store the module in.
	Repository string

	// Tag holds the tag for the module version.
	// If an empty version was passed to
	// Resolve, it holds the prefix shared by all version
	// tags for the module.
	Tag string
}

Location represents the location for a given module version or versions.

type LocationResolver added in v0.8.0

type LocationResolver interface {
	// ResolveToLocation resolves a base module path (without a version
	// suffix, a.k.a. OCI repository name) and optional version to
	// the location for that path. It reports whether it can find
	// appropriate location for the module.
	//
	// If the version is empty, the Tag in the returned Location
	// will hold the prefix that all versions of the module in its
	// repository have. That prefix will be followed by the version
	// itself.
	ResolveToLocation(path string, vers string) (Location, bool)

	// AllHosts returns all the registry hosts that the resolver
	// might resolve to, ordered lexically by hostname.
	AllHosts() []Host
}

LocationResolver resolves module paths to a location consisting of a host name of a registry and where in that registry the module is to be found.

Note: The implementation in this package operates entirely lexically, which is why Location contains only a host name and not an actual [ociregistry.Interface] implementation.

func ParseCUERegistry

func ParseCUERegistry(s string, catchAllDefault string) (LocationResolver, 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.

func ParseConfig added in v0.8.0

func ParseConfig(configFile []byte, filename string, catchAllDefault string) (LocationResolver, error)

ParseConfig parses the registry configuration with the given contents and file name. If there is no default registry, then the single registry specified in catchAllDefault will be used as a default.

Jump to

Keyboard shortcuts

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