landing-party 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- landing_party-0.1.0/.gitignore +8 -0
- landing_party-0.1.0/COPILOT.md +255 -0
- landing_party-0.1.0/LICENSE +21 -0
- landing_party-0.1.0/PKG-INFO +316 -0
- landing_party-0.1.0/README.md +287 -0
- landing_party-0.1.0/example/README.md +33 -0
- landing_party-0.1.0/example/lookups.py +73 -0
- landing_party-0.1.0/example/reports/debian-versions.md +32 -0
- landing_party-0.1.0/example/templates/debian-versions.md.j2 +23 -0
- landing_party-0.1.0/pyproject.toml +52 -0
- landing_party-0.1.0/src/landing_party/__init__.py +708 -0
- landing_party-0.1.0/src/landing_party/__main__.py +5 -0
- landing_party-0.1.0/tests/conftest.py +84 -0
- landing_party-0.1.0/tests/fixtures/demo/lookups.py +39 -0
- landing_party-0.1.0/tests/fixtures/demo/templates/debian-versions.md.j2 +23 -0
- landing_party-0.1.0/tests/golden/debian-versions.md +36 -0
- landing_party-0.1.0/tests/test_golden.py +54 -0
- landing_party-0.1.0/tests/test_lookups.py +141 -0
- landing_party-0.1.0/tests/test_rag.py +99 -0
- landing_party-0.1.0/tests/test_render.py +318 -0
- landing_party-0.1.0/tests/test_run.py +160 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
# landing-party: context for an AI assistant
|
|
2
|
+
|
|
3
|
+
<!-- Paste this whole file at the start of a chat (written for M365 Copilot).
|
|
4
|
+
It is self-contained: the assistant can't see the repo. For coding agents
|
|
5
|
+
working on landing-party itself, see AGENTS.md instead. -->
|
|
6
|
+
|
|
7
|
+
You're helping me write **lookups** (Python) and **report templates**
|
|
8
|
+
(Jinja2 markdown) for `landing-party`, a small CLI. I'm an
|
|
9
|
+
engineering manager. I run it by hand with my own CLI logins (e.g. `kubectl`),
|
|
10
|
+
commit the rendered markdown to git and share the link. Git history is the
|
|
11
|
+
trend over time.
|
|
12
|
+
|
|
13
|
+
You can't run anything. When you need to know what a command outputs or how
|
|
14
|
+
it fails, ask me for a sample (I'll paste JSON or stderr, possibly redacted).
|
|
15
|
+
Don't guess at output formats.
|
|
16
|
+
|
|
17
|
+
## How it works
|
|
18
|
+
|
|
19
|
+
A reports repo:
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
templates/
|
|
23
|
+
debian-versions.md.j2 # one template per page -> reports/debian-versions.md
|
|
24
|
+
lookups.py # all lookups, in this one file
|
|
25
|
+
report.yaml # optional; only for changing heading/Updated line/footer
|
|
26
|
+
reports/ # rendered output, committed
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`landing-party render` renders every `templates/*.md.j2`. `--dry-run`
|
|
30
|
+
prints to stdout and writes nothing. `-v` shows each command, its output and
|
|
31
|
+
the full stderr of failures. `--strict` makes any failed lookup fail its page.
|
|
32
|
+
|
|
33
|
+
The tool wraps each template's output in a fixed layout: heading (from
|
|
34
|
+
`title`), an "Updated <time> by <user>" line, a traffic-light summary, a list
|
|
35
|
+
of failed lookups, **the template's output**, a legend generated from the
|
|
36
|
+
rules, and a footer. So a template is only the page body: no heading, no
|
|
37
|
+
legend, no "last updated" text. Markdown tables are aligned automatically.
|
|
38
|
+
|
|
39
|
+
## Lookups (`lookups.py`)
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
from landing_party import LookupFailed, lookup
|
|
43
|
+
|
|
44
|
+
@lookup
|
|
45
|
+
def my_lookup(ctx, arg1, arg2):
|
|
46
|
+
data = ctx.run(["kubectl", "get", "pods", "-n", arg1, "-o", "json"], parse="json")
|
|
47
|
+
return [...] # data, not markdown
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
- `@lookup` (bare, no arguments) makes the function callable from templates
|
|
51
|
+
as `my_lookup(arg1, arg2)`, without `ctx`. Functions without it are private
|
|
52
|
+
helpers.
|
|
53
|
+
- **Positional arguments only.** Keyword arguments in a template call fail the
|
|
54
|
+
page.
|
|
55
|
+
- Return **data**: dicts, lists, strings, numbers, `None`. Never markdown;
|
|
56
|
+
formatting belongs in the template. Dict keys are read in templates as
|
|
57
|
+
attributes (`row.namespace`).
|
|
58
|
+
- **Return sorted lists.** The same data must give byte-identical output so
|
|
59
|
+
git diffs show only real changes.
|
|
60
|
+
- `ctx.run(args, parse=None)` runs one command and returns its stdout:
|
|
61
|
+
- `args` is a list, never a shell string. There's no shell.
|
|
62
|
+
- `parse="json"` gives parsed JSON; `parse="lines"` gives the non-blank
|
|
63
|
+
lines, stripped; no `parse` gives the text.
|
|
64
|
+
- On a terminal, the command runs on a pty: I see its stderr as it runs,
|
|
65
|
+
I can answer password prompts, and there's no timeout. When scripted,
|
|
66
|
+
stdin is empty and there's a 60-second timeout.
|
|
67
|
+
- It returns stdout only. A command that writes to stderr needs
|
|
68
|
+
`["sh", "-c", "<command> 2>&1"]`, which only works where there's a shell.
|
|
69
|
+
- It raises `LookupFailed` on a missing command, non-zero exit, timeout, or
|
|
70
|
+
output that doesn't parse. `str(e)` is the last line of stderr; the full
|
|
71
|
+
stderr is `e.stderr`.
|
|
72
|
+
- Catch `LookupFailed` only for an **expected** condition you can describe
|
|
73
|
+
(e.g. "no `cat` in the image" → return `None`), and re-raise the rest. You
|
|
74
|
+
can also `raise LookupFailed("message")` yourself.
|
|
75
|
+
- **Any exception is a lookup failure, not a crash**, including a `KeyError`
|
|
76
|
+
from unexpected JSON. The tool lists it at the top of the page with its
|
|
77
|
+
error, the lookup's value becomes `Unknown`, and the page still renders.
|
|
78
|
+
So don't wrap everything in `try/except` to hide errors. Failures must be
|
|
79
|
+
visible.
|
|
80
|
+
- Python 3.9 (RHEL 9's default): no `match`, no `X | Y` type unions at
|
|
81
|
+
runtime, no 3.10+ features. Prefer the standard library.
|
|
82
|
+
- No caching, config or logging is available: `ctx.run` is the whole API.
|
|
83
|
+
|
|
84
|
+
## Templates (`templates/<name>.md.j2`)
|
|
85
|
+
|
|
86
|
+
YAML frontmatter, then markdown with plain Jinja2 (`for`, `if`, `set`,
|
|
87
|
+
`{{ }}`):
|
|
88
|
+
|
|
89
|
+
```jinja
|
|
90
|
+
---
|
|
91
|
+
title: Page heading
|
|
92
|
+
status:
|
|
93
|
+
rulename:
|
|
94
|
+
green: ">= 13"
|
|
95
|
+
amber: ">= 12"
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
Body text explaining what the page shows and what counts as red.
|
|
99
|
+
|
|
100
|
+
| Col A | Col B | Status |
|
|
101
|
+
|---|---|---|
|
|
102
|
+
{% for row in my_lookup("a", "b") %}
|
|
103
|
+
| {{ row.a }} | {{ row.b }} | {{ row.version | rag("rulename") }} |
|
|
104
|
+
{% endfor %}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
- Frontmatter keys that mean something: `title` and `status`. The whole
|
|
108
|
+
frontmatter is available as `page`.
|
|
109
|
+
- Block tags on their own line leave no blank line (`trim_blocks`), so table
|
|
110
|
+
rows can be generated as shown. Nothing is HTML-escaped.
|
|
111
|
+
- An undefined variable or a typo'd attribute **fails the page**. It doesn't
|
|
112
|
+
render empty.
|
|
113
|
+
- **A failed lookup's value is `Unknown`:** falsy, empty when looped over,
|
|
114
|
+
and printed as `⚪ Unknown`. It has **no attributes**, so guard before
|
|
115
|
+
reading fields: `{% if os and os.id == "debian" %}`, not
|
|
116
|
+
`{% if os.id == "debian" %}`. A loop over a failed lookup simply produces
|
|
117
|
+
no rows. The failure is already listed at the top of the page.
|
|
118
|
+
- Also available: `report.updated` (datetime), `report.updated_by`,
|
|
119
|
+
`report.host`, `report.template`.
|
|
120
|
+
|
|
121
|
+
## Traffic lights (`rag`)
|
|
122
|
+
|
|
123
|
+
- A rule has `green` and/or `amber`, each `">= <version>"`. Nothing else is
|
|
124
|
+
supported: no other operators, no `red:`, no ranges.
|
|
125
|
+
- `{{ value | rag("rulename") }}` gives `🟢 Green`, `🟡 Amber`, `🔴 Red` or
|
|
126
|
+
`⚪ Unknown`. It tries green, then amber; below both is red.
|
|
127
|
+
- Values compare as versions (`"9" < "12"`, `"12.9" < "13"`). `None`, empty,
|
|
128
|
+
a non-version like `"trixie/sid"`, or a failed lookup is **Unknown, never
|
|
129
|
+
green**.
|
|
130
|
+
- To light something that isn't a version, have the lookup return a number
|
|
131
|
+
(e.g. days until expiry) and set the thresholds on that.
|
|
132
|
+
- `rag` naming a rule that isn't in the frontmatter fails the page.
|
|
133
|
+
|
|
134
|
+
## The reference example
|
|
135
|
+
|
|
136
|
+
This is the page the tool was designed around. Follow its style.
|
|
137
|
+
|
|
138
|
+
`templates/debian-versions.md.j2`:
|
|
139
|
+
|
|
140
|
+
```jinja
|
|
141
|
+
---
|
|
142
|
+
title: Debian versions
|
|
143
|
+
status:
|
|
144
|
+
debian:
|
|
145
|
+
green: ">= 13" # stable: 13 (trixie); bump both when 14 is released
|
|
146
|
+
amber: ">= 12" # oldstable: 12 (bookworm)
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
Running workloads whose images are based on Debian, and whether they're on
|
|
150
|
+
the current stable release. Oldstable is amber; anything older is red.
|
|
151
|
+
Images based on other distributions, such as Ubuntu or Alpine, aren't listed.
|
|
152
|
+
|
|
153
|
+
| Namespace | Workload | Pods | Image | Debian | Status |
|
|
154
|
+
|---|---|--:|---|---|---|
|
|
155
|
+
{% for w in workloads() %}
|
|
156
|
+
{% set os = os_release(w.namespace, w.pod, w.container) %}
|
|
157
|
+
{% if os and os.id == "debian" %}
|
|
158
|
+
| {{ w.namespace }} | {{ w.workload }} | {{ w.pods }} | `{{ w.image }}` | {{ os.version_id }} ({{ os.codename }}) | {{ os.version_id | rag("debian") }} |
|
|
159
|
+
{% endif %}
|
|
160
|
+
{% endfor %}
|
|
161
|
+
|
|
162
|
+
Containers that couldn't be checked (no `cat` in the image) aren't listed
|
|
163
|
+
either. Failed checks are listed at the top.
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
`lookups.py`:
|
|
167
|
+
|
|
168
|
+
```python
|
|
169
|
+
"""Lookups for the example: a kubectl-based report on Debian versions.
|
|
170
|
+
|
|
171
|
+
Uses the current kubectl context. The commands are in ctx.run calls below.
|
|
172
|
+
"""
|
|
173
|
+
|
|
174
|
+
from landing_party import LookupFailed, lookup
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
# --- workloads ------------------------------------------------------------------
|
|
178
|
+
|
|
179
|
+
def _owner(pod):
|
|
180
|
+
"""The workload a pod belongs to: ("Deployment/invoice-api", "invoice-api-5d9c8").
|
|
181
|
+
|
|
182
|
+
The second part tells apart a Deployment's old and new pods mid-rollout.
|
|
183
|
+
"""
|
|
184
|
+
refs = pod["metadata"].get("ownerReferences") or [{"kind": "Pod", "name": pod["metadata"]["name"]}]
|
|
185
|
+
kind, name = refs[0]["kind"], refs[0]["name"]
|
|
186
|
+
if kind == "ReplicaSet": # made by a Deployment: drop the "-<hash>" suffix
|
|
187
|
+
pod_hash = pod["metadata"].get("labels", {}).get("pod-template-hash")
|
|
188
|
+
if pod_hash and name.endswith("-" + pod_hash):
|
|
189
|
+
return f"Deployment/{name[:-len(pod_hash) - 1]}", name
|
|
190
|
+
return f"{kind}/{name}", name
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
@lookup
|
|
194
|
+
def workloads(ctx):
|
|
195
|
+
"""Running workloads, one row per (namespace, workload, container).
|
|
196
|
+
|
|
197
|
+
Each row names one pod to look inside: pods of a workload share a spec,
|
|
198
|
+
so they have the same image and environment. "pods" counts them. Pods
|
|
199
|
+
being deleted are skipped; mid-rollout, old and new pods are separate rows.
|
|
200
|
+
"""
|
|
201
|
+
pods = ctx.run(["kubectl", "get", "pods", "--all-namespaces", "-o", "json",
|
|
202
|
+
"--field-selector=status.phase=Running"], parse="json")["items"]
|
|
203
|
+
|
|
204
|
+
found = {}
|
|
205
|
+
for pod in pods:
|
|
206
|
+
if pod["metadata"].get("deletionTimestamp"):
|
|
207
|
+
continue
|
|
208
|
+
ns = pod["metadata"]["namespace"]
|
|
209
|
+
owner, generation = _owner(pod)
|
|
210
|
+
for container in pod["spec"]["containers"]:
|
|
211
|
+
row = found.setdefault((ns, owner, generation, container["name"]), {
|
|
212
|
+
"namespace": ns, "workload": owner, "container": container["name"],
|
|
213
|
+
"image": container["image"], "pod": pod["metadata"]["name"], "pods": 0,
|
|
214
|
+
})
|
|
215
|
+
row["pods"] += 1
|
|
216
|
+
return [found[key] for key in sorted(found)]
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
# --- debian-versions ---------------------------------------------------------
|
|
220
|
+
|
|
221
|
+
@lookup
|
|
222
|
+
def os_release(ctx, namespace, pod, container):
|
|
223
|
+
"""The OS of a container, from /etc/os-release.
|
|
224
|
+
|
|
225
|
+
Returns {"id", "version_id", "codename"} (each may be None; all None if
|
|
226
|
+
there's no os-release file), or None if the image has no `cat`, so it
|
|
227
|
+
can't be checked.
|
|
228
|
+
"""
|
|
229
|
+
try:
|
|
230
|
+
lines = ctx.run(["kubectl", "exec", "-n", namespace, pod, "-c", container,
|
|
231
|
+
"--", "cat", "/etc/os-release"], parse="lines")
|
|
232
|
+
except LookupFailed as e:
|
|
233
|
+
if '"cat"' in e.stderr and "not found" in e.stderr:
|
|
234
|
+
return None
|
|
235
|
+
if "No such file" in e.stderr:
|
|
236
|
+
lines = []
|
|
237
|
+
else:
|
|
238
|
+
raise
|
|
239
|
+
fields = dict(line.split("=", 1) for line in lines if "=" in line)
|
|
240
|
+
get = lambda key: fields[key].strip('"') if key in fields else None
|
|
241
|
+
return {"id": get("ID"), "version_id": get("VERSION_ID"), "codename": get("VERSION_CODENAME")}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## How to help me
|
|
245
|
+
|
|
246
|
+
- Give complete, paste-ready code: the lookup(s) for `lookups.py` and the
|
|
247
|
+
whole template. Keep lookups small; one command per lookup where possible.
|
|
248
|
+
- Use only what's described here. Don't invent features (filters, template
|
|
249
|
+
includes or `extends`, config options, keyword arguments, other `rag`
|
|
250
|
+
operators, caching). If something seems to need one, say so instead of
|
|
251
|
+
working around it.
|
|
252
|
+
- Say what each page **doesn't** show (skipped items, unchecked cases) in the
|
|
253
|
+
page body, as the example does.
|
|
254
|
+
- Tell me the `landing-party render --dry-run` (or `-v`) command to try, and
|
|
255
|
+
what output or failure to expect.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Peter Ericson
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: landing-party
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Report-first monitoring: render Jinja2-templated markdown reports from live lookups
|
|
5
|
+
Project-URL: Source, https://github.com/pdericson/landing-party
|
|
6
|
+
Project-URL: Issues, https://github.com/pdericson/landing-party/issues
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Intended Audience :: System Administrators
|
|
12
|
+
Classifier: Operating System :: POSIX
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Topic :: System :: Systems Administration
|
|
22
|
+
Requires-Python: >=3.9
|
|
23
|
+
Requires-Dist: jinja2>=3.0
|
|
24
|
+
Requires-Dist: packaging>=21.0
|
|
25
|
+
Requires-Dist: pyyaml>=6.0
|
|
26
|
+
Provides-Extra: test
|
|
27
|
+
Requires-Dist: pytest>=7; extra == 'test'
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# landing-party
|
|
31
|
+
|
|
32
|
+
_Send a landing party before you build the monitoring._
|
|
33
|
+
|
|
34
|
+
`landing-party` does **report-first monitoring**: answer today's question
|
|
35
|
+
with a point-in-time markdown report, then decide what's worth monitoring
|
|
36
|
+
tomorrow. You run it by hand with your own logins, on purpose. There's no
|
|
37
|
+
service account, scheduler or server.
|
|
38
|
+
|
|
39
|
+
Each report is a Jinja2 template that calls **lookups**: small Python
|
|
40
|
+
functions that run commands such as `kubectl`. `landing-party render` writes
|
|
41
|
+
the result to `reports/`. Commit it and share the link, and git history
|
|
42
|
+
becomes the trend.
|
|
43
|
+
|
|
44
|
+
The value is in the conventions:
|
|
45
|
+
|
|
46
|
+
- **Provenance stamp**: every page says when it was updated and by whom, and
|
|
47
|
+
that its values are not live.
|
|
48
|
+
- **Traffic lights**: thresholds are declared at the top of the template, and
|
|
49
|
+
the legend is generated from them.
|
|
50
|
+
- **Readable markdown**: tables are aligned, so the raw file reads well in an
|
|
51
|
+
editor and in diffs.
|
|
52
|
+
|
|
53
|
+
## Getting started
|
|
54
|
+
|
|
55
|
+
You need Python 3.9 or later, the default `python3` on RHEL 9. On RHEL 8,
|
|
56
|
+
install `python3.9` or later from AppStream and use it in place of `python3`.
|
|
57
|
+
|
|
58
|
+
In your reports repo:
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
python3 -m venv .venv && . .venv/bin/activate
|
|
62
|
+
echo landing-party >> requirements.txt
|
|
63
|
+
pip install -r requirements.txt
|
|
64
|
+
landing-party init # templates/, reports/, a lookups.py stub, report.yaml
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## A report
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
templates/
|
|
71
|
+
debian-versions.md.j2 # one template per page -> reports/debian-versions.md
|
|
72
|
+
lookups.py # your lookups
|
|
73
|
+
report.yaml # optional: change the page layout
|
|
74
|
+
reports/ # rendered output, committed to git
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
This is `templates/debian-versions.md.j2`, from
|
|
78
|
+
[`example/`](https://github.com/pdericson/landing-party/tree/main/example):
|
|
79
|
+
|
|
80
|
+
```jinja
|
|
81
|
+
---
|
|
82
|
+
title: Debian versions
|
|
83
|
+
status:
|
|
84
|
+
debian:
|
|
85
|
+
green: ">= 13" # stable: 13 (trixie); bump both when 14 is released
|
|
86
|
+
amber: ">= 12" # oldstable: 12 (bookworm)
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
Running workloads whose images are based on Debian, and whether they're on
|
|
90
|
+
the current stable release. Oldstable is amber; anything older is red.
|
|
91
|
+
Images based on other distributions, such as Ubuntu or Alpine, aren't listed.
|
|
92
|
+
|
|
93
|
+
| Namespace | Workload | Pods | Image | Debian | Status |
|
|
94
|
+
|---|---|--:|---|---|---|
|
|
95
|
+
{% for w in workloads() %}
|
|
96
|
+
{% set os = os_release(w.namespace, w.pod, w.container) %}
|
|
97
|
+
{% if os and os.id == "debian" %}
|
|
98
|
+
| {{ w.namespace }} | {{ w.workload }} | {{ w.pods }} | `{{ w.image }}` | {{ os.version_id }} ({{ os.codename }}) | {{ os.version_id | rag("debian") }} |
|
|
99
|
+
{% endif %}
|
|
100
|
+
{% endfor %}
|
|
101
|
+
|
|
102
|
+
Containers that couldn't be checked (no `cat` in the image) aren't listed
|
|
103
|
+
either. Failed checks are listed at the top.
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
`landing-party render` writes `reports/debian-versions.md`:
|
|
107
|
+
|
|
108
|
+
```markdown
|
|
109
|
+
---
|
|
110
|
+
updated: 2026-11-30 11:27:32+13:00
|
|
111
|
+
updated_by: pdericson
|
|
112
|
+
summary: 🔴 1 · 🟡 1 · 🟢 1
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
# Debian versions
|
|
116
|
+
|
|
117
|
+
> **Updated** 2026-11-30 11:27 NZDT by pdericson. Values were current at the time of this update. They are not live.
|
|
118
|
+
|
|
119
|
+
**Summary:** 🔴 1 · 🟡 1 · 🟢 1
|
|
120
|
+
|
|
121
|
+
Running workloads whose images are based on Debian, and whether they're on
|
|
122
|
+
the current stable release. Oldstable is amber; anything older is red.
|
|
123
|
+
Images based on other distributions, such as Ubuntu or Alpine, aren't listed.
|
|
124
|
+
|
|
125
|
+
| Namespace | Workload | Pods | Image | Debian | Status |
|
|
126
|
+
| ----------- | ------------ | ---: | ----------- | ------------- | -------- |
|
|
127
|
+
| report-demo | Pod/debian11 | 1 | `debian:11` | 11 (bullseye) | 🔴 Red |
|
|
128
|
+
| report-demo | Pod/debian12 | 1 | `debian:12` | 12 (bookworm) | 🟡 Amber |
|
|
129
|
+
| report-demo | Pod/debian13 | 1 | `debian:13` | 13 (trixie) | 🟢 Green |
|
|
130
|
+
|
|
131
|
+
Containers that couldn't be checked (no `cat` in the image) aren't listed
|
|
132
|
+
either. Failed checks are listed at the top.
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
**Legend.** First matching band wins.
|
|
137
|
+
- `debian`: 🟢 Green ≥ 13 · 🟡 Amber ≥ 12 · 🔴 Red otherwise
|
|
138
|
+
- ⚪ Unknown: no value, or the lookup failed. Never counted as green.
|
|
139
|
+
|
|
140
|
+
<sub>Rendered from `templates/debian-versions.md.j2` on dev.</sub>
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## The template
|
|
144
|
+
|
|
145
|
+
The frontmatter between the `---` lines is YAML. `title` is the page heading
|
|
146
|
+
and `status` holds the [traffic-light](#traffic-lights) rules. The whole
|
|
147
|
+
frontmatter is available to the template as `page`, so you can add keys of
|
|
148
|
+
your own.
|
|
149
|
+
|
|
150
|
+
The rest is markdown with Jinja2 (`for`, `if`, `set`, `{{ ... }}`). Block
|
|
151
|
+
tags on their own line leave no blank line behind. A typo such as
|
|
152
|
+
`{{ w.namesapce }}` fails the page loudly rather than rendering an empty
|
|
153
|
+
cell. Nothing is HTML-escaped.
|
|
154
|
+
|
|
155
|
+
A template is only the page's body: `landing-party` adds the heading, stamp,
|
|
156
|
+
summary, failures, legend and footer (see [Page layout](#page-layout)).
|
|
157
|
+
|
|
158
|
+
## Lookups
|
|
159
|
+
|
|
160
|
+
Lookups live in `lookups.py`, next to `templates/`:
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
from landing_party import lookup
|
|
164
|
+
|
|
165
|
+
@lookup
|
|
166
|
+
def namespaces(ctx):
|
|
167
|
+
"""Namespace names, sorted."""
|
|
168
|
+
data = ctx.run(["kubectl", "get", "namespaces", "-o", "json"], parse="json")
|
|
169
|
+
return sorted(ns["metadata"]["name"] for ns in data["items"])
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
- `@lookup` makes the function callable from templates by its name, without
|
|
173
|
+
`ctx`: `{% for ns in namespaces() %}`. Functions without it are private
|
|
174
|
+
helpers.
|
|
175
|
+
- Lookups return **data** (dicts, lists, strings), never markdown, and
|
|
176
|
+
return lists sorted, so the same data gives byte-identical output.
|
|
177
|
+
- `@lookup` returns the function unchanged, so you can unit-test it with
|
|
178
|
+
`namespaces(landing_party.Ctx())`.
|
|
179
|
+
|
|
180
|
+
### `ctx.run`
|
|
181
|
+
|
|
182
|
+
`ctx.run(args, parse=None)` runs a command and returns its stdout.
|
|
183
|
+
|
|
184
|
+
- `args` is an argument list, never a shell string.
|
|
185
|
+
- `parse="json"` parses the output as JSON. `parse="lines"` returns the
|
|
186
|
+
non-blank lines, stripped. Without `parse`, you get the text.
|
|
187
|
+
- On a terminal, the command runs on a pty, as if you'd typed it: its
|
|
188
|
+
stderr shows as it runs, it can prompt for a password, and Ctrl-C stops
|
|
189
|
+
it. Otherwise (scripted or piped) it gets an empty stdin and a 60-second
|
|
190
|
+
timeout.
|
|
191
|
+
|
|
192
|
+
It raises `LookupFailed` for a missing command, a non-zero exit, a timeout,
|
|
193
|
+
or output that doesn't parse. The message is the last line of stderr, and
|
|
194
|
+
the full stderr is on `.stderr`. A lookup can raise `LookupFailed("...")`
|
|
195
|
+
itself, or catch it to handle an expected error, as the example's
|
|
196
|
+
`os_release` does for images without `cat`.
|
|
197
|
+
|
|
198
|
+
### When a lookup fails
|
|
199
|
+
|
|
200
|
+
Any exception from a lookup is a lookup failure: `LookupFailed`, a `KeyError`
|
|
201
|
+
from unexpected JSON, anything.
|
|
202
|
+
|
|
203
|
+
- The page lists it near the top:
|
|
204
|
+
``> ⚠ `os_release(apps, api-7d9f, api)`: error: unable to upgrade connection``.
|
|
205
|
+
- The lookup's value is ⚪ Unknown. It is falsy, so `{% if os %}` skips it,
|
|
206
|
+
and a loop over it runs zero times.
|
|
207
|
+
- The page is still written, the run carries on, and the exit code is 1.
|
|
208
|
+
|
|
209
|
+
## Traffic lights
|
|
210
|
+
|
|
211
|
+
`{{ value | rag("debian") }}` gives `🟢 Green`, `🟡 Amber`, `🔴 Red` or
|
|
212
|
+
`⚪ Unknown`, using the `debian` rule under `status:` in the frontmatter.
|
|
213
|
+
|
|
214
|
+
- At least `green` is green, otherwise at least `amber` is amber, otherwise
|
|
215
|
+
red. A rule can have just one of the two.
|
|
216
|
+
- Thresholds are `>= <version>`, and values compare as versions, so
|
|
217
|
+
`"9" < "12"`.
|
|
218
|
+
- **⚪ Unknown is never green.** A missing value, one that isn't a version
|
|
219
|
+
(such as `trixie/sid`), or a failed lookup is unknown.
|
|
220
|
+
- Every `rag` call counts towards the summary, and the legend is generated
|
|
221
|
+
from the rules.
|
|
222
|
+
- A `rag` naming a missing rule, or a malformed rule, fails the page.
|
|
223
|
+
|
|
224
|
+
## Page layout
|
|
225
|
+
|
|
226
|
+
The template renders first, then goes into a fixed layout: heading, Updated
|
|
227
|
+
line, summary, failed lookups, the template's output, legend, footer. Because
|
|
228
|
+
the template renders first, the summary and failures know what happened.
|
|
229
|
+
|
|
230
|
+
Every markdown table is padded so its columns line up (emoji count as two
|
|
231
|
+
columns). Only spacing changes, so GitHub and GitLab show the same table.
|
|
232
|
+
|
|
233
|
+
The output frontmatter (`updated`, `updated_by`, `summary`) lets other tools
|
|
234
|
+
check how old a page is. Before any lookup runs, `landing-party` captures
|
|
235
|
+
`report.updated`, `report.updated_by`, `report.host` and `report.template`,
|
|
236
|
+
which templates and layout lines can use.
|
|
237
|
+
|
|
238
|
+
### Changing the layout
|
|
239
|
+
|
|
240
|
+
The heading, Updated line and footer can be changed in `report.yaml`. They
|
|
241
|
+
are Jinja, with `report` and `page`. An empty value removes the line. These
|
|
242
|
+
are the defaults:
|
|
243
|
+
|
|
244
|
+
```yaml
|
|
245
|
+
layout:
|
|
246
|
+
heading: "# {{ page.title }}"
|
|
247
|
+
updated: "> **Updated** {{ report.updated.strftime('%Y-%m-%d %H:%M %Z') }} by {{ report.updated_by }}. Values were current at the time of this update. They are not live."
|
|
248
|
+
footer: "<sub>Rendered from `{{ report.template }}` on {{ report.host }}.</sub>"
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
`layout` is the only setting. An unknown key fails the run; a line that
|
|
252
|
+
doesn't render fails the page.
|
|
253
|
+
|
|
254
|
+
## Command line
|
|
255
|
+
|
|
256
|
+
```
|
|
257
|
+
landing-party init
|
|
258
|
+
landing-party render [--dry-run] [--strict] [-v]
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
`init` creates the skeleton in the current directory. It never overwrites.
|
|
262
|
+
|
|
263
|
+
`render` renders every `templates/*.md.j2` to `reports/`, atomically, so a
|
|
264
|
+
failed page leaves the previous version in place.
|
|
265
|
+
|
|
266
|
+
- `--dry-run` runs the lookups, writes nothing and prints the markdown. It's
|
|
267
|
+
a quick check that your logins work.
|
|
268
|
+
- `--strict` makes a failed lookup fail its page: it isn't written, the run
|
|
269
|
+
stops, and the exit code is 1. Use it when the run is scripted.
|
|
270
|
+
- `-v` shows each command and its output, and the full stderr of each failure.
|
|
271
|
+
|
|
272
|
+
```
|
|
273
|
+
✓ debian-versions 🔴 1 · 🟡 1 · 🟢 1
|
|
274
|
+
1 page: 1 ok, 0 failed
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
| Exit code | Meaning |
|
|
278
|
+
|-----------|-----------------------------------------------------------------------------|
|
|
279
|
+
| 0 | Every page rendered with no failed lookups |
|
|
280
|
+
| 1 | A page failed, or a lookup failed |
|
|
281
|
+
| 2 | A repo problem: no `templates/`, a bad `report.yaml`, a broken `lookups.py` |
|
|
282
|
+
|
|
283
|
+
## Non-goals
|
|
284
|
+
|
|
285
|
+
- caching of any kind
|
|
286
|
+
- a plugin registry, installer or self-update command (pip covers these)
|
|
287
|
+
- HTML, PDF, email or Confluence output
|
|
288
|
+
- a scheduler, a server, a web UI or a service-account mode
|
|
289
|
+
- Ansible as the runtime (Ansible can be a data source through `ctx.run`)
|
|
290
|
+
|
|
291
|
+
## Development
|
|
292
|
+
|
|
293
|
+
```sh
|
|
294
|
+
python3 -m venv .venv && . .venv/bin/activate
|
|
295
|
+
python -m pip install -e ".[test]"
|
|
296
|
+
python -m pytest
|
|
297
|
+
UPDATE_GOLDEN=1 python -m pytest tests/test_golden.py # after an intended output change
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
Supported: Python 3.9+ with jinja2 >= 3.0, pyyaml >= 6.0 and packaging >= 21.0.
|
|
301
|
+
GitHub Actions runs the tests on each supported Python, and with the minimum
|
|
302
|
+
dependencies on 3.9. `ci/matrix.sh` does the same locally in podman.
|
|
303
|
+
|
|
304
|
+
## Open questions
|
|
305
|
+
|
|
306
|
+
- **Capturing stderr.** `ctx.run` returns stdout only, so a command that
|
|
307
|
+
writes to stderr needs `sh -c "... 2>&1"`, which fails in images without a
|
|
308
|
+
shell.
|
|
309
|
+
- **The summary shows zero counts** (`🔴 0 · 🟡 1 · 🟢 2`). Should they be
|
|
310
|
+
hidden?
|
|
311
|
+
- **Debian testing has no `VERSION_ID`,** so the example shows
|
|
312
|
+
`None (forky)` for it.
|
|
313
|
+
|
|
314
|
+
## Licence
|
|
315
|
+
|
|
316
|
+
MIT
|