diffmap

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package diffmap computes the change-set that would turn map [a] into map [b].

A change-set is itself a [map[string]any] that contains only the keys that differ. Added keys get their new value, removed keys get a nil value, and modified nested-maps are expressed recursively.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(dst, chg DiffMap)

Apply mutates [dst] so that, after the call, [dst] equals the map that originally produced the given change-set `chg`.

dst := map[string]any{"a": 1, "b": map[string]any{"c": false}}
chg := map[string]any{"b": map[string]any{"c": true}}
diffmap.Apply(dst, chg) // dst is now {"a":1,"b":{"c":true}}

Types

type DiffMap

type DiffMap = map[string]any

DiffMap is a recursive string-keyed map used throughout the project as the canonical representation for Kubernetes resource objects and their diffs.

func Diff

func Diff(a, b DiffMap) DiffMap

Diff returns the minimal change-set required to transform [a] into [b]. If [a] and [b] are equal it returns nil (not an empty map) so callers can test `if Diff(...) == nil { }` with zero allocations.

Jump to

Keyboard shortcuts

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