You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
testdata/ Realistic fleet-gitops fixture repo for tests
24
+
assets/ Logo and screenshot images
25
+
docs/ Architecture and API endpoint docs
17
26
```
18
27
19
28
## Data flow
@@ -24,7 +33,7 @@ flowchart LR
24
33
C[Fleet API] -->|api.FetchAll| D[FleetState]
25
34
B --> E[diff.Diff]
26
35
D --> E
27
-
E --> F[DiffResult]
36
+
E --> F["[]DiffResult"]
28
37
F --> G{--format}
29
38
G -->|terminal| H[terminal.go]
30
39
G -->|json| I[json.go]
@@ -33,13 +42,30 @@ flowchart LR
33
42
34
43
## API client
35
44
36
-
`FetchAll` parallelizes all GET requests via `errgroup`. When `default.yml` has global sections, it also fetches `/config`, global policies, and global queries.
45
+
`FetchAll` parallelizes all GET requests via `errgroup`. When `default.yml` has global sections, it also fetches `/config`, global policies, and global queries. HTTPS is enforced by default (`FLEET_PLAN_INSECURE=1` to override for local dev).
37
46
38
47
See [api-endpoints.md](api-endpoints.md) for the full list.
39
48
49
+
## Auth resolution
50
+
51
+
Priority order (highest wins):
52
+
53
+
1.`--url` / `--token` flags
54
+
2.`FLEET_PLAN_URL` / `FLEET_PLAN_TOKEN` env vars
55
+
3. Config file: `~/.config/fleet-plan.json` or `<repo>/.config/fleet-plan.json`
Walks `teams/*.yml`, resolves `path:` references, produces `ParsedRepo`. Also parses `default.yml` for labels, `org_settings`, `agent_options`, `controls`, and global policies/queries.
68
+
Walks `teams/*.yml`, resolves `path:` references, produces `ParsedRepo`. Also parses `default.yml` for labels, `org_settings`, `agent_options`, `controls`, and global policies/queries. All path references are validated against the repo root to prevent traversal.
43
69
44
70
## Diff engine
45
71
@@ -56,12 +82,32 @@ Compares `FleetState` (API) vs `ParsedRepo` (YAML). Produces `[]DiffResult` per
56
82
| Profiles | PayloadDisplayName | add/delete only |
57
83
| Labels |`name` (cross-ref) | valid/missing with host counts |
58
84
59
-
Whitespace is normalized before comparison to avoid false positives from YAML vs API newline differences.
85
+
Whitespace is normalized before comparison to avoid false positives from YAML vs API newline differences. Per-field diffs are stored in `ResourceChange.Fields` for both added and modified resources.
86
+
87
+
## Output modes
88
+
89
+
| Mode | Flag | Description |
90
+
|------|------|-------------|
91
+
| Terminal (default) |`--format terminal`| ANSI-colored, smart truncation (80 chars), diff context around changes, capped at 3 fields per resource |
92
+
| Terminal verbose |`--verbose`| Full untruncated old/new values for all changed fields |
93
+
| JSON |`--format json`| Machine-readable, all fields |
94
+
| Markdown |`--format markdown`| For CI comments / MR descriptions |
95
+
96
+
## Screenshot generation
97
+
98
+
`gen_screenshot.go` (`//go:build ignore`) renders representative output from testdata fixtures for the README screenshot. Regenerate with:
99
+
100
+
```bash
101
+
go run ./internal/output/gen_screenshot.go > /tmp/raw.txt
Requires a PTY wrapper (e.g., `script -qec`) for ANSI color output when piping.
60
106
61
107
## Tests
62
108
63
109
```
64
110
go test -race ./...
65
111
```
66
112
67
-
All packages have `_test.go`. Tests use `testdata/` as a shared fleet-gitops fixture. Table-driven throughout.
113
+
All packages have `_test.go`. Tests use `testdata/` as a shared fleet-gitops fixture. Table-driven throughout. Coverage target: >= 75% (current: ~81%).
0 commit comments