compiler

package
v0.2.36 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2022 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultCompiler = New()

DefaultCompiler is the default Compiler and is used by Compile

Functions

func Err

func Err(err error) error

Types

type Compiler

type Compiler struct {
	*cue.Context
	// contains filtered or unexported fields
}

Polyfill for a cue runtime (we call it compiler to avoid confusion with dagger runtime) Use this instead of cue.Runtime

func New

func New() *Compiler

func (*Compiler) Compile

func (c *Compiler) Compile(name string, src string) (*Value, error)

func (*Compiler) DecodeJSON

func (c *Compiler) DecodeJSON(path string, data []byte) (*Value, error)

func (*Compiler) DecodeYAML

func (c *Compiler) DecodeYAML(path string, data []byte) (*Value, error)

func (*Compiler) Err

func (c *Compiler) Err(err error) error

func (*Compiler) ErrInstance added in v0.2.22

func (c *Compiler) ErrInstance(err error, i *build.Instance) error

func (*Compiler) NewValue

func (c *Compiler) NewValue() *Value

Compile an empty value

func (*Compiler) Wrap

func (c *Compiler) Wrap(v cue.Value) *Value

type ErrorInstance added in v0.2.22

type ErrorInstance struct {
	Err      error
	Instance *build.Instance
	// contains filtered or unexported fields
}

func (ErrorInstance) Error added in v0.2.22

func (e ErrorInstance) Error() string

type Field

type Field struct {
	Selector cue.Selector
	Value    *Value

	IsOptional bool
}

Field represents a struct field

func (Field) Label

func (f Field) Label() string

Label returns the unquoted selector

type JSON

type JSON []byte

func (JSON) Get

func (s JSON) Get(path ...string) ([]byte, error)

func (JSON) PrettyString

func (s JSON) PrettyString() string

func (JSON) Set

func (s JSON) Set(valueJSON []byte, path ...string) (JSON, error)

func (JSON) String

func (s JSON) String() string

func (JSON) Unset

func (s JSON) Unset(path ...string) (JSON, error)

type Value

type Value struct {
	// contains filtered or unexported fields
}

Value is a wrapper around cue.Value. Use instead of cue.Value and cue.Instance

func Build

func Build(ctx context.Context, src string, overlays map[string]fs.FS, args ...string) (*Value, error)

Build a cue configuration tree from the files in fs.

func Compile

func Compile(name string, src string) (*Value, error)

func DecodeJSON

func DecodeJSON(path string, data []byte) (*Value, error)

func DecodeYAML

func DecodeYAML(path string, data []byte) (*Value, error)

func NewValue

func NewValue() *Value

func Wrap

func Wrap(v cue.Value) *Value

FIXME can be refactored away now?

func (*Value) AbsPath

func (v *Value) AbsPath() (string, error)

AbsPath returns an absolute path contained in Value Paths are relative to the CUE file they were declared in.

func (*Value) Bool

func (v *Value) Bool() (bool, error)

Proxy function to the underlying cue.Value

func (*Value) Bytes

func (v *Value) Bytes() ([]byte, error)

Proxy function to the underlying cue.Value

func (*Value) Cue

func (v *Value) Cue() cue.Value

func (*Value) Decode

func (v *Value) Decode(x interface{}) error

Proxy function to the underlying cue.Value

func (*Value) Default

func (v *Value) Default() (*Value, bool)

func (*Value) Dereference

func (v *Value) Dereference() *Value

func (*Value) Dirname

func (v *Value) Dirname() (string, error)

Dirname returns the CUE dirname where the value was defined

func (*Value) Doc

func (v *Value) Doc() []*ast.CommentGroup

func (*Value) DocSummary added in v0.2.1

func (v *Value) DocSummary() string

DocSummary returns the first line of documentation

func (*Value) Exists

func (v *Value) Exists() bool

Proxy function to the underlying cue.Value

func (*Value) Expr added in v0.2.8

func (v *Value) Expr() (cue.Op, []*Value)

Proxy function to the underlying cue.Value

func (*Value) Fields

func (v *Value) Fields(opts ...cue.Option) ([]Field, error)

Proxy function to the underlying cue.Value Field ordering is guaranteed to be stable.

func (*Value) Filename

func (v *Value) Filename() (string, error)

Filename returns the CUE filename where the value was defined

func (*Value) Fill added in v0.2.0

func (v *Value) Fill(value interface{}) (*Value, error)

Fill updates a value, in place

func (*Value) FillFields

func (v *Value) FillFields(values map[string]interface{}) (*Value, error)

FillFields fills multiple fields, in place

func (*Value) FillPath

func (v *Value) FillPath(p cue.Path, x interface{}) error

FillPath fills the value in-place

func (*Value) HasAttr

func (v *Value) HasAttr(filter ...string) bool

Returns true if value has a dagger attribute (eg. artifact, secret, input)

func (*Value) IncompleteKind

func (v *Value) IncompleteKind() cue.Kind

Proxy function to the underlying cue.Value

func (*Value) Int64

func (v *Value) Int64() (int64, error)

Proxy function to the underlying cue.Value

func (*Value) IsConcrete

func (v *Value) IsConcrete() bool

func (*Value) IsConcreteR

func (v *Value) IsConcreteR(opts ...cue.Option) error

Recursive concreteness check.

func (*Value) IsReference added in v0.2.11

func (v *Value) IsReference() bool

func (*Value) JSON

func (v *Value) JSON() JSON

Export concrete values to JSON. ignoring non-concrete values. Contrast with cue.Value.MarshalJSON which requires all values to be concrete.

func (*Value) Kind

func (v *Value) Kind() cue.Kind

Proxy function to the underlying cue.Value

func (*Value) Len

func (v *Value) Len() cue.Value

Proxy function to the underlying cue.Value

func (*Value) List

func (v *Value) List() ([]*Value, error)

func (*Value) Lookup

func (v *Value) Lookup(path string) *Value

Lookup is a helper function to lookup by path parts.

func (*Value) LookupPath

func (v *Value) LookupPath(p cue.Path) *Value

LookupPath is a concurrency safe wrapper around cue.Value.LookupPath

func (*Value) Path

func (v *Value) Path() cue.Path

Proxy function to the underlying cue.Value

func (*Value) Pos added in v0.2.8

func (v *Value) Pos() token.Pos

func (*Value) ReferencePath

func (v *Value) ReferencePath() (*Value, cue.Path)

func (*Value) Source

func (v *Value) Source(opts ...cue.Option) ([]byte, error)

Return cue source for this value

func (*Value) String

func (v *Value) String() (string, error)

Proxy function to the underlying cue.Value

func (*Value) Struct

func (v *Value) Struct() (*cue.Struct, error)

Proxy function to the underlying cue.Value

func (*Value) Validate

func (v *Value) Validate(opts ...cue.Option) error

Check that a value is valid. Optionally check that it matches all the specified spec definitions..

func (*Value) Walk

func (v *Value) Walk(before func(*Value) bool, after func(*Value))

Jump to

Keyboard shortcuts

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