Roll out the tool runtime to the remaining tools+events modules (ADR 0052/0051)
Nineteen modules gain a broker-bound runtime container that serves the module's tools under its own scoped account: bazarr, gitea, grafana, home-assistant, icecast, influxdb, jackett, keycloak, mailu, nextcloud, nodered, nzbget, ombi, photos, portainer, qbittorrent, searxng, tautulli, verdaccio. Config is the assignment's, not the manifest's (ADR 0051): each client's fromEnv overlays a settings-merged config file (MESH_<M>_CONFIG_FILE) over its env fallbacks, so URL and credentials come from `settings set`, with the URL defaulting to the server on the node. nextcloud and mailu also mount the docker socket for their exec-based tools. Proven in the mesh-lab: assigned-grafana green — settings deliver the URL and token, the runtime reads the merged config and serves grafana's tools under the scoped account, with nothing in the manifest. Two gaps this surfaced are filed as hq issues 008 (a provider runtime's seal key) and 009 (a settings change does not restart a container runtime). Claude-Session: https://claude.ai/code/session_01LrgweAeERJYBg88c5cKDzF
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
// by an API key sent as the `x-api-key` header). The client speaks only what the tools and the
|
||||
// item-added event need: server version and statistics, albums, and recent assets.
|
||||
|
||||
import { readFileSync } from "node:fs";
|
||||
|
||||
export interface PhotosServerInfo {
|
||||
version: string;
|
||||
photos?: number;
|
||||
@@ -24,6 +26,13 @@ export interface PhotosAsset {
|
||||
createdAt?: string;
|
||||
}
|
||||
|
||||
/** The settings-merged config the mesh delivers (novox/hq ADR 0051): { url, apiKey, token, password, user, ... }. */
|
||||
function meshConfig(file?: string): Record<string, string> {
|
||||
if (!file) return {};
|
||||
try { return JSON.parse(readFileSync(file, "utf8")) as Record<string, string>; }
|
||||
catch { return {}; }
|
||||
}
|
||||
|
||||
export class PhotosClient {
|
||||
readonly baseUrl: string;
|
||||
|
||||
@@ -38,8 +47,9 @@ export class PhotosClient {
|
||||
* the API key is required, and without it the module contributes nothing rather than reaching an
|
||||
* unauthenticated endpoint. */
|
||||
static fromEnv(env: NodeJS.ProcessEnv = process.env): PhotosClient {
|
||||
const url = env.MESH_PHOTOS_URL ?? `http://127.0.0.1:${env.PHOTOS_PORT ?? "2283"}`;
|
||||
const key = env.MESH_PHOTOS_API_KEY;
|
||||
const cfg = meshConfig(env.MESH_PHOTOS_CONFIG_FILE);
|
||||
const url = cfg.url ?? env.MESH_PHOTOS_URL ?? `http://127.0.0.1:${env.PHOTOS_PORT ?? "2283"}`;
|
||||
const key = cfg.apiKey ?? env.MESH_PHOTOS_API_KEY;
|
||||
if (!key) throw new Error("no photos API key — set MESH_PHOTOS_API_KEY");
|
||||
return new PhotosClient(url, key);
|
||||
}
|
||||
|
||||
@@ -47,6 +47,25 @@
|
||||
"/etc/photos/store.json:/etc/photos/store.json:ro",
|
||||
"/etc/photos/store.secret:/etc/photos/store.secret:ro"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "runtime",
|
||||
"type": "container",
|
||||
"name": "mesh-photos",
|
||||
"image": "mesh-runtime-photos@sha256:0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"network": "host",
|
||||
"volumes": [
|
||||
"/var/lib/mesh/photos/broker:/run/secrets/broker:ro",
|
||||
"/var/lib/mesh/photos/config.json:/run/config/config.json:ro"
|
||||
],
|
||||
"env": {
|
||||
"MESH_BROKER_FILE": "/run/secrets/broker",
|
||||
"MESH_PHOTOS_URL": "http://127.0.0.1:2283",
|
||||
"MESH_PHOTOS_CONFIG_FILE": "/run/config/config.json"
|
||||
}
|
||||
}
|
||||
],
|
||||
"capabilities": [
|
||||
"container-runtime"
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user