https://github.com/berquerant/k8s-object-diff-go
k8s object diff by object id
https://github.com/berquerant/k8s-object-diff-go
diff go kubernetes yaml
Last synced: 4 months ago
JSON representation
k8s object diff by object id
- Host: GitHub
- URL: https://github.com/berquerant/k8s-object-diff-go
- Owner: berquerant
- License: mit
- Created: 2025-06-30T10:58:32.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2026-01-16T16:06:50.000Z (5 months ago)
- Last Synced: 2026-01-17T05:12:17.184Z (5 months ago)
- Topics: diff, go, kubernetes, yaml
- Language: Go
- Homepage:
- Size: 184 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Notice: NOTICE
Awesome Lists containing this project
README
[](https://goreportcard.com/report/github.com/berquerant/k8s-object-diff-go)
# k8s-object-diff-go
```
❯ objdiff --help
objdiff - k8s object diff by object id
# Usage
objdiff [flags] LEFT_FILE RIGHT_FILE
# Object ID
A unique ID for a k8s object.
e.g.
apiVersion: v1
kind: Pod
metadata:
name: nginx
namespace: default
then id is 'v1>Pod>default>nginx'.
# Output format
## idlist
All object IDs.
## id
ID diff.
## text
Unified diff.
## yaml
Array of
id: "Object ID"
diff: "Unified diff"
left: "Left object (optional)"
right: "Right object (optional)"
type: "Diff type (add or change or destroy)"
# Exit status
0 if inputs are the same.
1 if inputs differ.
Otherwise 2.
# Override differ
objdiff -x diff left.yml right.yml
invokes
diff --unified=3 --color=never --label left.yml --label right.yml LEFT_FILE RIGHT_FILE
DIFFCMD='diff' objdiff -c -C 5 left.yml right.yml
invokes
diff --unified=5 --color=always --label left.yml --label right.yml LEFT_FILE RIGHT_FILE
# Flags
--allowDuplicateKey allow the use of keys with the same name in the same map (default true)
-c, --color colored diff
-C, --context int diff context (default 3)
--debug enable debug log
-x, --diffCmd string invoke this to get diff instead of builtin differ
-n, --indent int yaml indent (default 2)
-L, --label strings use label instead of file name
-o, --out string output format: text,yaml,id,idlist (default "text")
-q, --quiet quiet log
-d, --separator string object id separator (default ">")
--success exit with 0 even if inputs differ
-v, --verbose enable verbose output; annotate diff type and display summary
--version print objdiff version
```
## Example
For [left.yml](./tests/diffs/left.yml) and [right.yml](./tests/diffs/right.yml), executing
``` shell
objdiff left.yml right.yml
```
yields the [result](./tests/diffs/out.txt).
## Installation
Build binary:
``` shell
make
```
Show help:
``` shell
./dist/objdiff --help
```