merge

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Merge

func Merge(left, right any) error

Merge two config trees together.

Data in the left is replaced with data in the right unless it's zero value.

This function is not supposed to be a generic merge function. It is specifically fine-tuned to merge Talos machine configuration.

Rules:

  • if it is a simple value (int, float, string, etc.), it's merged into the left unless it's zero value, but boolean false is always merged.
  • if it is a pointer, merged dereferencing the pointer unless the right is nil
  • if it is a slice, merged by concatenating the right to the left.
  • if the `merge:"replace"` struct tag is defined, a slice is replaced with the value of the right (unless it's zero value.)
  • slices of `[]byte` are always replaced
  • if it is a map, for each key value is merged recursively.
  • if it is a struct, merge is performed for each field of the struct.
  • if the type implements 'merger' interface, Merge function is called to handle the merge process.
  • merger interface should be implemented on the pointer to the type.

Types

This section is empty.

Jump to

Keyboard shortcuts

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