Turns the empty scaffold into a working Nova extension for Apple Container and container-compose, in the shape of the Docker Suite extension. Sidebar (Scripts/Sidebar): - System, Containers, Images, Volumes and Networks sections - Containers grouped into compose projects via the com.docker.compose.project label container-compose stamps; project rows drive compose up/down/build against the matching workspace file - Lifecycle, shell, logs, inspect, browse and copy commands per resource - Apple Container publishes no event stream, so the sidebar polls while visible and only reloads a section when a fingerprint of its data changes, which keeps selection and expansion intact Hostnames (Scripts/Hostnames.js): - A container's hostname is <name>.<domain> and the domain lives in Apple Container's config.toml, which has no CLI setter, so the Hostname Domain preference reads and writes that file directly - Changing it offers to register the domain with macOS and restart the services; the write preserves the file's other tables and its mode Language support: - Dockerfile and Compose syntaxes backed by tree-sitter grammars built by Tools/build-syntaxes.sh, pinned to revisions that generate ABI 14 - The Compose syntax is named dockercompose because that is the languageId docker-language-server recognises compose files by - docker-language-server is downloaded on first use rather than bundled, at roughly 40 MB Icons are generated by Tools/make-icons.py so they can be regenerated rather than hand-maintained. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UnSBcR5Lywz5Fbj5FmVbfc
61 lines
1.4 KiB
JavaScript
61 lines
1.4 KiB
JavaScript
//
|
|
// Networks.
|
|
//
|
|
|
|
const { Element } = require("./Element");
|
|
|
|
const ROLE_LABEL = "com.apple.container.resource.role";
|
|
|
|
class NetworkModel extends Element {
|
|
constructor(json) {
|
|
let configuration = (json && json.configuration) || {};
|
|
let status = (json && json.status) || {};
|
|
|
|
super(`network:${configuration.name || json.id}`);
|
|
|
|
this.name = configuration.name || json.id;
|
|
this.mode = configuration.mode || "";
|
|
this.plugin = configuration.plugin || "";
|
|
this.created = configuration.creationDate || null;
|
|
this.labels = configuration.labels || {};
|
|
this.subnet = status.ipv4Subnet || "";
|
|
this.gateway = status.ipv4Gateway || "";
|
|
this.subnet6 = status.ipv6Subnet || "";
|
|
}
|
|
|
|
get revision() {
|
|
return `${this.subnet}:${this.gateway}:${this.mode}`;
|
|
}
|
|
|
|
get builtin() {
|
|
return this.labels[ROLE_LABEL] === "builtin";
|
|
}
|
|
|
|
get tooltip() {
|
|
let lines = [`Network:\t${this.name}`];
|
|
|
|
if (this.mode) {
|
|
lines.push(`Mode:\t${this.mode}`);
|
|
}
|
|
if (this.subnet) {
|
|
lines.push(`Subnet:\t${this.subnet}`);
|
|
}
|
|
if (this.gateway) {
|
|
lines.push(`Gateway:\t${this.gateway}`);
|
|
}
|
|
if (this.plugin) {
|
|
lines.push(`Plugin:\t${this.plugin}`);
|
|
}
|
|
|
|
return lines.join("\n");
|
|
}
|
|
}
|
|
|
|
function build(list) {
|
|
return (list || [])
|
|
.map((entry) => new NetworkModel(entry))
|
|
.sort((left, right) => left.name.localeCompare(right.name));
|
|
}
|
|
|
|
module.exports = { NetworkModel, build };
|