podmanager 1.0.0 → 1.0.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/bin/podmanager.js +78 -58
- package/package.json +1 -1
- package/public/css/style.css +4 -97
- package/public/index.html +6 -34
- package/public/js/api.js +0 -10
- package/public/js/app.js +0 -74
- package/src/app.js +0 -4
- package/src/index.js +10 -3
- package/src/middlewares/async-handler.middleware.js +0 -3
- package/src/middlewares/error.middleware.js +0 -3
- package/src/routes/containers.route.js +0 -13
- package/src/routes/events.route.js +1 -3
- package/src/routes/images.route.js +0 -5
- package/src/routes/networks.route.js +0 -4
- package/src/routes/pods.route.js +0 -7
- package/src/routes/system.route.js +0 -3
- package/src/routes/volumes.route.js +0 -4
- package/src/services/podman.service.js +4 -19
|
@@ -4,25 +4,21 @@ const asyncHandler = require('../middlewares/async-handler.middleware');
|
|
|
4
4
|
|
|
5
5
|
const router = express.Router();
|
|
6
6
|
|
|
7
|
-
// GET /api/networks
|
|
8
7
|
router.get('/', asyncHandler(async (req, res) => {
|
|
9
8
|
const networks = await Podman.listNetworks();
|
|
10
9
|
res.json({ success: true, data: networks });
|
|
11
10
|
}));
|
|
12
11
|
|
|
13
|
-
// GET /api/networks/:name
|
|
14
12
|
router.get('/:name', asyncHandler(async (req, res) => {
|
|
15
13
|
const data = await Podman.inspectNetwork(req.params.name);
|
|
16
14
|
res.json({ success: true, data });
|
|
17
15
|
}));
|
|
18
16
|
|
|
19
|
-
// POST /api/networks
|
|
20
17
|
router.post('/', asyncHandler(async (req, res) => {
|
|
21
18
|
const result = await Podman.createNetwork(req.body);
|
|
22
19
|
res.json({ success: true, message: 'Network created', ...result });
|
|
23
20
|
}));
|
|
24
21
|
|
|
25
|
-
// DELETE /api/networks/:name
|
|
26
22
|
router.delete('/:name', asyncHandler(async (req, res) => {
|
|
27
23
|
const result = await Podman.removeNetwork(req.params.name);
|
|
28
24
|
res.json({ success: true, message: 'Network removed', ...result });
|
package/src/routes/pods.route.js
CHANGED
|
@@ -4,43 +4,36 @@ const asyncHandler = require('../middlewares/async-handler.middleware');
|
|
|
4
4
|
|
|
5
5
|
const router = express.Router();
|
|
6
6
|
|
|
7
|
-
// GET /api/pods
|
|
8
7
|
router.get('/', asyncHandler(async (req, res) => {
|
|
9
8
|
const pods = await Podman.listPods();
|
|
10
9
|
res.json({ success: true, data: pods });
|
|
11
10
|
}));
|
|
12
11
|
|
|
13
|
-
// GET /api/pods/:id
|
|
14
12
|
router.get('/:id', asyncHandler(async (req, res) => {
|
|
15
13
|
const data = await Podman.inspectPod(req.params.id);
|
|
16
14
|
res.json({ success: true, data });
|
|
17
15
|
}));
|
|
18
16
|
|
|
19
|
-
// POST /api/pods
|
|
20
17
|
router.post('/', asyncHandler(async (req, res) => {
|
|
21
18
|
const result = await Podman.createPod(req.body);
|
|
22
19
|
res.json({ success: true, message: 'Pod created', ...result });
|
|
23
20
|
}));
|
|
24
21
|
|
|
25
|
-
// POST /api/pods/:id/start
|
|
26
22
|
router.post('/:id/start', asyncHandler(async (req, res) => {
|
|
27
23
|
const result = await Podman.startPod(req.params.id);
|
|
28
24
|
res.json({ success: true, message: 'Pod started', ...result });
|
|
29
25
|
}));
|
|
30
26
|
|
|
31
|
-
// POST /api/pods/:id/stop
|
|
32
27
|
router.post('/:id/stop', asyncHandler(async (req, res) => {
|
|
33
28
|
const result = await Podman.stopPod(req.params.id);
|
|
34
29
|
res.json({ success: true, message: 'Pod stopped', ...result });
|
|
35
30
|
}));
|
|
36
31
|
|
|
37
|
-
// POST /api/pods/:id/restart
|
|
38
32
|
router.post('/:id/restart', asyncHandler(async (req, res) => {
|
|
39
33
|
const result = await Podman.restartPod(req.params.id);
|
|
40
34
|
res.json({ success: true, message: 'Pod restarted', ...result });
|
|
41
35
|
}));
|
|
42
36
|
|
|
43
|
-
// DELETE /api/pods/:id
|
|
44
37
|
router.delete('/:id', asyncHandler(async (req, res) => {
|
|
45
38
|
const force = req.query.force === 'true';
|
|
46
39
|
const result = await Podman.removePod(req.params.id, force);
|
|
@@ -4,19 +4,16 @@ const asyncHandler = require('../middlewares/async-handler.middleware');
|
|
|
4
4
|
|
|
5
5
|
const router = express.Router();
|
|
6
6
|
|
|
7
|
-
// GET /api/system/info
|
|
8
7
|
router.get('/info', asyncHandler(async (req, res) => {
|
|
9
8
|
const info = await Podman.getSystemInfo();
|
|
10
9
|
res.json({ success: true, data: info });
|
|
11
10
|
}));
|
|
12
11
|
|
|
13
|
-
// GET /api/system/df
|
|
14
12
|
router.get('/df', asyncHandler(async (req, res) => {
|
|
15
13
|
const df = await Podman.getSystemDf();
|
|
16
14
|
res.json({ success: true, data: df });
|
|
17
15
|
}));
|
|
18
16
|
|
|
19
|
-
// POST /api/system/prune
|
|
20
17
|
router.post('/prune', asyncHandler(async (req, res) => {
|
|
21
18
|
const { type = 'all' } = req.body;
|
|
22
19
|
const result = await Podman.prune(type);
|
|
@@ -4,26 +4,22 @@ const asyncHandler = require('../middlewares/async-handler.middleware');
|
|
|
4
4
|
|
|
5
5
|
const router = express.Router();
|
|
6
6
|
|
|
7
|
-
// GET /api/volumes
|
|
8
7
|
router.get('/', asyncHandler(async (req, res) => {
|
|
9
8
|
const volumes = await Podman.listVolumes();
|
|
10
9
|
res.json({ success: true, data: volumes });
|
|
11
10
|
}));
|
|
12
11
|
|
|
13
|
-
// GET /api/volumes/:name
|
|
14
12
|
router.get('/:name', asyncHandler(async (req, res) => {
|
|
15
13
|
const data = await Podman.inspectVolume(req.params.name);
|
|
16
14
|
res.json({ success: true, data });
|
|
17
15
|
}));
|
|
18
16
|
|
|
19
|
-
// POST /api/volumes
|
|
20
17
|
router.post('/', asyncHandler(async (req, res) => {
|
|
21
18
|
const { name, driver } = req.body;
|
|
22
19
|
const result = await Podman.createVolume(name, driver);
|
|
23
20
|
res.json({ success: true, message: 'Volume created', ...result });
|
|
24
21
|
}));
|
|
25
22
|
|
|
26
|
-
// DELETE /api/volumes/:name
|
|
27
23
|
router.delete('/:name', asyncHandler(async (req, res) => {
|
|
28
24
|
const force = req.query.force === 'true';
|
|
29
25
|
const result = await Podman.removeVolume(req.params.name, force);
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
const { execFile, spawn } = require('child_process');
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Execute podman command safely using execFile
|
|
5
|
-
*/
|
|
6
3
|
function runPodman(args, options = {}) {
|
|
7
4
|
return new Promise((resolve, reject) => {
|
|
8
|
-
const maxBuffer = options.maxBuffer || 10 * 1024 * 1024;
|
|
9
|
-
const timeout = options.timeout || 60000;
|
|
5
|
+
const maxBuffer = options.maxBuffer || 10 * 1024 * 1024;
|
|
6
|
+
const timeout = options.timeout || 60000;
|
|
10
7
|
execFile('podman', args, { maxBuffer, timeout, ...options }, (err, stdout, stderr) => {
|
|
11
8
|
if (err) {
|
|
12
9
|
const error = new Error(stderr.trim() || err.message);
|
|
@@ -20,9 +17,6 @@ function runPodman(args, options = {}) {
|
|
|
20
17
|
});
|
|
21
18
|
}
|
|
22
19
|
|
|
23
|
-
/**
|
|
24
|
-
* Execute podman command and parse JSON output
|
|
25
|
-
*/
|
|
26
20
|
async function runPodmanJson(args) {
|
|
27
21
|
const { stdout } = await runPodman(args);
|
|
28
22
|
if (!stdout) return [];
|
|
@@ -34,7 +28,7 @@ async function runPodmanJson(args) {
|
|
|
34
28
|
}
|
|
35
29
|
|
|
36
30
|
const Podman = {
|
|
37
|
-
|
|
31
|
+
|
|
38
32
|
async getSystemInfo() {
|
|
39
33
|
const raw = await runPodmanJson(['system', 'info', '--format', 'json']);
|
|
40
34
|
return {
|
|
@@ -87,7 +81,6 @@ const Podman = {
|
|
|
87
81
|
return { stdout, stderr };
|
|
88
82
|
},
|
|
89
83
|
|
|
90
|
-
// Containers
|
|
91
84
|
async listContainers(all = true) {
|
|
92
85
|
const args = ['ps', '--format', 'json'];
|
|
93
86
|
if (all) args.push('-a');
|
|
@@ -171,21 +164,18 @@ const Podman = {
|
|
|
171
164
|
if (pod) args.push('--pod', pod);
|
|
172
165
|
else if (network) args.push('--network', network);
|
|
173
166
|
|
|
174
|
-
// Ports
|
|
175
167
|
const portList = Array.isArray(ports) ? ports : ports.split('\n');
|
|
176
168
|
for (const p of portList) {
|
|
177
169
|
const trimmed = p.trim();
|
|
178
170
|
if (trimmed) args.push('-p', trimmed);
|
|
179
171
|
}
|
|
180
172
|
|
|
181
|
-
// Envs
|
|
182
173
|
const envList = Array.isArray(envs) ? envs : envs.split('\n');
|
|
183
174
|
for (const e of envList) {
|
|
184
175
|
const trimmed = e.trim();
|
|
185
176
|
if (trimmed) args.push('-e', trimmed);
|
|
186
177
|
}
|
|
187
178
|
|
|
188
|
-
// Volumes
|
|
189
179
|
const volList = Array.isArray(volumes) ? volumes : volumes.split('\n');
|
|
190
180
|
for (const v of volList) {
|
|
191
181
|
const trimmed = v.trim();
|
|
@@ -195,7 +185,7 @@ const Podman = {
|
|
|
195
185
|
args.push(image.trim());
|
|
196
186
|
|
|
197
187
|
if (cmd && cmd.trim()) {
|
|
198
|
-
|
|
188
|
+
|
|
199
189
|
const cmdParts = cmd.trim().split(/\s+/);
|
|
200
190
|
args.push(...cmdParts);
|
|
201
191
|
}
|
|
@@ -237,7 +227,6 @@ const Podman = {
|
|
|
237
227
|
return await runPodman(args, { timeout: 30000 });
|
|
238
228
|
},
|
|
239
229
|
|
|
240
|
-
// Pods
|
|
241
230
|
async listPods() {
|
|
242
231
|
const pods = await runPodmanJson(['pod', 'ps', '--format', 'json']);
|
|
243
232
|
return Array.isArray(pods) ? pods : [];
|
|
@@ -282,7 +271,6 @@ const Podman = {
|
|
|
282
271
|
return { podId: stdout.trim(), stderr };
|
|
283
272
|
},
|
|
284
273
|
|
|
285
|
-
// Images
|
|
286
274
|
async listImages() {
|
|
287
275
|
const images = await runPodmanJson(['images', '--format', 'json']);
|
|
288
276
|
return Array.isArray(images) ? images : [];
|
|
@@ -326,7 +314,6 @@ const Podman = {
|
|
|
326
314
|
return await runPodman(args);
|
|
327
315
|
},
|
|
328
316
|
|
|
329
|
-
// Volumes
|
|
330
317
|
async listVolumes() {
|
|
331
318
|
const volumes = await runPodmanJson(['volume', 'ls', '--format', 'json']);
|
|
332
319
|
return Array.isArray(volumes) ? volumes : [];
|
|
@@ -351,7 +338,6 @@ const Podman = {
|
|
|
351
338
|
return await runPodman(args);
|
|
352
339
|
},
|
|
353
340
|
|
|
354
|
-
// Networks
|
|
355
341
|
async listNetworks() {
|
|
356
342
|
const networks = await runPodmanJson(['network', 'ls', '--format', 'json']);
|
|
357
343
|
return Array.isArray(networks) ? networks : [];
|
|
@@ -376,7 +362,6 @@ const Podman = {
|
|
|
376
362
|
return await runPodman(['network', 'rm', name]);
|
|
377
363
|
},
|
|
378
364
|
|
|
379
|
-
// Events
|
|
380
365
|
async getEvents(since = '24h') {
|
|
381
366
|
try {
|
|
382
367
|
const args = ['events', '--stream=false', '--format', 'json'];
|