Documentation
¶
Index ¶
- func BuildCUEFromBytes(data []byte) (cue.Value, error)
- func FormatCUEDefinitions(val cue.Value) []byte
- func ImportPathForModule(modPath string) string
- func IsJSONSchema(data []byte) bool
- func IsMajorOnly(v string) bool
- func SplitModuleVersion(input string) (string, string)
- type CUELoader
- type EmbeddedLoader
- type FileLoader
- type LegacyLoader
- type Loader
- type Registry
- type Schema
- type SchemaFormat
- type URLLoader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildCUEFromBytes ¶
BuildCUEFromBytes compiles CUE bytes into a cue.Value.
func FormatCUEDefinitions ¶
FormatCUEDefinitions extracts top-level definitions from a CUE value and formats them as readable CUE syntax.
func ImportPathForModule ¶
ImportPathForModule returns the CUE import path for a module path.
func IsJSONSchema ¶
IsJSONSchema returns true if the data looks like JSON (starts with '{').
func IsMajorOnly ¶
IsMajorOnly returns true if v matches "v0", "v1", "v2", etc.
func SplitModuleVersion ¶
SplitModuleVersion separates a module path from its version.
Types ¶
type CUELoader ¶
type CUELoader struct{}
CUELoader loads schemas from the CUE Central Registry.
type EmbeddedLoader ¶
type EmbeddedLoader struct{}
EmbeddedLoader loads schemas from built-in embedded files.
func (*EmbeddedLoader) Match ¶
func (l *EmbeddedLoader) Match(source string) bool
type FileLoader ¶
type FileLoader struct{}
FileLoader loads schemas from file:// URIs.
func (*FileLoader) Match ¶
func (l *FileLoader) Match(source string) bool
type LegacyLoader ¶
type LegacyLoader struct{}
LegacyLoader handles bare file paths without any scheme prefix.
func (*LegacyLoader) Match ¶
func (l *LegacyLoader) Match(source string) bool
type Loader ¶
type Loader interface {
Match(source string) bool
Load(ctx context.Context, source string, platform string) (*Schema, error)
}
Loader loads a schema from a source string.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds an ordered list of loaders and dispatches to the first match.
func DefaultRegistry ¶
func DefaultRegistry() *Registry
DefaultRegistry returns a registry with all built-in loaders in priority order.
func NewRegistry ¶
NewRegistry creates a Registry with the given loaders.
type Schema ¶
Schema holds a loaded platform schema with both raw bytes (for serving) and compiled CUE (for validation).
type SchemaFormat ¶
type SchemaFormat int
SchemaFormat identifies the schema file format.
const ( FormatUnknown SchemaFormat = iota FormatJSON FormatCUE )
func DetectFormat ¶
func DetectFormat(path string) SchemaFormat
DetectFormat determines the schema format from file extension.