Documentation ¶
Overview ¶
Package topologymutation provides helpers for implementing the topology mutation hooks.
Index ¶
- func GetBoolVariable(templateVariables map[string]apiextensionsv1.JSON, variableName string) (bool, error)
- func GetObjectVariableInto(templateVariables map[string]apiextensionsv1.JSON, variableName string, ...) error
- func GetStringVariable(templateVariables map[string]apiextensionsv1.JSON, variableName string) (string, error)
- func GetVariable(templateVariables map[string]apiextensionsv1.JSON, variableName string) (*apiextensionsv1.JSON, error)
- func IsNotFoundError(err error) bool
- func MergeVariableMaps(variableMaps ...map[string]apiextensionsv1.JSON) (map[string]apiextensionsv1.JSON, error)
- func ToMap(variables []runtimehooksv1.Variable) map[string]apiextensionsv1.JSON
- func WalkTemplates(ctx context.Context, decoder runtime.Decoder, ...)
- type FailForUnknownTypes
- type PatchFormat
- type WalkTemplatesOption
- type WalkTemplatesOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetBoolVariable ¶ added in v1.7.0
func GetBoolVariable(templateVariables map[string]apiextensionsv1.JSON, variableName string) (bool, error)
GetBoolVariable get the value as a bool.
func GetObjectVariableInto ¶ added in v1.7.0
func GetObjectVariableInto(templateVariables map[string]apiextensionsv1.JSON, variableName string, into interface{}) error
GetObjectVariableInto gets variable's string value then unmarshal it into object passed from 'into'.
func GetStringVariable ¶
func GetStringVariable(templateVariables map[string]apiextensionsv1.JSON, variableName string) (string, error)
GetStringVariable get the variable value as a string.
func GetVariable ¶
func GetVariable(templateVariables map[string]apiextensionsv1.JSON, variableName string) (*apiextensionsv1.JSON, error)
GetVariable get the variable value.
func IsNotFoundError ¶ added in v1.7.0
IsNotFoundError checks if the passed error is a notFoundError. It exposes same function in internal package so that user can directly call.
func MergeVariableMaps ¶ added in v1.7.0
func MergeVariableMaps(variableMaps ...map[string]apiextensionsv1.JSON) (map[string]apiextensionsv1.JSON, error)
MergeVariableMaps merges variables. This func is useful when merging global and template-specific variables. NOTE: In case a variable exists in multiple maps, the variable from the latter map is preserved. NOTE: The builtin variable object is merged instead of simply overwritten.
func ToMap ¶ added in v1.7.0
func ToMap(variables []runtimehooksv1.Variable) map[string]apiextensionsv1.JSON
ToMap converts a list of Variables to a map of apiextensionsv1.JSON (name is the map key). This is usually used to convert the Variables in a GeneratePatchesRequestItem into a format that is used by MergeVariableMaps.
func WalkTemplates ¶
func WalkTemplates(ctx context.Context, decoder runtime.Decoder, req *runtimehooksv1.GeneratePatchesRequest, resp *runtimehooksv1.GeneratePatchesResponse, mutateFunc func(ctx context.Context, obj runtime.Object, variables map[string]apiextensionsv1.JSON, holderRef runtimehooksv1.HolderReference) error, opts ...WalkTemplatesOption)
WalkTemplates walks through all templates of a GeneratePatchesRequest and calls the mutateFunc. By using walk templates it is possible to implement patches using typed API objects, which makes code easier to read and less error prone than using unstructured or working with raw json/yaml. Also, by using this func it is possible to ignore most of the details of the GeneratePatchesRequest and GeneratePatchesResponse messages format and focus on writing patches/modifying the templates.
Types ¶
type FailForUnknownTypes ¶
type FailForUnknownTypes struct{}
FailForUnknownTypes defines if WalkTemplates should fail when processing unknown types. If not set unknown types will be silently ignored, which allows to the WalkTemplates decoder to be configured only the API types it cares about.
func (FailForUnknownTypes) ApplyToWalkTemplates ¶
func (f FailForUnknownTypes) ApplyToWalkTemplates(in *WalkTemplatesOptions)
ApplyToWalkTemplates applies this configuration to the given WalkTemplatesOptions.
type PatchFormat ¶
type PatchFormat struct {
Format runtimehooksv1.PatchType
}
PatchFormat defines the patch format that WalkTemplates should generate. If not set, JSONPatchType will be used.
func (PatchFormat) ApplyToWalkTemplates ¶
func (d PatchFormat) ApplyToWalkTemplates(in *WalkTemplatesOptions)
ApplyToWalkTemplates applies this configuration to the given WalkTemplatesOptions.
type WalkTemplatesOption ¶
type WalkTemplatesOption interface { // ApplyToWalkTemplates applies this configuration to the given WalkTemplatesOptions. ApplyToWalkTemplates(*WalkTemplatesOptions) }
WalkTemplatesOption is some configuration that modifies WalkTemplates behavior.
type WalkTemplatesOptions ¶
type WalkTemplatesOptions struct {
// contains filtered or unexported fields
}
WalkTemplatesOptions contains options for WalkTemplates behavior.