Documentation ¶
Overview ¶
Implements loading of Namespace-specific dialect of Cue which includes: * a Golang-like module system where modules are loaded from source transparently when needed; * support for @fn() attributes allowing to access runtime data from the environment.
Index ¶
- Constants
- func CollectImports(ctx context.Context, resolver WorkspaceLoader, pkgname string, ...) error
- func DecodeToTypedProtoMessage[V proto.Message](v *CueV) (V, error)
- func Format(ctx context.Context, fsfs fnfs.ReadWriteFS, loc fnfs.Location, name string, ...) error
- func FormatSource(loc fnerrors.Location, w io.Writer, contents []byte) error
- func IsStandardImportPath(path string) bool
- func SerializedEval[V any](p *Partial, f func() (V, error)) (V, error)
- func SerializedEval3[V any, T any](p *Partial, f func() (V, T, error)) (V, T, error)
- func WalkAttrs(parent cue.Value, visit func(v cue.Value, key, value string) error) error
- func WrapCueError(e error, absPath func(string) string) error
- type CuePackage
- type CueV
- type EvalCtx
- type KeyAndPath
- type Location
- type PackageContents
- type Partial
- type Root
- type WorkspaceLoader
Constants ¶
const ( InputKeyword = "input" AllocKeyword = "alloc" PackageIKW = "package" ServerDepIKw = "server_dep" ImageIKw = "image" VCSIKw = "vcs" WorkspaceIKw = "workspace" ProtoloadIKw = "protoload" ServerPortAllocKw = "port" ResourceIKw = "resource" )
Variables ¶
This section is empty.
Functions ¶
func CollectImports ¶
func CollectImports(ctx context.Context, resolver WorkspaceLoader, pkgname string, m map[string]*CuePackage) error
Fills [m] with the transitive closure of packages and files imported by package [pkgname]. TODO: Use [snapshotCache] instead of re-parsing all packages directly.
func DecodeToTypedProtoMessage ¶ added in v0.0.72
func Format ¶
func Format(ctx context.Context, fsfs fnfs.ReadWriteFS, loc fnfs.Location, name string, opts fnfs.WriteFileExtendedOpts) error
func IsStandardImportPath ¶
func SerializedEval3 ¶
Types ¶
type CuePackage ¶
type CuePackage struct { *PackageContents Files []string // Relative to RelPath Imports []string // Top level import statements. }
Represents an unparsed Cue package.
func (CuePackage) RelFiles ¶
func (pkg CuePackage) RelFiles() []string
type CueV ¶
func (*CueV) DecodeAs ¶
func (v *CueV) DecodeAs(msgtype protoreflect.MessageType) (proto.Message, error)
func (*CueV) LookupPath ¶
type EvalCtx ¶
type EvalCtx struct {
// contains filtered or unexported fields
}
Entry point to load Cue packages from a Namespace workspace.
func NewEvalCtx ¶
func NewEvalCtx(loader WorkspaceLoader, scope any) *EvalCtx
If set, "scope" are passed as a "Scope" BuildOption to "BuildInstance".
type KeyAndPath ¶
type PackageContents ¶
type Partial ¶
type Partial struct { CueV Ctx *snapshotCache Left []KeyAndPath Package CuePackage CueImports []CuePackage }
Represents a Cue value alongside a list of keys that are *left* to be resolved and filled later.
type WorkspaceLoader ¶
type WorkspaceLoader interface {
SnapshotDir(context.Context, schema.PackageName, memfs.SnapshotOpts) (*PackageContents, error)
}