Documentation ¶
Index ¶
- func AsModFS(in fs.FS, modname string) fs.FS
- func InstanceWithThema(modFS fs.FS, dir string, opts ...Option) (*build.Instance, error)
- func InstancesWithThema(modFS fs.FS, dir string, opts ...Option) (*build.Instance, error)
- func ToOverlay(prefix string, vfs fs.FS, overlay map[string]load.Source) error
- type ErrFSNotACueModule
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AsModFS ¶
AsModFS injects a cue.mod/module.cue file into the provided in fs.FS at its root, preparing it for use by
If a cue.mod already exists in the provided fs.FS, this func is a no-op.
func InstanceWithThema ¶
InstanceWithThema wraps CUE's load.Instance in order to allow loading .cue files that directly `import "github.com/grafana/thema"`, as lineages are expected to. This is accomplished by constructing a load.Config.Overlay with the Thema CUE files dynamically injected under cue.mod/pkg/, where CUE searches for mod-external imports.
This loader is opinionated, preferring simple ease-of-use and fewer degrees of freedom to the completeness of load.Instances. Some reasonable use cases may not be achievable. Make your own as needed - all key component parts are exported from elsewhere in the Thema Go module.
The modFS is expected to be an fs.FS containing the cue.mod module metadata, and any lineage(s) to be loaded.
The root of the FS must be an importable CUE module with a path. That is, there must exist cue.mod/module.cue, which must contain a top-level field declaring the module name (aka import prefix/module path), e.g.:
module: "github.com/grafana/thema"
The dir parameter must specify a directory containing .cue files with lineages to be loaded, relative to the module root directory. This is similar to load.Config.Dir, except:
- The package name of the root dir is the final element of the module name, unless overridden with a Package option.
- "." and the empty string are a special value that will load the root directory of the modFS.
NOTE - this function is likely to be deprecated and removed in favor of a more generic dependency overlay loader.
func InstancesWithThema ¶
InstancesWithThema passes through to InstanceWithThema. DEPRECATED: use InstanceWithThema.
Types ¶
type ErrFSNotACueModule ¶
type ErrFSNotACueModule struct {
// contains filtered or unexported fields
}
ErrFSNotACueModule is a general error that wraps a particular error that explains why a particular fs.FS cannot be used as a CUE module FS as needed by InstancesWithThema.
func (*ErrFSNotACueModule) Error ¶
func (e *ErrFSNotACueModule) Error() string
func (*ErrFSNotACueModule) Unwrap ¶
func (e *ErrFSNotACueModule) Unwrap() error