Documentation
¶
Index ¶
- type Comparer
- type Formatter
- type Option
- func WithColor(enabled bool) Option
- func WithCommas(commas bool) Option
- func WithHideUnchanged(hideUnchanged bool) Option
- func WithIndentation(indentation string) Option
- func WithIndentedDiffMarkers(indentedDiffMarkers bool) Option
- func WithJSONinJSONCompare(jsonInJSONComparer Comparer) Option
- func WithPatchSeriesPostProcess(patchSeriesPostProcess PatchSeriesPostProcessor) Option
- type Patch
- type PatchSeriesPostProcessor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Comparer ¶
A Comparer compares two JSON documents and returns a JSON patch that transforms the first document into the second document.
type Formatter ¶
type Formatter struct {
// contains filtered or unexported fields
}
Formatter formats the diff if the given JSON patch is applied to the given JSON document.
func NewJSONFormatter ¶
NewJSONFormatter creates a new JSON formatter.
func NewTerraformFormatter ¶
NewTerraformFormatter creates a new Terraform formatter.
func (Formatter) Format ¶
Format writes the formatted representation of the jsonpatch applied to the provided original in pretty form.
The argument original can either be of tye []byte or any of the JSON types: map[string]any, []any, bool, float64, string or nil. If an other type is passed, Format will return an error. If the type is []byte, the argument is treated as a marshaled JSON document and is unmarshaled before processing.
The argument jsonpatch can either be of type []byte representing a JSON document following the JSON Patch specification (RFC 6902) or any type, that is marshalable to a JSON document following the before mentioned specification. In the second case is the argument marshaled to JSON before being processed.
type Option ¶
type Option func(*Formatter)
Option is a function that sets an option on the formatter.
func WithColor ¶
WithColor provides an option for the formatter to enable or disable the color full output.
func WithCommas ¶
WithCommas provides an option for the formatter to enable or disable the commas at the end of the JSON items.
func WithHideUnchanged ¶
WithHideUnchanged provides an option for the formatter to enable or disable the hiding of unchanged items. If enabled, unchanged items will not be printed. But instead a summary will be printed mentioning the number of unchanged items. If disabled, all items will be printed.
func WithIndentation ¶
WithIndentation provides an option for the formatter to set the indentation string to use when formatting the output.
func WithIndentedDiffMarkers ¶
WithIndentedDiffMarkers provides an option for the formatter to enable or disable the indentation of the diff markers. If enabled, the diff markers will be indented to match the indentation of the JSON. If disabled, the diff markers will be aligned to the left.
func WithJSONinJSONCompare ¶
WithJSONinJSONCompare provides an option for the formatter to set the comparer to use when comparing JSON in JSON. If not set, JSON in JSON diffing is disabled.
func WithPatchSeriesPostProcess ¶ added in v0.0.6
func WithPatchSeriesPostProcess(patchSeriesPostProcess PatchSeriesPostProcessor) Option
WithPatchSeriesPostProcess provides an option for the formatter to set the post processor to use when processing the patch series.
type PatchSeriesPostProcessor ¶ added in v0.0.6
A PatchSeriesPostProcessor processes the JSON patch series before the diff is printed. It can be used to modify the diff before it is printed.