Documentation ¶
Index ¶
- Variables
- type IteratorReference
- type LocalVariable
- type MapBuilder
- func (b *MapBuilder) AddLocalTemplateVariable(name string, value any) error
- func (b *MapBuilder) AppendTemplate(template string) *MapBuilder
- func (b *MapBuilder) ApplyMap(body map[string]interface{})
- func (b *MapBuilder) ApplyTemplates(existingJSON []byte, input []byte, appendTemplates bool) ([]byte, error)
- func (b *MapBuilder) ClearMap()
- func (b *MapBuilder) Get(key string) interface{}
- func (b *MapBuilder) GetBody() (interface{}, error)
- func (b *MapBuilder) GetFile() (*os.File, error)
- func (b *MapBuilder) GetFileContents() *os.File
- func (b *MapBuilder) GetMap() map[string]interface{}
- func (b *MapBuilder) GetRaw() string
- func (b *MapBuilder) GetString(key string) (string, bool)
- func (b *MapBuilder) HasChanged() bool
- func (b *MapBuilder) HasFile() bool
- func (b *MapBuilder) HasRaw() bool
- func (b *MapBuilder) KeyExists(path string) bool
- func (b *MapBuilder) MarshalJSON() (body []byte, err error)
- func (b *MapBuilder) MarshalJSONArray() ([]byte, error)
- func (b *MapBuilder) MarshalJSONObject() (body []byte, err error)
- func (b *MapBuilder) MarshalJSONWithInput(input interface{}) (body []byte, err error)
- func (b *MapBuilder) MergeJSON(existingJSON []byte, maps ...map[string]interface{}) ([]byte, error)
- func (b *MapBuilder) MergeMaps(maps ...map[string]interface{}) error
- func (b *MapBuilder) PrependTemplate(template string) *MapBuilder
- func (b *MapBuilder) Set(path string, value interface{}) error
- func (b *MapBuilder) SetAppendTemplatePreference(value bool) *MapBuilder
- func (b *MapBuilder) SetApplyTemplateOnMarshalPreference(value bool) *MapBuilder
- func (b *MapBuilder) SetEmptyMap() *MapBuilder
- func (b *MapBuilder) SetFile(path string)
- func (b *MapBuilder) SetMap(body map[string]interface{})
- func (b *MapBuilder) SetOptionalMap(value map[string]interface{})
- func (b *MapBuilder) SetPath(path string, value interface{}) error
- func (b *MapBuilder) SetRaw(v string)
- func (b *MapBuilder) SetRawPath(path string, value []byte) error
- func (b *MapBuilder) SetRequiredKeys(keys ...string)
- func (b *MapBuilder) SetTemplateVariables(variables map[string]interface{})
- func (b *MapBuilder) SetTuple(path string, values ...interface{}) error
- type MapBuilderIterator
Constants ¶
This section is empty.
Variables ¶
var Logger *logger.Logger
Functions ¶
This section is empty.
Types ¶
type IteratorReference ¶
type LocalVariable ¶ added in v2.32.0
type MapBuilder ¶
type MapBuilder struct { BodyRaw []byte TemplateIterator iterator.Iterator TemplateIteratorNames []string // Array output settings ArraySize int ArrayPrefix string ArraySuffix string // contains filtered or unexported fields }
MapBuilder creates body builder
func NewInitializedMapBuilder ¶
func NewInitializedMapBuilder(initBody bool) *MapBuilder
NewInitializedMapBuilder creates a new map builder with the map set to an empty map
func NewMapBuilder ¶
func NewMapBuilder() *MapBuilder
NewMapBuilder creates a new map builder with the map set to nil
func NewMapBuilderFromJSON ¶
func NewMapBuilderFromJSON(data string) (*MapBuilder, error)
NewMapBuilderFromJSON returns a new mapper builder object created from json
func NewMapBuilderFromJsonnetSnippet ¶
func NewMapBuilderFromJsonnetSnippet(snippet string) (*MapBuilder, error)
NewMapBuilderFromJsonnetSnippet returns a new mapper builder from a jsonnet snippet See https://jsonnet.org/learning/tutorial.html for details on how to create a snippet
func NewMapBuilderWithInit ¶
func NewMapBuilderWithInit(body []byte) *MapBuilder
NewMapBuilderWithInit returns a new map builder seeding the builder with json
func (*MapBuilder) AddLocalTemplateVariable ¶ added in v2.32.0
func (b *MapBuilder) AddLocalTemplateVariable(name string, value any) error
AddLocalTemplateVariable will inject new local variables into the jsonnet template using the local name = value; syntax. It allows users to access additional variables more easily
func (*MapBuilder) AppendTemplate ¶
func (b *MapBuilder) AppendTemplate(template string) *MapBuilder
AppendTemplate appends a templates to be merged in with the body
func (*MapBuilder) ApplyMap ¶
func (b *MapBuilder) ApplyMap(body map[string]interface{})
ApplyMap sets a new map to the body. This will remove any existing values in the body
func (*MapBuilder) ApplyTemplates ¶
func (b *MapBuilder) ApplyTemplates(existingJSON []byte, input []byte, appendTemplates bool) ([]byte, error)
ApplyTemplates merges the existing body data with a given jsonnet snippet. When reverse is false, then the snippet will be applied to the existing data, when reverse is true, then the given snippet will be the base, and the existing data will be applied to the new snippet.
func (*MapBuilder) ClearMap ¶
func (b *MapBuilder) ClearMap()
ClearMap removed the existing map and sets it to nil.
func (*MapBuilder) Get ¶
func (b *MapBuilder) Get(key string) interface{}
Get returns a value as an interface
func (*MapBuilder) GetBody ¶
func (b *MapBuilder) GetBody() (interface{}, error)
GetBody returns the body as an interface
func (*MapBuilder) GetFile ¶
func (b *MapBuilder) GetFile() (*os.File, error)
GetFile get the file reference
func (*MapBuilder) GetFileContents ¶
func (b *MapBuilder) GetFileContents() *os.File
GetFileContents returns the map contents as a file (only if a file is already set)
func (*MapBuilder) GetMap ¶
func (b *MapBuilder) GetMap() map[string]interface{}
GetMap returns the body as a map[string]interface{}
func (*MapBuilder) GetString ¶
func (b *MapBuilder) GetString(key string) (string, bool)
GetString the value as a string
func (*MapBuilder) HasChanged ¶
func (b *MapBuilder) HasChanged() bool
func (*MapBuilder) HasFile ¶
func (b *MapBuilder) HasFile() bool
HasFile return true if the body is being set from file
func (*MapBuilder) HasRaw ¶
func (b *MapBuilder) HasRaw() bool
HasRaw return true if the body is being set from raw data
func (*MapBuilder) KeyExists ¶
func (b *MapBuilder) KeyExists(path string) bool
KeyExists return true if the given dot notation path exists or not
func (*MapBuilder) MarshalJSON ¶
func (b *MapBuilder) MarshalJSON() (body []byte, err error)
func (*MapBuilder) MarshalJSONArray ¶
func (b *MapBuilder) MarshalJSONArray() ([]byte, error)
func (*MapBuilder) MarshalJSONObject ¶
func (b *MapBuilder) MarshalJSONObject() (body []byte, err error)
MarshalJSON returns the body as json
func (*MapBuilder) MarshalJSONWithInput ¶
func (b *MapBuilder) MarshalJSONWithInput(input interface{}) (body []byte, err error)
MarshalJSONWithInput convers the body to json and also injecting additional data into the template input to make it available using the input.value variable in jsonnet
func (*MapBuilder) MergeJSON ¶
func (b *MapBuilder) MergeJSON(existingJSON []byte, maps ...map[string]interface{}) ([]byte, error)
func (*MapBuilder) MergeMaps ¶
func (b *MapBuilder) MergeMaps(maps ...map[string]interface{}) error
MergeMaps merges a list of maps into the body. If the body does not already exists, then it will be ignored. Only shallow merging is done. Duplicate keys will be overwritten by maps later in the list
func (*MapBuilder) PrependTemplate ¶
func (b *MapBuilder) PrependTemplate(template string) *MapBuilder
PrependTemplate prepends a templates to be merged in with the body
func (*MapBuilder) Set ¶
func (b *MapBuilder) Set(path string, value interface{}) error
Set sets a value to a give dot notation path
func (*MapBuilder) SetAppendTemplatePreference ¶ added in v2.40.0
func (b *MapBuilder) SetAppendTemplatePreference(value bool) *MapBuilder
SetAppendTemplatePreference sets if the templates should be appended when evaluating the entire map Setting it to append means that the template can override other values provided in the map
func (*MapBuilder) SetApplyTemplateOnMarshalPreference ¶
func (b *MapBuilder) SetApplyTemplateOnMarshalPreference(value bool) *MapBuilder
SetApplyTemplateOnMarshalPreference sets whether the templates should be applied during marshalling or not.
func (*MapBuilder) SetEmptyMap ¶
func (b *MapBuilder) SetEmptyMap() *MapBuilder
SetEmptyMap sets the body to an empty map. It will override an existing body
func (*MapBuilder) SetFile ¶
func (b *MapBuilder) SetFile(path string)
SetFile sets the body to the contents of the file path
func (*MapBuilder) SetMap ¶
func (b *MapBuilder) SetMap(body map[string]interface{})
SetMap sets a new map to the body (if not nil). This will remove any existing values in the body
func (*MapBuilder) SetOptionalMap ¶
func (b *MapBuilder) SetOptionalMap(value map[string]interface{})
SetOptionalMap set optional map values which can be overwritten by other values
func (*MapBuilder) SetPath ¶
func (b *MapBuilder) SetPath(path string, value interface{}) error
func (*MapBuilder) SetRaw ¶
func (b *MapBuilder) SetRaw(v string)
SetRaw sets the body to a raw string
func (*MapBuilder) SetRawPath ¶
func (b *MapBuilder) SetRawPath(path string, value []byte) error
func (*MapBuilder) SetRequiredKeys ¶
func (b *MapBuilder) SetRequiredKeys(keys ...string)
SetRequiredKeys stores the list of keys which should be present when marshaling the map to json. Nested paths are accepted via dot notation
func (*MapBuilder) SetTemplateVariables ¶
func (b *MapBuilder) SetTemplateVariables(variables map[string]interface{})
SetTemplateVariables stores the given variables that will be used in the template evaluation
func (*MapBuilder) SetTuple ¶ added in v2.41.0
func (b *MapBuilder) SetTuple(path string, values ...interface{}) error
Set multiple values
type MapBuilderIterator ¶ added in v2.41.0
type MapBuilderIterator struct { MapBuilder *MapBuilder Index int64 }
func NewMapBuilderIterator ¶ added in v2.41.0
func NewMapBuilderIterator(b *MapBuilder) *MapBuilderIterator
func (*MapBuilderIterator) GetNext ¶ added in v2.41.0
func (i *MapBuilderIterator) GetNext() (line []byte, input interface{}, err error)
func (*MapBuilderIterator) IsBound ¶ added in v2.41.0
func (i *MapBuilderIterator) IsBound() bool