nacho-python 0.0.3__tar.gz → 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.
- nacho_python-0.1.0/PKG-INFO +822 -0
- nacho_python-0.1.0/README.md +775 -0
- {nacho_python-0.0.3 → nacho_python-0.1.0}/nacho/__init__.py +12 -5
- nacho_python-0.1.0/nacho/_version.py +3 -0
- nacho_python-0.1.0/nacho/cli/__init__.py +9 -0
- nacho_python-0.1.0/nacho/cli/main.py +750 -0
- nacho_python-0.1.0/nacho/client.py +252 -0
- {nacho_python-0.0.3 → nacho_python-0.1.0}/nacho/config.py +82 -53
- {nacho_python-0.0.3 → nacho_python-0.1.0}/nacho/env.py +58 -31
- {nacho_python-0.0.3 → nacho_python-0.1.0}/nacho/event.py +69 -103
- {nacho_python-0.0.3 → nacho_python-0.1.0}/nacho/schema.py +10 -24
- {nacho_python-0.0.3 → nacho_python-0.1.0}/nacho/server/__init__.py +4 -4
- {nacho_python-0.0.3 → nacho_python-0.1.0}/nacho/server/app.py +210 -119
- nacho_python-0.1.0/nacho/server/auth.py +168 -0
- {nacho_python-0.0.3 → nacho_python-0.1.0}/nacho/server/models.py +37 -24
- nacho_python-0.1.0/nacho/server/runtime.py +671 -0
- nacho_python-0.1.0/nacho/server/ui/index.html +1909 -0
- {nacho_python-0.0.3 → nacho_python-0.1.0}/nacho/storage/__init__.py +14 -3
- nacho_python-0.1.0/nacho/storage/base.py +71 -0
- {nacho_python-0.0.3 → nacho_python-0.1.0}/nacho/storage/file.py +6 -5
- nacho_python-0.1.0/nacho/storage/remote.py +353 -0
- {nacho_python-0.0.3 → nacho_python-0.1.0}/nacho/utils/__init__.py +1 -2
- {nacho_python-0.0.3 → nacho_python-0.1.0}/nacho/utils/io.py +35 -41
- {nacho_python-0.0.3 → nacho_python-0.1.0}/nacho/utils/path.py +51 -32
- nacho_python-0.1.0/nacho_python.egg-info/PKG-INFO +822 -0
- {nacho_python-0.0.3 → nacho_python-0.1.0}/nacho_python.egg-info/SOURCES.txt +2 -0
- {nacho_python-0.0.3 → nacho_python-0.1.0}/nacho_python.egg-info/requires.txt +5 -3
- {nacho_python-0.0.3 → nacho_python-0.1.0}/pyproject.toml +21 -12
- nacho_python-0.0.3/PKG-INFO +0 -676
- nacho_python-0.0.3/README.md +0 -631
- nacho_python-0.0.3/nacho/_version.py +0 -4
- nacho_python-0.0.3/nacho/cli/__init__.py +0 -11
- nacho_python-0.0.3/nacho/cli/main.py +0 -638
- nacho_python-0.0.3/nacho/server/auth.py +0 -93
- nacho_python-0.0.3/nacho/server/runtime.py +0 -452
- nacho_python-0.0.3/nacho/server/ui/index.html +0 -1292
- nacho_python-0.0.3/nacho/storage/base.py +0 -33
- nacho_python-0.0.3/nacho/storage/remote.py +0 -293
- nacho_python-0.0.3/nacho_python.egg-info/PKG-INFO +0 -676
- {nacho_python-0.0.3 → nacho_python-0.1.0}/LICENSE +0 -0
- {nacho_python-0.0.3 → nacho_python-0.1.0}/MANIFEST.in +0 -0
- {nacho_python-0.0.3 → nacho_python-0.1.0}/nacho_python.egg-info/dependency_links.txt +0 -0
- {nacho_python-0.0.3 → nacho_python-0.1.0}/nacho_python.egg-info/entry_points.txt +0 -0
- {nacho_python-0.0.3 → nacho_python-0.1.0}/nacho_python.egg-info/top_level.txt +0 -0
- {nacho_python-0.0.3 → nacho_python-0.1.0}/setup.cfg +0 -0
|
@@ -0,0 +1,822 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: nacho-python
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Nacho - Lightweight, schema-first dynamic configuration service
|
|
5
|
+
Author-email: "Nya Foundation Team (k3scat)" <k3scat@github.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/nya-foundation/nacho
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/nya-foundation/nacho/issues
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Requires-Python: >=3.9
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: pyyaml>=6.0
|
|
21
|
+
Requires-Dist: tomli>=2.0.0; python_version < "3.11"
|
|
22
|
+
Requires-Dist: tomli-w>=1.0.0
|
|
23
|
+
Provides-Extra: server
|
|
24
|
+
Requires-Dist: fastapi>=0.100.0; extra == "server"
|
|
25
|
+
Requires-Dist: uvicorn>=0.22.0; extra == "server"
|
|
26
|
+
Requires-Dist: websockets>=10.0; extra == "server"
|
|
27
|
+
Provides-Extra: remote
|
|
28
|
+
Requires-Dist: requests>=2.31.0; extra == "remote"
|
|
29
|
+
Requires-Dist: websocket-client>=1.8.0; extra == "remote"
|
|
30
|
+
Provides-Extra: schema
|
|
31
|
+
Requires-Dist: jsonschema>=4.0.0; extra == "schema"
|
|
32
|
+
Requires-Dist: rfc3987>=1.3.8; extra == "schema"
|
|
33
|
+
Provides-Extra: all
|
|
34
|
+
Requires-Dist: nacho-python[remote,schema,server]; extra == "all"
|
|
35
|
+
Provides-Extra: dev
|
|
36
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
37
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
38
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
39
|
+
Requires-Dist: httpx>=0.27.0; extra == "dev"
|
|
40
|
+
Requires-Dist: nacho-python[all]; extra == "dev"
|
|
41
|
+
Provides-Extra: lint
|
|
42
|
+
Requires-Dist: ruff>=0.5.0; extra == "lint"
|
|
43
|
+
Provides-Extra: uitest
|
|
44
|
+
Requires-Dist: playwright>=1.45; extra == "uitest"
|
|
45
|
+
Requires-Dist: pytest-playwright>=0.5.0; extra == "uitest"
|
|
46
|
+
Dynamic: license-file
|
|
47
|
+
|
|
48
|
+
# Nacho
|
|
49
|
+
|
|
50
|
+
<div align="center">
|
|
51
|
+
|
|
52
|
+
<pre>
|
|
53
|
+
_ _ _ ____ _ _ ___
|
|
54
|
+
| \ | | / \ / ___|| | | | / _ \
|
|
55
|
+
| \| | / _ \ | | | |_| || | | |
|
|
56
|
+
| |\ | / ___ \ | |___ | _ || |_| |
|
|
57
|
+
|_| \_|/_/ \_\ \____||_| |_| \___/
|
|
58
|
+
</pre>
|
|
59
|
+
|
|
60
|
+
<h3>Lightweight, self-hosted dynamic configuration service for Python</h3>
|
|
61
|
+
|
|
62
|
+
<p>
|
|
63
|
+
<a href="README.md">English</a> |
|
|
64
|
+
<a href="README_zh.md">中文</a> |
|
|
65
|
+
<a href="README_ja.md">日本語</a>
|
|
66
|
+
</p>
|
|
67
|
+
|
|
68
|
+
<div>
|
|
69
|
+
<a href="https://pypi.org/project/nacho-python/"><img src="https://img.shields.io/pypi/v/nacho-python.svg" alt="PyPI version"/></a>
|
|
70
|
+
<a href="https://pypi.org/project/nacho-python/"><img src="https://img.shields.io/pypi/pyversions/nacho-python.svg" alt="Python versions"/></a>
|
|
71
|
+
<a href="https://github.com/nya-foundation/nacho/blob/main/LICENSE"><img src="https://img.shields.io/github/license/nya-foundation/nacho.svg" alt="License"/></a>
|
|
72
|
+
<a href="https://pepy.tech/projects/nacho-python"><img src="https://static.pepy.tech/badge/nacho-python" alt="PyPI Downloads"/></a>
|
|
73
|
+
<a href="https://hub.docker.com/r/k3scat/nacho"><img src="https://img.shields.io/docker/pulls/k3scat/nacho" alt="Docker Pulls"/></a>
|
|
74
|
+
<a href="https://deepwiki.com/Nya-Foundation/Nacho"><img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki"/></a>
|
|
75
|
+
</div>
|
|
76
|
+
|
|
77
|
+
<div>
|
|
78
|
+
<a href="https://codecov.io/gh/nya-foundation/nacho"><img src="https://codecov.io/gh/nya-foundation/nacho/branch/main/graph/badge.svg" alt="Code Coverage"/></a>
|
|
79
|
+
<a href="https://github.com/nya-foundation/nacho/actions/workflows/scan.yml"><img src="https://github.com/nya-foundation/nacho/actions/workflows/scan.yml/badge.svg" alt="CodeQL and Dependencies Scan"/></a>
|
|
80
|
+
<a href="https://github.com/nya-foundation/nacho/actions/workflows/publish.yml"><img src="https://github.com/nya-foundation/nacho/actions/workflows/publish.yml/badge.svg" alt="CI/CD Builds"/></a>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
|
|
84
|
+
## Overview
|
|
85
|
+
|
|
86
|
+
Nacho is a self-hosted configuration service for Python. Run one Nacho server,
|
|
87
|
+
point your services at it with a few lines of code, and push configuration
|
|
88
|
+
changes that reach them live — no redeploy, no restart, no polling.
|
|
89
|
+
|
|
90
|
+
Every write is validated against a JSON Schema before it is stored, every
|
|
91
|
+
revision is kept in a rollback history, and a built-in single-file web UI
|
|
92
|
+
manages all of it. When you do not need a server, the same library works
|
|
93
|
+
standalone against a local file or an in-memory dict.
|
|
94
|
+
|
|
95
|
+
| Capability | Description |
|
|
96
|
+
|---|---|
|
|
97
|
+
| Centralized configuration | One server manages every service's configuration through a REST API, a CLI, and a web UI. |
|
|
98
|
+
| Live updates | Clients subscribe over WebSocket and receive changes the moment they happen. |
|
|
99
|
+
| Schema-first validation | Writes are checked against a JSON Schema and rejected before they reach storage. |
|
|
100
|
+
| History and rollback | Every revision is snapshotted; any revision can be inspected and restored. |
|
|
101
|
+
| Drop-in Python client | `RemoteStorageBackend` gives a remote application the same API as a local file. |
|
|
102
|
+
| Optimistic concurrency | Revision-checked writes turn lost updates into explicit `409 Conflict` responses. |
|
|
103
|
+
| Multi-format | JSON, YAML, and TOML are interchangeable across API payloads, stored files, and the UI editor. |
|
|
104
|
+
| Standalone mode | Use Nacho as a plain configuration library with no server at all. |
|
|
105
|
+
|
|
106
|
+
## Installation
|
|
107
|
+
|
|
108
|
+
Nacho keeps its core dependency footprint small through optional extras:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
pip install nacho-python[server] # run a configuration server
|
|
112
|
+
pip install nacho-python[remote] # connect a service to a server
|
|
113
|
+
pip install nacho-python[schema] # JSON Schema validation for standalone use
|
|
114
|
+
pip install nacho-python # core: standalone local file management
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Requires Python 3.9 or later. Docker images are available for containerized
|
|
118
|
+
deployments (see [Docker](#docker)).
|
|
119
|
+
|
|
120
|
+
## Quick start
|
|
121
|
+
|
|
122
|
+
Start a server:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
pip install nacho-python[server]
|
|
126
|
+
nacho server --config config.yaml --api-key "secure-key"
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
The server is now live at `http://127.0.0.1:8000` with a REST API, WebSocket
|
|
130
|
+
push, interactive API docs at `/docs`, and a management UI at `/ui`.
|
|
131
|
+
|
|
132
|
+
Connect a service:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
pip install nacho-python[remote]
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
from nacho import Nacho, RemoteStorageBackend
|
|
140
|
+
|
|
141
|
+
config = Nacho(
|
|
142
|
+
storage=RemoteStorageBackend(
|
|
143
|
+
url="http://127.0.0.1:8000",
|
|
144
|
+
app_name="my-service",
|
|
145
|
+
api_key="secure-key",
|
|
146
|
+
watch=True, # receive live updates over WebSocket
|
|
147
|
+
),
|
|
148
|
+
events=True,
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
# Read configuration exactly like a local dict
|
|
152
|
+
port = config.get_int("server.port", default=8000)
|
|
153
|
+
|
|
154
|
+
# React the instant someone changes it on the server
|
|
155
|
+
@config.on_change("features.*")
|
|
156
|
+
def on_flag_change(path, new_value, **kwargs):
|
|
157
|
+
print(f"{path} is now {new_value}")
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Change a value from the UI, the CLI, or the API, and every connected client
|
|
161
|
+
sees it immediately.
|
|
162
|
+
|
|
163
|
+
No server needed? Nacho also works as a standalone file-backed library:
|
|
164
|
+
`config = Nacho("config.yaml")`. See
|
|
165
|
+
[Standalone usage](#standalone-usage).
|
|
166
|
+
|
|
167
|
+
## Running a server
|
|
168
|
+
|
|
169
|
+
The CLI is the usual way to run a server:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
nacho server \
|
|
173
|
+
--config config.yaml \
|
|
174
|
+
--schema schema.json \
|
|
175
|
+
--port 8000 \
|
|
176
|
+
--api-key "secure-key" \
|
|
177
|
+
--data-dir ".nacho/apps" \
|
|
178
|
+
--history-limit 50
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
The server binds to `127.0.0.1` by default. Pass `--host 0.0.0.0` to accept
|
|
182
|
+
connections from other machines; the CLI prints a warning if you expose the
|
|
183
|
+
server without `--api-key`, because an unauthenticated server grants full
|
|
184
|
+
write access to anyone who can reach it.
|
|
185
|
+
|
|
186
|
+
Run exactly **one server process** per data directory. App state, revision
|
|
187
|
+
counters, and WebSocket subscriptions live in process memory, so running the
|
|
188
|
+
app behind multiple workers (e.g. `uvicorn --workers 2`) or pointing two
|
|
189
|
+
server processes at the same `--data-dir` produces inconsistent revisions and
|
|
190
|
+
missed live updates.
|
|
191
|
+
|
|
192
|
+
| Flag | Default | Description |
|
|
193
|
+
|---|---|---|
|
|
194
|
+
| `--host` | `127.0.0.1` | Bind address (`0.0.0.0` to listen on all interfaces) |
|
|
195
|
+
| `--port` | `8000` | Bind port |
|
|
196
|
+
| `--config`, `-c` | none | Configuration file to serve as an app |
|
|
197
|
+
| `--schema` | none | JSON Schema enforced for `--config` |
|
|
198
|
+
| `--app-name` | `default` | App name for the `--config` file |
|
|
199
|
+
| `--data-dir` | none | Directory for API-created app state and history |
|
|
200
|
+
| `--api-key` | none | Enable bearer-token authentication |
|
|
201
|
+
| `--read-only-api-key` | none | Additional key granting read access only |
|
|
202
|
+
| `--history-limit` | `50` | Revision snapshots kept per app (`0` disables history) |
|
|
203
|
+
| `--read-only` | off | Reject every write |
|
|
204
|
+
| `--reload` | off | Auto-reload for development |
|
|
205
|
+
|
|
206
|
+
### Embedding in an existing application
|
|
207
|
+
|
|
208
|
+
`NachoOrchestrator` wraps one or more `Nacho` instances in a FastAPI
|
|
209
|
+
application, so a server can also be constructed in code or mounted into an
|
|
210
|
+
existing app:
|
|
211
|
+
|
|
212
|
+
```python
|
|
213
|
+
from fastapi import FastAPI
|
|
214
|
+
from nacho import Nacho, NachoOrchestrator
|
|
215
|
+
|
|
216
|
+
app = FastAPI(title="My Application")
|
|
217
|
+
|
|
218
|
+
orchestrator = NachoOrchestrator(
|
|
219
|
+
apps={"config": Nacho("config.yaml", events=True)},
|
|
220
|
+
api_key="secure-key",
|
|
221
|
+
cors_origins=["https://admin.example.com"],
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
app.mount("/config", orchestrator.app) # configuration API under /config
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
Run it directly with `orchestrator.run(host="127.0.0.1", port=8000)` when it
|
|
228
|
+
is not mounted.
|
|
229
|
+
|
|
230
|
+
### Management UI
|
|
231
|
+
|
|
232
|
+
The server hosts a single-file web UI at `/ui` — no separate process, no build
|
|
233
|
+
step. It provides:
|
|
234
|
+
|
|
235
|
+
- App management: list, create, rename, describe, and delete apps.
|
|
236
|
+
- Configuration editing: a code editor for JSON, YAML, and TOML with syntax
|
|
237
|
+
highlighting, format switching, on-demand validation, and revision-aware
|
|
238
|
+
saves that surface conflicts instead of clobbering newer data.
|
|
239
|
+
- Schema editing: view, edit, or clear an app's JSON Schema; the current
|
|
240
|
+
configuration is re-checked against the new schema before it is accepted.
|
|
241
|
+
- History: browse revision snapshots and restore any of them with one click.
|
|
242
|
+
- Live updates: changes pushed over WebSocket are reflected in real time, and
|
|
243
|
+
unsaved local edits are preserved when a remote change arrives.
|
|
244
|
+
|
|
245
|
+
When the server runs with `--api-key`, the UI prompts for the key on first
|
|
246
|
+
load. The `/ui` page itself is public so the sign-in screen can load; every
|
|
247
|
+
API call behind it requires authentication.
|
|
248
|
+
|
|
249
|
+
### Authentication
|
|
250
|
+
|
|
251
|
+
Passing `--api-key` (or `api_key=` to `NachoOrchestrator`) enables bearer
|
|
252
|
+
authentication for the whole API. Clients send the key either as an
|
|
253
|
+
`Authorization: Bearer <key>` header or through the cookie the UI sets for
|
|
254
|
+
its own WebSocket handshake. Requests with a missing or wrong key receive
|
|
255
|
+
`401 Unauthorized`. The comparison is timing-safe.
|
|
256
|
+
|
|
257
|
+
A second key can be added with `--read-only-api-key` (or
|
|
258
|
+
`read_only_api_key=`). It authenticates GETs and WebSocket subscriptions but
|
|
259
|
+
receives `403 Forbidden` on any write — hand it to dashboards, pollers, and
|
|
260
|
+
services that only consume configuration, so the write credential never
|
|
261
|
+
leaves the operators who need it.
|
|
262
|
+
|
|
263
|
+
`/`, `/health`, `/ui`, `/docs`, `/redoc`, and `/openapi.json` stay public: the
|
|
264
|
+
API surface is not a secret, only the data behind it.
|
|
265
|
+
|
|
266
|
+
Cross-origin browser access is disabled unless you opt in with
|
|
267
|
+
`cors_origins=[...]` — the bundled UI is same-origin and the SDK/CLI are not
|
|
268
|
+
browsers, so a drive-by web page cannot reach a default server.
|
|
269
|
+
|
|
270
|
+
## REST API
|
|
271
|
+
|
|
272
|
+
Interactive documentation is available at `/docs` (Swagger UI) and `/redoc`
|
|
273
|
+
once the server is running.
|
|
274
|
+
|
|
275
|
+
### Payload format
|
|
276
|
+
|
|
277
|
+
Config and schema payloads are native JSON objects:
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
curl -X POST http://127.0.0.1:8000/api/apps \
|
|
281
|
+
-H "Authorization: Bearer secure-key" \
|
|
282
|
+
-H "Content-Type: application/json" \
|
|
283
|
+
-d '{
|
|
284
|
+
"name": "my-service",
|
|
285
|
+
"data": {"database": {"host": "localhost", "port": 5432}},
|
|
286
|
+
"schema": {"type": "object", "properties": {"database": {"type": "object"}}}
|
|
287
|
+
}'
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Payloads may also be sent as encoded strings in any supported format, which
|
|
291
|
+
is how the CLI and UI submit YAML and TOML:
|
|
292
|
+
|
|
293
|
+
```json
|
|
294
|
+
{"data": "database:\n host: localhost\n", "format": "yaml"}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### Revisions and optimistic concurrency
|
|
298
|
+
|
|
299
|
+
Every app carries a monotonically increasing revision, bumped on each
|
|
300
|
+
successful write. Reads of `/config` (full or per-path) return the current
|
|
301
|
+
revision in the `ETag` and `X-Nacho-Revision` response headers. Writes may
|
|
302
|
+
include a `revision` field stating the revision the client last saw; if the
|
|
303
|
+
server has moved on, the write fails with `409 Conflict` and the stored
|
|
304
|
+
configuration is left untouched:
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
curl -X PUT http://127.0.0.1:8000/api/apps/my-service/config/cache.ttl \
|
|
308
|
+
-H "Authorization: Bearer secure-key" \
|
|
309
|
+
-H "Content-Type: application/json" \
|
|
310
|
+
-d '{"value": 600, "revision": 3}'
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
Omitting `revision` performs an unconditional write.
|
|
314
|
+
|
|
315
|
+
The `ETag` also enables cheap polling: send it back as `If-None-Match` and
|
|
316
|
+
the server answers `304 Not Modified` — no body — until the revision moves.
|
|
317
|
+
|
|
318
|
+
```bash
|
|
319
|
+
curl -H 'If-None-Match: "3"' http://127.0.0.1:8000/api/apps/my-service/config
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### History and rollback
|
|
323
|
+
|
|
324
|
+
The server snapshots every revision (configuration, schema, and metadata)
|
|
325
|
+
into a per-app ring buffer — on disk under `data_dir/history/` when a data
|
|
326
|
+
directory is configured, in memory otherwise. `--history-limit` controls
|
|
327
|
+
retention.
|
|
328
|
+
|
|
329
|
+
Rollback is roll-forward: restoring revision 41 does not rewrite history but
|
|
330
|
+
creates a new revision whose content equals snapshot 41. The revision counter
|
|
331
|
+
stays monotonic, live clients are notified like on any other write, and a
|
|
332
|
+
rollback can itself be rolled back. A snapshot restores configuration and
|
|
333
|
+
schema together, so the result is always self-consistent.
|
|
334
|
+
|
|
335
|
+
```bash
|
|
336
|
+
curl http://127.0.0.1:8000/api/apps/my-service/history
|
|
337
|
+
curl http://127.0.0.1:8000/api/apps/my-service/history/41
|
|
338
|
+
curl -X POST http://127.0.0.1:8000/api/apps/my-service/rollback \
|
|
339
|
+
-H "Content-Type: application/json" \
|
|
340
|
+
-d '{"revision": 41, "expected_revision": 42}'
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
### Endpoint reference
|
|
344
|
+
|
|
345
|
+
System:
|
|
346
|
+
|
|
347
|
+
| Endpoint | Method | Description |
|
|
348
|
+
|---|---|---|
|
|
349
|
+
| `/health` | GET | Health check and instance summary |
|
|
350
|
+
| `/ui` | GET | Built-in web management UI |
|
|
351
|
+
| `/docs`, `/redoc` | GET | Interactive API documentation |
|
|
352
|
+
| `/api/convert` | POST | Convert a payload between JSON, YAML, and TOML |
|
|
353
|
+
|
|
354
|
+
App management:
|
|
355
|
+
|
|
356
|
+
| Endpoint | Method | Description |
|
|
357
|
+
|---|---|---|
|
|
358
|
+
| `/api/apps` | GET | List all apps |
|
|
359
|
+
| `/api/apps` | POST | Create an app |
|
|
360
|
+
| `/api/apps/{app}` | GET | Get app info |
|
|
361
|
+
| `/api/apps/{app}` | PUT | Replace an app's config, schema, and description |
|
|
362
|
+
| `/api/apps/{app}` | DELETE | Delete an app |
|
|
363
|
+
| `/api/apps/{app}/metadata` | PATCH | Rename an app or change its description |
|
|
364
|
+
|
|
365
|
+
Configuration and schema:
|
|
366
|
+
|
|
367
|
+
| Endpoint | Method | Description |
|
|
368
|
+
|---|---|---|
|
|
369
|
+
| `/api/apps/{app}/config` | GET | Get the full configuration |
|
|
370
|
+
| `/api/apps/{app}/config` | PUT | Replace the full configuration |
|
|
371
|
+
| `/api/apps/{app}/config/{path}` | GET | Get the value at a dotted path |
|
|
372
|
+
| `/api/apps/{app}/config/{path}` | PUT | Set the value at a dotted path |
|
|
373
|
+
| `/api/apps/{app}/config/{path}` | DELETE | Delete the key at a dotted path |
|
|
374
|
+
| `/api/apps/{app}/schema` | GET | Get the app's JSON Schema |
|
|
375
|
+
| `/api/apps/{app}/schema` | PUT | Replace or clear the app's JSON Schema |
|
|
376
|
+
| `/api/apps/{app}/validate` | POST | Validate a payload against the app's schema |
|
|
377
|
+
|
|
378
|
+
History:
|
|
379
|
+
|
|
380
|
+
| Endpoint | Method | Description |
|
|
381
|
+
|---|---|---|
|
|
382
|
+
| `/api/apps/{app}/history` | GET | List revision snapshots, newest first |
|
|
383
|
+
| `/api/apps/{app}/history/{revision}` | GET | Get one revision snapshot |
|
|
384
|
+
| `/api/apps/{app}/rollback` | POST | Restore a snapshot as a new revision |
|
|
385
|
+
|
|
386
|
+
Real-time:
|
|
387
|
+
|
|
388
|
+
| Endpoint | Protocol | Description |
|
|
389
|
+
|---|---|---|
|
|
390
|
+
| `/ws/{app}` | WebSocket | Receive the current config on subscribe, then every change |
|
|
391
|
+
|
|
392
|
+
The WebSocket is receive-only: the server sends an `initial_config` message
|
|
393
|
+
on subscribe followed by an `update` message per change, each carrying the
|
|
394
|
+
app name, revision, and full configuration. Writes always go through REST, so
|
|
395
|
+
there is never ambiguity about who owns the state.
|
|
396
|
+
|
|
397
|
+
## Remote clients
|
|
398
|
+
|
|
399
|
+
A remote client reads and writes through the REST API and receives pushes
|
|
400
|
+
over WebSocket. Once constructed, a remote-backed `Nacho` instance behaves
|
|
401
|
+
exactly like a file-backed one — the same `get`, `set`, `on_change`, and
|
|
402
|
+
schema APIs.
|
|
403
|
+
|
|
404
|
+
Requires `pip install nacho-python[remote]`.
|
|
405
|
+
|
|
406
|
+
```text
|
|
407
|
+
REST reads/writes
|
|
408
|
+
+-------------+ GET/PUT/PATCH/DELETE +----------------------+
|
|
409
|
+
| Python app | -----------------------> | Nacho server |
|
|
410
|
+
| Nacho | | REST API + Web UI |
|
|
411
|
+
| Remote | <----------------------- | File/dict storage |
|
|
412
|
+
| client | WebSocket pushes | Schema validation |
|
|
413
|
+
+-------------+ /ws/{app} +----------------------+
|
|
414
|
+
| ^
|
|
415
|
+
| on_change handlers |
|
|
416
|
+
+---------------------------------------------+
|
|
417
|
+
live config updates
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
```python
|
|
421
|
+
from nacho import Nacho, RemoteStorageBackend
|
|
422
|
+
|
|
423
|
+
storage = RemoteStorageBackend(
|
|
424
|
+
url="https://config-server.example.com",
|
|
425
|
+
app_name="my-service",
|
|
426
|
+
api_key="secure-key",
|
|
427
|
+
watch=True, # opt in to WebSocket updates
|
|
428
|
+
)
|
|
429
|
+
|
|
430
|
+
config = Nacho(storage=storage, events=True)
|
|
431
|
+
|
|
432
|
+
host = config.get("database.host")
|
|
433
|
+
|
|
434
|
+
@config.on_change("features.*")
|
|
435
|
+
def on_feature_change(path, new_value, **kwargs):
|
|
436
|
+
print(f"feature flag updated: {path} = {new_value}")
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
Connecting never mutates the server: a wrong API key fails loudly at
|
|
440
|
+
construction, reading a nonexistent app raises a clear error (so a typo
|
|
441
|
+
cannot silently return an empty config), and the first `save()` to a
|
|
442
|
+
nonexistent app creates it.
|
|
443
|
+
|
|
444
|
+
The backend is revision-aware. Every load and push records the server
|
|
445
|
+
revision it saw, and `save()` sends it back — if another client wrote in
|
|
446
|
+
between, `save()` raises `ConflictError` (with the server's expected/actual
|
|
447
|
+
revisions) instead of silently overwriting the other write. Call `load()`,
|
|
448
|
+
reapply your change, and save again:
|
|
449
|
+
|
|
450
|
+
```python
|
|
451
|
+
from nacho import ConflictError
|
|
452
|
+
|
|
453
|
+
try:
|
|
454
|
+
config.save()
|
|
455
|
+
except ConflictError:
|
|
456
|
+
config.load() # pick up the concurrent change
|
|
457
|
+
config.set("my.key", value)
|
|
458
|
+
config.save()
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
If the WebSocket connection drops, the watcher reconnects automatically with
|
|
462
|
+
a bounded number of consecutive retries (`reconnect=0` retries forever), and
|
|
463
|
+
the counter resets on every successful connection. Keepalive pings detect
|
|
464
|
+
half-open connections, and permanent failures (bad key, deleted app) stop
|
|
465
|
+
the retry loop with a clear log line instead of retrying forever. Stale or
|
|
466
|
+
out-of-order pushes are dropped, so the local snapshot never rolls backwards.
|
|
467
|
+
|
|
468
|
+
The CLI covers the same ground without the SDK — see
|
|
469
|
+
[Command-line interface](#command-line-interface).
|
|
470
|
+
|
|
471
|
+
## Event system
|
|
472
|
+
|
|
473
|
+
With `events=True`, Nacho dispatches change notifications after every
|
|
474
|
+
successful write, whether the change was made locally or pushed from a
|
|
475
|
+
server. Events carry the changed path, old value, new value, and event type.
|
|
476
|
+
|
|
477
|
+
```python
|
|
478
|
+
from nacho import Nacho, EventType
|
|
479
|
+
|
|
480
|
+
config = Nacho("config.yaml", events=True)
|
|
481
|
+
|
|
482
|
+
# Fires for any change to a key under "database"
|
|
483
|
+
@config.on_change("database.*")
|
|
484
|
+
def on_db_change(path, old_value, new_value, **kwargs):
|
|
485
|
+
print(f"database key changed: {path}")
|
|
486
|
+
|
|
487
|
+
# Fires once per write operation (aggregate event)
|
|
488
|
+
@config.on_change("@global")
|
|
489
|
+
def on_any_change(**kwargs):
|
|
490
|
+
print("config was modified")
|
|
491
|
+
|
|
492
|
+
# Fires for CREATE or UPDATE events under "cache"
|
|
493
|
+
@config.on_event([EventType.CREATE, EventType.UPDATE], path_pattern="cache.*")
|
|
494
|
+
def on_cache_change(event_type, path, new_value, **kwargs):
|
|
495
|
+
print(f"{event_type.name} {path} = {new_value}")
|
|
496
|
+
|
|
497
|
+
config.set("database.host", "new-host") # on_db_change, on_any_change
|
|
498
|
+
config.set("cache.ttl", 600) # on_cache_change (CREATE)
|
|
499
|
+
config.set("cache.ttl", 300) # on_cache_change (UPDATE)
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
Path pattern reference:
|
|
503
|
+
|
|
504
|
+
| Pattern | Fires when |
|
|
505
|
+
|---|---|
|
|
506
|
+
| `None` (default) | Any change at any path |
|
|
507
|
+
| `"@global"` | Once per write operation (aggregate) |
|
|
508
|
+
| `"*"` | Any per-key event (not the aggregate) |
|
|
509
|
+
| `"database.*"` | Any key nested under `database` |
|
|
510
|
+
|
|
511
|
+
Handlers may be sync or async. Async handlers are scheduled on the running
|
|
512
|
+
event loop when one exists, and executed with `asyncio.run()` otherwise.
|
|
513
|
+
Registering a handler on an instance created without `events=True` logs a
|
|
514
|
+
warning, because the handler would never fire.
|
|
515
|
+
|
|
516
|
+
## Schema validation
|
|
517
|
+
|
|
518
|
+
Nacho enforces the schema on every write. An invalid value raises
|
|
519
|
+
`ValidationError` before the change is applied, so the configuration is never
|
|
520
|
+
left in an invalid state. The same guarantee applies to local writes and to
|
|
521
|
+
writes accepted by the server.
|
|
522
|
+
|
|
523
|
+
Standalone usage requires `pip install nacho-python[schema]`.
|
|
524
|
+
|
|
525
|
+
```json
|
|
526
|
+
{
|
|
527
|
+
"type": "object",
|
|
528
|
+
"required": ["database"],
|
|
529
|
+
"properties": {
|
|
530
|
+
"database": {
|
|
531
|
+
"type": "object",
|
|
532
|
+
"required": ["host", "port"],
|
|
533
|
+
"properties": {
|
|
534
|
+
"host": {"type": "string"},
|
|
535
|
+
"port": {"type": "integer", "minimum": 1024}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
```python
|
|
543
|
+
from nacho import Nacho, ValidationError
|
|
544
|
+
|
|
545
|
+
config = Nacho("config.yaml", schema="schema.json")
|
|
546
|
+
|
|
547
|
+
# An invalid write raises immediately; the config is not modified
|
|
548
|
+
try:
|
|
549
|
+
config.set("database.port", "not-a-number")
|
|
550
|
+
except ValidationError as e:
|
|
551
|
+
print(e.errors) # list of violation strings
|
|
552
|
+
|
|
553
|
+
# Inspect the current config without writing
|
|
554
|
+
errors = config.validate()
|
|
555
|
+
|
|
556
|
+
# Validate an arbitrary dict against the schema
|
|
557
|
+
errors = config.check({"database": {"host": "localhost", "port": 80}})
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
## Standalone usage
|
|
561
|
+
|
|
562
|
+
Nacho does not require a server. Point it at a local file, or hand it a plain
|
|
563
|
+
dict, and it works as a self-contained configuration library for scripts,
|
|
564
|
+
tests, and single-process applications. Everything below behaves identically
|
|
565
|
+
with a file, a dict, or a remote server behind it.
|
|
566
|
+
|
|
567
|
+
### Reading and writing
|
|
568
|
+
|
|
569
|
+
```python
|
|
570
|
+
from nacho import Nacho
|
|
571
|
+
|
|
572
|
+
config = Nacho({"database": {"host": "127.0.0.1", "port": 5432}}) # in-memory
|
|
573
|
+
config = Nacho("config.yaml") # file-backed
|
|
574
|
+
|
|
575
|
+
# Typed reads with sensible coercion
|
|
576
|
+
host = config.get("database.host")
|
|
577
|
+
port = config.get_int("database.port")
|
|
578
|
+
debug = config.get_bool("app.debug")
|
|
579
|
+
tags = config.get_list("app.tags")
|
|
580
|
+
options = config.get_dict("app.options")
|
|
581
|
+
|
|
582
|
+
config.update({"logging": {"level": "DEBUG"}}) # deep-merge
|
|
583
|
+
config.replace({"database": {"host": "prod-db", "port": 5432}})
|
|
584
|
+
config.delete("legacy.setting")
|
|
585
|
+
config.load() # reload from storage
|
|
586
|
+
config.save() # persist to storage
|
|
587
|
+
print(config.json()) # export as a JSON string
|
|
588
|
+
```
|
|
589
|
+
|
|
590
|
+
### Transactions
|
|
591
|
+
|
|
592
|
+
Group multiple writes into one atomic operation. The transaction commits when
|
|
593
|
+
the block exits cleanly and is discarded on any exception. Commit replays the
|
|
594
|
+
transaction's operations onto the *current* configuration, so an unrelated
|
|
595
|
+
write that landed while the transaction was open is preserved, not discarded:
|
|
596
|
+
|
|
597
|
+
```python
|
|
598
|
+
with config.transaction() as txn:
|
|
599
|
+
txn.set("database.host", "new-host")
|
|
600
|
+
txn.set("database.port", 5433)
|
|
601
|
+
# Handlers fire once here with the aggregated changes
|
|
602
|
+
config.save()
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
### Environment variable overrides
|
|
606
|
+
|
|
607
|
+
Pass `env_prefix` to overlay environment variables on the configuration at
|
|
608
|
+
load time. Variable names follow `{PREFIX}_{NESTED_KEY}`, with nesting levels
|
|
609
|
+
separated by the delimiter (default `_`):
|
|
610
|
+
|
|
611
|
+
```bash
|
|
612
|
+
export MYAPP_DATABASE_HOST=prod-db.example.com
|
|
613
|
+
export MYAPP_DATABASE_PORT=5433
|
|
614
|
+
export MYAPP_FEATURES_ENABLED=true
|
|
615
|
+
```
|
|
616
|
+
|
|
617
|
+
```python
|
|
618
|
+
config = Nacho("config.yaml", env_prefix="MYAPP")
|
|
619
|
+
|
|
620
|
+
config.get("database.host") # "prod-db.example.com"
|
|
621
|
+
config.get_int("database.port") # 5433
|
|
622
|
+
config.get_bool("features.enabled") # True
|
|
623
|
+
```
|
|
624
|
+
|
|
625
|
+
Values are coerced where unambiguous: `true`/`false`/`yes`/`no`/`on`/`off`
|
|
626
|
+
become booleans, numeric strings become numbers (`"1"` is the integer 1, not
|
|
627
|
+
a boolean), and JSON-looking strings are parsed as JSON. Floats are only
|
|
628
|
+
parsed when the text round-trips, so `MYAPP_VERSION=3.10` stays the string
|
|
629
|
+
`"3.10"`, and quoting a value (`MYAPP_PORT='"8080"'`) forces it to stay a
|
|
630
|
+
string. Everything else stays a string.
|
|
631
|
+
|
|
632
|
+
Keys with underscores in their names use a doubled delimiter for nesting:
|
|
633
|
+
`MYAPP_DB__MAX_CONNECTIONS` sets `db.max_connections`. Env overrides are
|
|
634
|
+
runtime-only overlays: `save()` persists the stored configuration, not the
|
|
635
|
+
overlaid view.
|
|
636
|
+
|
|
637
|
+
## Command-line interface
|
|
638
|
+
|
|
639
|
+
```bash
|
|
640
|
+
nacho --help
|
|
641
|
+
nacho --version
|
|
642
|
+
```
|
|
643
|
+
|
|
644
|
+
Every remote command takes `--remote <url>`, `--app-name <name>` (default
|
|
645
|
+
`default`), and `--api-key <key>`. Errors are written to stderr, and exit
|
|
646
|
+
codes distinguish failure classes so scripts can branch without parsing
|
|
647
|
+
messages:
|
|
648
|
+
|
|
649
|
+
| Exit code | Meaning |
|
|
650
|
+
|---|---|
|
|
651
|
+
| 0 | Success |
|
|
652
|
+
| 1 | Generic error (schema violation, transport failure, missing extras) |
|
|
653
|
+
| 2 | Usage error (bad flags or arguments) |
|
|
654
|
+
| 3 | Not found (missing app, key, path, or history revision) |
|
|
655
|
+
| 4 | Revision conflict (a concurrent write won) |
|
|
656
|
+
| 5 | Authentication failure (bad or missing API key, read-only server) |
|
|
657
|
+
|
|
658
|
+
Output is rendered in `--format {json,yaml,toml}` (default `json`), so every
|
|
659
|
+
command's output is machine-parseable; `nacho get missing.key` exits 3 with a
|
|
660
|
+
stderr message instead of printing `None`.
|
|
661
|
+
|
|
662
|
+
### Values
|
|
663
|
+
|
|
664
|
+
```bash
|
|
665
|
+
# Read a key, or the whole config, locally or remotely
|
|
666
|
+
nacho get database.host --config config.yaml
|
|
667
|
+
nacho get --format json --remote http://config-server:8000 --app-name my-service
|
|
668
|
+
|
|
669
|
+
# Include the current revision in the output
|
|
670
|
+
nacho get --show-revision --format json --remote http://config-server:8000
|
|
671
|
+
|
|
672
|
+
# Write and delete, with optional conflict-safe revision checks
|
|
673
|
+
nacho set cache.ttl 600 --remote http://config-server:8000 --revision 3
|
|
674
|
+
nacho delete legacy.setting --remote http://config-server:8000 --revision 4
|
|
675
|
+
|
|
676
|
+
# Force a type when auto-detection would guess wrong
|
|
677
|
+
nacho set app.version 3.10 --type str --remote http://config-server:8000
|
|
678
|
+
nacho set app.flags '{"beta": true}' --type json --remote http://config-server:8000
|
|
679
|
+
|
|
680
|
+
# Local file equivalents
|
|
681
|
+
nacho set database.port 5432 --config config.yaml
|
|
682
|
+
nacho delete legacy.setting --config config.yaml
|
|
683
|
+
```
|
|
684
|
+
|
|
685
|
+
Local writes are read-modify-write on the file with no cross-process lock:
|
|
686
|
+
the file itself is written atomically, but two `nacho set` commands racing on
|
|
687
|
+
the same file can lose one of the updates. Point concurrent writers at a
|
|
688
|
+
server (`--remote`) instead — that is what revision-checked writes are for.
|
|
689
|
+
|
|
690
|
+
### Apps
|
|
691
|
+
|
|
692
|
+
```bash
|
|
693
|
+
nacho apps list --remote http://config-server:8000
|
|
694
|
+
nacho apps create my-service \
|
|
695
|
+
--remote http://config-server:8000 \
|
|
696
|
+
--description "Core service" \
|
|
697
|
+
--config config.yaml \
|
|
698
|
+
--schema schema.json
|
|
699
|
+
nacho apps show --remote http://config-server:8000 --app-name my-service
|
|
700
|
+
nacho apps rename my-service-v2 --remote http://config-server:8000 --app-name my-service
|
|
701
|
+
nacho apps describe "Payments service" --remote http://config-server:8000 --app-name my-service
|
|
702
|
+
nacho apps delete my-service --remote http://config-server:8000
|
|
703
|
+
```
|
|
704
|
+
|
|
705
|
+
### Schemas and validation
|
|
706
|
+
|
|
707
|
+
```bash
|
|
708
|
+
# Print or replace the schema the server enforces
|
|
709
|
+
nacho schema get --remote http://config-server:8000 --app-name my-service
|
|
710
|
+
nacho schema push schema.json --remote http://config-server:8000 --app-name my-service
|
|
711
|
+
|
|
712
|
+
# Validate a local file against the server's stored schema
|
|
713
|
+
nacho validate --config config.yaml --remote http://config-server:8000 --app-name my-service
|
|
714
|
+
|
|
715
|
+
# Validate against a local schema file instead
|
|
716
|
+
nacho validate --config config.yaml --schema schema.json
|
|
717
|
+
```
|
|
718
|
+
|
|
719
|
+
### History and rollback
|
|
720
|
+
|
|
721
|
+
```bash
|
|
722
|
+
nacho history list --remote http://config-server:8000 --app-name my-service
|
|
723
|
+
nacho history show 41 --remote http://config-server:8000 --app-name my-service
|
|
724
|
+
|
|
725
|
+
# What changed between two revisions — or between revision 41 and now
|
|
726
|
+
nacho history diff 41 42 --remote http://config-server:8000 --app-name my-service
|
|
727
|
+
nacho history diff 41 --remote http://config-server:8000 --app-name my-service
|
|
728
|
+
|
|
729
|
+
# Restore revision 41 as a new revision; --revision-check makes it conflict-safe
|
|
730
|
+
nacho rollback 41 --remote http://config-server:8000 --app-name my-service --revision-check 42
|
|
731
|
+
```
|
|
732
|
+
|
|
733
|
+
### Live updates
|
|
734
|
+
|
|
735
|
+
```bash
|
|
736
|
+
# Print the current config, then one JSON line per change (Ctrl+C to stop)
|
|
737
|
+
nacho watch --remote http://config-server:8000 --app-name my-service
|
|
738
|
+
```
|
|
739
|
+
|
|
740
|
+
### Scaffolding
|
|
741
|
+
|
|
742
|
+
```bash
|
|
743
|
+
# Create a config file from a built-in template
|
|
744
|
+
nacho init config.yaml --template default
|
|
745
|
+
# Templates: empty, default, web-app, api-service, microservice
|
|
746
|
+
```
|
|
747
|
+
|
|
748
|
+
## Docker
|
|
749
|
+
|
|
750
|
+
Nacho ships a multi-stage `Dockerfile` producing a small Alpine-based image
|
|
751
|
+
that runs the configuration server as a non-root user, with a container
|
|
752
|
+
health check against `/health`. Published images are available on Docker Hub
|
|
753
|
+
and GHCR:
|
|
754
|
+
|
|
755
|
+
```bash
|
|
756
|
+
docker pull k3scat/nacho:latest
|
|
757
|
+
docker pull ghcr.io/nya-foundation/nacho:latest
|
|
758
|
+
|
|
759
|
+
# Run the server (UI at http://localhost:8000/ui)
|
|
760
|
+
docker run -p 8000:8000 k3scat/nacho:latest
|
|
761
|
+
|
|
762
|
+
# Run with authentication enabled
|
|
763
|
+
docker run -p 8000:8000 k3scat/nacho:latest \
|
|
764
|
+
server --host 0.0.0.0 --config config.yaml --api-key "secure-key"
|
|
765
|
+
|
|
766
|
+
# Mount your own config for the default app
|
|
767
|
+
docker run -p 8000:8000 \
|
|
768
|
+
-v "$(pwd)/config.yaml:/app/config.yaml" k3scat/nacho:latest
|
|
769
|
+
```
|
|
770
|
+
|
|
771
|
+
Or with Compose:
|
|
772
|
+
|
|
773
|
+
```bash
|
|
774
|
+
docker compose up --build
|
|
775
|
+
```
|
|
776
|
+
|
|
777
|
+
The image entrypoint is `nacho`; the default command is
|
|
778
|
+
`server --host 0.0.0.0 --config config.yaml`. Append any `nacho server` flags
|
|
779
|
+
to override the defaults. The container exposes port `8000`.
|
|
780
|
+
|
|
781
|
+
## Operational notes
|
|
782
|
+
|
|
783
|
+
- Dot-notation paths are intentionally simple. Literal dots in key names and
|
|
784
|
+
numeric string keys are ambiguous; prefer nested object keys.
|
|
785
|
+
- The built-in API-key authentication suits local, private, and single-tenant
|
|
786
|
+
deployments. Shared production deployments should add scoped tokens, audit
|
|
787
|
+
logging, and rate limiting in front of the service.
|
|
788
|
+
- Server state is file-backed and single-process. The revision counter is
|
|
789
|
+
authoritative in memory, so run one server process per data directory; the
|
|
790
|
+
storage abstraction is the boundary to implement a stronger backend if you
|
|
791
|
+
need multi-process or high-availability operation.
|
|
792
|
+
- Editing a `--config` file by hand while the server is running is not
|
|
793
|
+
detected; the server's next write wins. Make changes through the API, CLI,
|
|
794
|
+
or UI.
|
|
795
|
+
|
|
796
|
+
## Development
|
|
797
|
+
|
|
798
|
+
```bash
|
|
799
|
+
git clone https://github.com/nya-foundation/nacho.git
|
|
800
|
+
cd nacho
|
|
801
|
+
uv sync --all-extras
|
|
802
|
+
|
|
803
|
+
uv run pytest # fast suites (unit + smoke), 95% coverage gate
|
|
804
|
+
uv run pytest -m "integration or e2e" --no-cov # live-server suites
|
|
805
|
+
uv run pytest -m docker --no-cov # builds and exercises the Docker image
|
|
806
|
+
uv run playwright install chromium # one-time browser download
|
|
807
|
+
uv run pytest -m ui --no-cov # browser-driven web UI suite
|
|
808
|
+
|
|
809
|
+
uvx ruff format . && uvx ruff check . # formatting and lint (enforced in CI)
|
|
810
|
+
```
|
|
811
|
+
|
|
812
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for the branch model, code style, and
|
|
813
|
+
release process.
|
|
814
|
+
|
|
815
|
+
## Community
|
|
816
|
+
|
|
817
|
+
Open an issue on [GitHub](https://github.com/nya-foundation/nacho/issues) or
|
|
818
|
+
join the [Nya Foundation Discord](https://discord.gg/jXAxVPSs7K).
|
|
819
|
+
|
|
820
|
+
## License
|
|
821
|
+
|
|
822
|
+
MIT — see [LICENSE](LICENSE) for details.
|