cuetils

package
v0.6.9-alpha.11 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2023 License: Apache-2.0 Imports: 26 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DEFAULT_TESTDATA_DIRS = []string{"testdata"}
View Source
var (
	DefaultSyntaxOpts = CueSyntaxOptions{
		Attributes:  true,
		Concrete:    false,
		Definitions: true,
		Docs:        true,
		Hidden:      true,
		Optional:    true,
	}
)

Functions

func AttrToMap added in v0.5.17

func AttrToMap(A cue.Attribute) (m map[string]string)

TODO, improve merge strategy

func CueErrorToString added in v0.6.1

func CueErrorToString(err error) string

func CueSyntax added in v0.5.4

func CueSyntax(val cue.Value, opts []cue.Option) ast.Node

func ExpandCueError added in v0.6.1

func ExpandCueError(err error) error

func FindModuleAbsPath added in v0.6.1

func FindModuleAbsPath(dir string) (string, error)

func FormatCue added in v0.6.2

func FormatCue(val cue.Value) (string, error)

func FormatOutput added in v0.6.2

func FormatOutput(val cue.Value, format string) (string, error)

func PrintAttr added in v0.6.2

func PrintAttr(attr cue.Attribute, val cue.Value) error

func PrintCue added in v0.6.2

func PrintCue(val cue.Value) (string, error)

func PrintCueError added in v0.5.4

func PrintCueError(err error)

func PrintCueValue added in v0.5.4

func PrintCueValue(val cue.Value) (string, error)

func RunDefFromArgs

func RunDefFromArgs(args []string) error

func RunEvalFromArgs

func RunEvalFromArgs(args []string) error

func RunExportFromArgs

func RunExportFromArgs(args []string) error

func RunTrimFromArgs

func RunTrimFromArgs(args []string) error

func RunVetFromArgs

func RunVetFromArgs(args []string) error

func ToFile added in v0.6.9

func ToFile(n ast.Node) *ast.File

func ValueToSyntaxString added in v0.5.4

func ValueToSyntaxString(val cue.Value, opts ...cue.Option) (string, error)

Types

type CueRuntime

type CueRuntime struct {
	Entrypoints []string
	Workspace   string
	FS          billy.Filesystem

	CueContext     *cue.Context
	CueConfig      *load.Config
	BuildInstances []*build.Instance
	CueErrors      []error
	FieldOpts      []cue.Option

	IncludeData bool

	CueInstance *cue.Instance
	CueValue    cue.Value
	Value       interface{}
	// contains filtered or unexported fields
}

func CueRuntimeFromEntrypoints added in v0.5.4

func CueRuntimeFromEntrypoints(entrypoints []string) (crt *CueRuntime, err error)

CueRuntimeFromArgs builds up a CueRuntime

by processing the args passed in

func CueRuntimeFromEntrypointsAndFlags added in v0.5.4

func CueRuntimeFromEntrypointsAndFlags(entrypoints []string) (crt *CueRuntime, err error)

CueRuntimeFromArgsAndFlags builds up a CueRuntime

by processing the args passed in AND the current flag values

func (*CueRuntime) ConvertToValue added in v0.5.4

func (CRT *CueRuntime) ConvertToValue(in interface{}) (cue.Value, error)

func (*CueRuntime) Load

func (CRT *CueRuntime) Load() (err error)

func (*CueRuntime) ParseCueExpr added in v0.5.4

func (CRT *CueRuntime) ParseCueExpr(expr string) (cue.Value, error)

func (*CueRuntime) PrintCueErrors added in v0.5.4

func (CR *CueRuntime) PrintCueErrors()

func (*CueRuntime) PrintValue

func (CRT *CueRuntime) PrintValue() error

type CueSyntaxOptions added in v0.5.4

type CueSyntaxOptions struct {
	Attributes  bool
	Concrete    bool
	Definitions bool
	Docs        bool
	Hidden      bool
	Optional    bool
}

func (CueSyntaxOptions) MakeOpts added in v0.5.4

func (CSO CueSyntaxOptions) MakeOpts() []cue.Option

type KeyVal added in v0.5.7

type KeyVal struct {
	Key string
	Val cue.Value
}

func GetByAttrKeys added in v0.5.7

func GetByAttrKeys(val cue.Value, attr string, all, any []string) ([]KeyVal, error)

GetByAttrAndKeys extracts fields from a value by attribute and key names if all or any is empty, the condition check is skipped and all values will pass so to get all values with an attribute, with no concern for the contents, use:

GetByAttrAndKeys(val, "myattr", []string{}, []string{})

TODO, change this to return map[string]cue.Value

type TestOpFunc added in v0.5.4

type TestOpFunc func(name string, args cue.Value) (cue.Value, error)

type TestSuite added in v0.5.4

type TestSuite struct {
	suite.Suite

	Op TestOpFunc

	CRT *CueRuntime

	TestdataDirs []string
	Entrypoints  []string
}

func NewTestSuite added in v0.5.4

func NewTestSuite(testdirs []string, op TestOpFunc) *TestSuite

func (*TestSuite) DoTestOp added in v0.5.4

func (TS *TestSuite) DoTestOp(name string, args cue.Value) (cue.Value, error)

func (*TestSuite) RunCase added in v0.5.4

func (TS *TestSuite) RunCase(path string) (err error)

func (*TestSuite) RunCases added in v0.5.4

func (TS *TestSuite) RunCases(paths []string) (err error)

func (*TestSuite) RunGroup added in v0.5.4

func (TS *TestSuite) RunGroup(cases, group string, V cue.Value) (err error)

func (*TestSuite) RunTestCase added in v0.5.4

func (TS *TestSuite) RunTestCase(cases, group, test string, V cue.Value) (err error)

func (*TestSuite) SetupCue added in v0.5.4

func (TS *TestSuite) SetupCue() (err error)

func (*TestSuite) SetupEntrypoints added in v0.5.4

func (TS *TestSuite) SetupEntrypoints() (err error)

Jump to

Keyboard shortcuts

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