builder

package
v0.0.0-...-3a469b5 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package builder implements a simple way to generate arbitrary Jsonnet directly from Go, using a functional API inspired by how Jsonnet is written itself.

Index

Constants

View Source
const (
	SeparatorLong    = ",\n"
	SeparatorConcise = ", "
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ArithType

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

arithmetic

func Add

func Add(name string, o ...Type) ArithType

func Div

func Div(name string, o ...Type) ArithType

func Mod

func Mod(name string, o ...Type) ArithType

func Mul

func Mul(name string, o ...Type) ArithType

func Sub

func Sub(name string, o ...Type) ArithType

func (ArithType) Name

func (n ArithType) Name() string

func (ArithType) String

func (m ArithType) String() string

type BoolType

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

bools

func Bool

func Bool(name string, value bool) BoolType

func (BoolType) Name

func (n BoolType) Name() string

func (BoolType) String

func (s BoolType) String() string

type CallType

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

function call

func Call

func Call(name, funcName string, args []Type) CallType

func CallChain

func CallChain(name string, calls ...CallType) CallType

CallChain allows to chain multiple calls

func (CallType) Name

func (n CallType) Name() string

func (CallType) String

func (c CallType) String() string

type CommentType

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

func Comment

func Comment(value Type, comment string) CommentType

func (CommentType) Comment

func (t CommentType) Comment() string

func (CommentType) Name

func (t CommentType) Name() string

func (CommentType) String

func (t CommentType) String() string

type ConditionType

type ConditionType struct {
	If   Type
	Then Type
	Else Type
	// contains filtered or unexported fields
}

func IfThenElse

func IfThenElse(name string, If, Then, Else Type) ConditionType

func (ConditionType) Name

func (c ConditionType) Name() string

func (ConditionType) String

func (c ConditionType) String() string

type Doc

type Doc struct {
	Locals []LocalType
	Root   Type
}

func (Doc) String

func (d Doc) String() string

type FloatType

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

floats

func Float

func Float(name string, value float64) FloatType

func (FloatType) Name

func (n FloatType) Name() string

func (FloatType) String

func (f FloatType) String() string

type FuncType

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

function definition

func Func

func Func(name string, args []Type, returns Type) FuncType

func LargeFunc

func LargeFunc(name string, args []Type, returns Type) FuncType

func (FuncType) Args

func (f FuncType) Args() string

func (FuncType) Name

func (n FuncType) Name() string

func (FuncType) String

func (f FuncType) String() string

type HiddenType

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

hidden field (::)

func Hidden

func Hidden(value Type) HiddenType

func (HiddenType) Name

func (h HiddenType) Name() string

func (HiddenType) String

func (h HiddenType) String() string

type ImportType

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

func Import

func Import(name, pkg string) ImportType

func ImportStr

func ImportStr(name, pkg string) ImportType

func (ImportType) Name

func (n ImportType) Name() string

func (ImportType) String

func (i ImportType) String() string

type IntType

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

ints

func Int

func Int(name string, value int) IntType

func (IntType) Name

func (n IntType) Name() string

func (IntType) String

func (s IntType) String() string

type ListType

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

Lists (arrays)

func List

func List(name string, items ...Type) ListType

func (ListType) Name

func (n ListType) Name() string

func (ListType) String

func (t ListType) String() string

type LocalType

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

func Local

func Local(value Type) LocalType

func (LocalType) Name

func (t LocalType) Name() string

func (LocalType) String

func (t LocalType) String() string

type MergeType

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

merge

func Merge

func Merge(value Type) MergeType

func (MergeType) Name

func (t MergeType) Name() string

func (MergeType) String

func (t MergeType) String() string

type NullType

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

null

func Null

func Null(name string) NullType

func (NullType) Name

func (n NullType) Name() string

func (NullType) String

func (s NullType) String() string

type ObjectType

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

Objects (dicts)

func ConciseObject

func ConciseObject(name string, children ...Type) ObjectType

func Object

func Object(name string, children ...Type) ObjectType

func (ObjectType) ConciseString

func (o ObjectType) ConciseString() string

func (ObjectType) Name

func (n ObjectType) Name() string

func (ObjectType) String

func (o ObjectType) String() string

type RefType

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

func Ref

func Ref(name, to string) RefType

func (RefType) Name

func (n RefType) Name() string

func (RefType) String

func (r RefType) String() string

type RequiredArgType

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

required arguments (no default value)

func Required

func Required(t Type) RequiredArgType

func (RequiredArgType) Name

func (r RequiredArgType) Name() string

func (RequiredArgType) String

func (r RequiredArgType) String() string

type SprintfType

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

string formatting

func Sprintf

func Sprintf(name, format string, values ...Type) SprintfType

func (SprintfType) Name

func (n SprintfType) Name() string

type StringType

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

strings

func String

func String(name, value string) StringType

func (StringType) Name

func (n StringType) Name() string

func (StringType) String

func (s StringType) String() string

type Type

type Type interface {
	String() string
	Name() string
}

func Args

func Args(args ...Type) []Type

function arguments

func Marshal

func Marshal(name string, ptr interface{}) Type

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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