@infosupport/huddle-cli 0.0.0-experiment-66.35.1 → 0.0.0-experiment-66.36.1

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.
package/dist/firewall.js CHANGED
@@ -12,6 +12,7 @@ exports.runFirewallGroup = runFirewallGroup;
12
12
  exports.runFirewallFolder = runFirewallFolder;
13
13
  const fs_1 = __importDefault(require("fs"));
14
14
  const api_1 = require("./api");
15
+ const config_1 = require("./config");
15
16
  const utils_1 = require("./utils");
16
17
  async function runFirewallList(opts) {
17
18
  const qs = new URLSearchParams({ status: opts.status ?? 'requested' });
@@ -262,7 +263,11 @@ async function runFirewallFolder(opts) {
262
263
  if (!path)
263
264
  throw new Error('Usage: huddle firewall folder set <path>');
264
265
  await (0, api_1.post)('/api/settings', { firewallRulesFolder: path });
265
- console.log((0, utils_1.green)(`[OK] Firewall rules folder set to ${(0, utils_1.cyan)(path)} (re-read now and on startup)`));
266
+ // Persist on the host too, so `huddle init`/`restart` mounts the folder into
267
+ // the gateway container (which otherwise cannot see host paths).
268
+ (0, config_1.writeConfig)({ ...(0, config_1.readConfig)(), firewallRulesFolder: path });
269
+ console.log((0, utils_1.green)(`[OK] Firewall rules folder set to ${(0, utils_1.cyan)(path)}`));
270
+ console.log((0, utils_1.dim)(' Run `huddle restart` to mount it into the gateway, then it is re-read on start & reload.'));
266
271
  return;
267
272
  }
268
273
  if (action === 'reload') {
package/dist/index.js CHANGED
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const api_1 = require("./api");
10
+ const config_1 = require("./config");
10
11
  const start_1 = require("./start");
11
12
  const firewall_1 = require("./firewall");
12
13
  const init_1 = require("./init");
@@ -17,7 +18,7 @@ const utils_1 = require("./utils");
17
18
  const experiment_1 = require("./experiment");
18
19
  const VALUE_FLAGS = new Set(['url', 'ide', 'name', 'image', 'workspace', 'container', 'status', 'runtime', 'experiment', 'path', 'out', 'ca-path', 'output']);
19
20
  const BOOLEAN_FLAGS = new Set(['help', 'h', 'empty', 'i', 'interactive', 'version', 'v', 'deny', 'replace', 'docker-socket', 'force']);
20
- const COMMANDS = new Set(['start', 'firewall', 'fw', 'init', 'experiment', 'migrate', 'help', 'version']);
21
+ const COMMANDS = new Set(['start', 'firewall', 'fw', 'init', 'restart', 'experiment', 'migrate', 'help', 'version']);
21
22
  function parseArgs(argv) {
22
23
  const positional = [];
23
24
  const flags = {};
@@ -94,6 +95,8 @@ Usage:
94
95
  huddle start [options] [folder] Explicitly start a devcontainer
95
96
  huddle init [options] Pull the Huddle + devcontainer base images and
96
97
  start them via Docker or Podman
98
+ huddle restart Recreate the gateway (e.g. to mount a changed
99
+ team firewall-rules folder)
97
100
  huddle migrate [folder] Wire an existing docker-compose devcontainer
98
101
  behind Huddle by generating an override file
99
102
  huddle firewall list [options] Show firewall requests
@@ -217,6 +220,26 @@ async function main() {
217
220
  await (0, init_1.runInit)(initOpts, (0, images_1.resolveImages)());
218
221
  return;
219
222
  }
223
+ if (cmd === 'restart') {
224
+ // Stop + recreate the gateway (runInit does `rm -f` first) so a changed
225
+ // team firewall-rules folder gets mounted. Refresh the folder from the
226
+ // running gateway's DB setting so a value set in the portal takes effect.
227
+ const initOpts = { runtime: flagString(flags, 'runtime') };
228
+ try {
229
+ const s = await (0, api_1.get)('/api/settings');
230
+ const folder = (s.firewallRulesFolder ?? '').trim();
231
+ const cfg = (0, config_1.readConfig)();
232
+ if (folder !== (cfg.firewallRulesFolder ?? '')) {
233
+ (0, config_1.writeConfig)({ ...cfg, firewallRulesFolder: folder || undefined });
234
+ }
235
+ }
236
+ catch {
237
+ // Gateway not reachable — fall back to the cached folder in the CLI config.
238
+ }
239
+ (0, experiment_1.ensureCliForChannel)(process.argv.slice(2));
240
+ await (0, init_1.runInit)(initOpts, (0, images_1.resolveImages)());
241
+ return;
242
+ }
220
243
  if (cmd === 'experiment') {
221
244
  const subCmd = sub ?? 'status';
222
245
  if (subCmd === 'use') {
package/dist/init.js CHANGED
@@ -145,6 +145,15 @@ async function runInit(opts, images) {
145
145
  // network (moby/moby#36174). Which source IP the gateway sees for forwarded
146
146
  // traffic no longer matters — the control plane authenticates with the
147
147
  // operator token instead of source-IP filtering.
148
+ // Team-managed firewall-rules folder (#69): the gateway can only read folders
149
+ // the CLI binds into its container, so mount the configured host folder at the
150
+ // same path (so the path stored in the DB setting resolves identically inside
151
+ // the gateway). Read-only — Huddle never writes back to the team's Git folder.
152
+ const fwFolder = cfg.firewallRulesFolder?.trim();
153
+ const fwMountFlag = fwFolder ? ` -v "${fwFolder}:${fwFolder}:ro"` : '';
154
+ if (fwFolder) {
155
+ console.log((0, utils_1.dim)(` Mounting firewall-rules folder: ${fwFolder}`));
156
+ }
148
157
  run(`${rt} run -d` +
149
158
  ` --name ${CONTAINER}` +
150
159
  ` --network ${runtime.defaultNetwork}` +
@@ -155,6 +164,7 @@ async function runInit(opts, images) {
155
164
  ` -v ${VOLUME}:/data` +
156
165
  ` -v ${runtime.socketPath}:/var/run/docker.sock` +
157
166
  ` -v "${hostTmpSockets}:/tmp/dc-sockets"` +
167
+ fwMountFlag +
158
168
  (0, images_1.gatewayEnvFlags)(images) +
159
169
  ` ${IMAGE}`);
160
170
  // Attaching devcontainer-net after the container has started pollutes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infosupport/huddle-cli",
3
- "version": "0.0.0-experiment-66.35.1",
3
+ "version": "0.0.0-experiment-66.36.1",
4
4
  "description": "Huddle CLI — start devcontainers and manage firewall rules",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "author": "Info Support B.V.",