cuetils

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2022 License: BSD-3-Clause Imports: 25 Imported by: 0

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

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

TODO, improve merge strategy

func CueErrorToString

func CueErrorToString(err error) string

func CueSyntax

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

func ExpandCueError

func ExpandCueError(err error) error

func FindModuleAbsPath

func FindModuleAbsPath() (string, error)

func FormatCue

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

func FormatOutput

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

func PrintAttr

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

func PrintCue

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

func PrintCueError

func PrintCueError(err error)

func PrintCueValue

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 ValueToSyntaxString

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

	CueInstance *cue.Instance
	CueValue    cue.Value
	Value       interface{}
}

func CueRuntimeFromEntrypoints

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

CueRuntimeFromArgs builds up a CueRuntime

by processing the args passed in

func CueRuntimeFromEntrypointsAndFlags

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

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

func (*CueRuntime) Load

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

func (*CueRuntime) ParseCueExpr

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

func (*CueRuntime) PrintCueErrors

func (CR *CueRuntime) PrintCueErrors()

func (*CueRuntime) PrintValue

func (CRT *CueRuntime) PrintValue() error

type CueSyntaxOptions

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

func (CueSyntaxOptions) MakeOpts

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

type KeyVal

type KeyVal struct {
	Key string
	Val cue.Value
}

func GetByAttrKeys

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

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

type TestSuite

type TestSuite struct {
	suite.Suite

	Op TestOpFunc

	CRT *CueRuntime

	TestdataDirs []string
	Entrypoints  []string
}

func NewTestSuite

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

func (*TestSuite) DoTestOp

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

func (*TestSuite) RunCase

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

func (*TestSuite) RunCases

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

func (*TestSuite) RunGroup

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

func (*TestSuite) RunTestCase

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

func (*TestSuite) SetupCue

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

func (*TestSuite) SetupEntrypoints

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

Jump to

Keyboard shortcuts

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