Documentation ¶
Overview ¶
Package topologymutation provides helpers for implementing the topology mutation hooks.
Index ¶
- func GetStringVariable(templateVariables map[string]apiextensionsv1.JSON, variableName string) (string, bool, error)
- func GetVariable(templateVariables map[string]apiextensionsv1.JSON, variableName string) (*apiextensionsv1.JSON, bool, error)
- 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 GetStringVariable ¶
func GetStringVariable(templateVariables map[string]apiextensionsv1.JSON, variableName string) (string, bool, error)
GetStringVariable get the variable value as a string.
func GetVariable ¶
func GetVariable(templateVariables map[string]apiextensionsv1.JSON, variableName string) (*apiextensionsv1.JSON, bool, error)
GetVariable get the variable value.
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.