util

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildImport

func BuildImport(path string, templates map[string]string) (*build.Instance, error)

BuildImport create build.Instance with given cue templates. `path` is the cue import path for the build.Instance, like `import "example/demo"`

func FieldValues added in v1.9.0

func FieldValues(value cue.Value) []cue.Value

FieldValues the field values of the given value If the given value is a list, all its items will be returned If the given value is a map, all its key-value entries will be returned The returned values will be sorted in the order of their "step" attribute

func Iterate

func Iterate(value cue.Value, fn func(v cue.Value) (stop bool)) (stop bool)

Iterate over all fields of the cue.Value with fn, if fn returns true, iteration stops

func Print

func Print(value cue.Value, options ...PrintOption) ([]byte, error)

Print print cue.Value

func ToRawString

func ToRawString(v cue.Value, opts ...cue.Option) (string, error)

ToRawString stringify cue.Value without resolving references

func ToString

func ToString(v cue.Value, opts ...cue.Option) (string, error)

ToString stringify cue.Value with reference resolved

Types

type PrintConfig

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

PrintConfig config for printing value

func NewPrintConfig

func NewPrintConfig(options ...PrintOption) *PrintConfig

NewPrintConfig create print config

type PrintFormat

type PrintFormat string

PrintFormat format for printing cue.Value

const (
	// PrintFormatJson json
	PrintFormatJson PrintFormat = "json"
	// PrintFormatYaml yaml
	PrintFormatYaml PrintFormat = "yaml"
	// PrintFormatCue cue
	PrintFormatCue PrintFormat = "cue"
)

type PrintOption

type PrintOption interface {
	ApplyTo(*PrintConfig)
}

PrintOption options for printing value

type WithFormat

type WithFormat string

WithFormat set format for the print value

func (WithFormat) ApplyTo

func (in WithFormat) ApplyTo(cfg *PrintConfig)

ApplyTo .

type WithPath

type WithPath string

WithPath set path for the print value

func (WithPath) ApplyTo

func (in WithPath) ApplyTo(cfg *PrintConfig)

ApplyTo .

Jump to

Keyboard shortcuts

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