Documentation
¶
Overview ¶
Package modconfig provides access to the standard CUE module configuration, including registry access and authorization.
Index ¶
Constants ¶
const DefaultRegistry = "registry.cue.works"
DefaultRegistry is the default registry host.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CachedRegistry ¶ added in v0.13.0
type CachedRegistry interface {
// FetchFromCache looks up the given module in the cache.
// It returns an error that satisfies [errors.Is]([modregistry.ErrNotFound]) if the
// module is not present in the cache at this version or if there
// is no cache.
FetchFromCache(mv module.Version) (module.SourceLoc, error)
}
CachedRegistry is optionally implemented by a registry that contains a cache.
type Config ¶
type Config struct {
// Transport is used to make the underlying HTTP requests.
// If it's nil, [http.DefaultTransport] will be used.
Transport http.RoundTripper
// Env provides environment variable values. If this is nil,
// the current process's environment will be used.
Env []string
// CUERegistry specifies the registry or registries to use
// to resolve modules. If it is empty, $CUE_REGISTRY
// is used.
// Experimental: this field might go away in a future version.
CUERegistry string
// ClientType is used as part of the User-Agent header
// that's added in each outgoing HTTP request.
// If it's empty, it defaults to "cuelang.org/go".
ClientType string
}
Config provides the starting point for the configuration.
type Host ¶
type Host = modresolve.Host
Host represents a registry host name and whether it should be accessed via a secure connection or not.
type HostLocation ¶
type HostLocation = modresolve.Location
HostLocation represents a registry host and a location with it.
type Registry ¶
type Registry interface {
// Requirements returns a list of the modules required by the given module
// version.
Requirements(ctx context.Context, m module.Version) ([]module.Version, error)
// Fetch returns the location of the contents for the given module
// version, downloading it if necessary.
Fetch(ctx context.Context, m module.Version) (module.SourceLoc, error)
// ModuleVersions returns all the versions for the module with the
// given path, which should contain a major version.
ModuleVersions(ctx context.Context, mpath string) ([]string, error)
}
Registry is used to access CUE modules from external sources.
func NewRegistry ¶
NewRegistry returns an implementation of the Registry interface suitable for passing to [load.Instances]. It uses the standard CUE cache directory.
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver implements modregistry.Resolver in terms of the CUE registry configuration file and auth configuration.
func NewResolver ¶
NewResolver returns an implementation of modregistry.Resolver that uses cfg to guide registry resolution. If cfg is nil, it's equivalent to passing pointer to a zero Config struct.
It consults the same environment variables used by the cue command.
The contents of the configuration will not be mutated.
func (*Resolver) AllHosts ¶
AllHosts returns all the registry hosts that the resolver might resolve to, ordered lexically by hostname.
func (*Resolver) ResolveToLocation ¶
func (r *Resolver) ResolveToLocation(mpath string, version string) (HostLocation, bool)
ResolveToLocation returns the host location for the given module path and version without creating a Registry instance for it.
func (*Resolver) ResolveToRegistry ¶
func (r *Resolver) ResolveToRegistry(mpath string, version string) (modregistry.RegistryLocation, error)
ResolveToRegistry implements modregistry.Resolver.ResolveToRegistry.