@cloud-cli/vm 1.2.0 → 1.3.0
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/index.d.ts +2 -0
- package/dist/index.js +7 -1
- package/package.json +1 -1
- package/src/index.spec.ts +11 -0
- package/src/index.ts +9 -1
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ interface NameAndPathOption {
|
|
|
7
7
|
}
|
|
8
8
|
declare function list(): Promise<string[]>;
|
|
9
9
|
declare function ls(options: NameAndPathOption): Promise<string[]>;
|
|
10
|
+
declare function fixPermissions(options: NameOption): Promise<boolean>;
|
|
10
11
|
declare function rm(options: NameAndPathOption): Promise<boolean>;
|
|
11
12
|
declare function cat(options: NameAndPathOption): Promise<string>;
|
|
12
13
|
declare function show(options: NameOption): Promise<{
|
|
@@ -26,5 +27,6 @@ declare const _default: {
|
|
|
26
27
|
ls: typeof ls;
|
|
27
28
|
rm: typeof rm;
|
|
28
29
|
cat: typeof cat;
|
|
30
|
+
fixPermissions: typeof fixPermissions;
|
|
29
31
|
};
|
|
30
32
|
export default _default;
|
package/dist/index.js
CHANGED
|
@@ -25,6 +25,12 @@ async function ls(options) {
|
|
|
25
25
|
const files = await exec('ls', ['-1', join(root, path)]);
|
|
26
26
|
return files.stdout.trim().split('\n');
|
|
27
27
|
}
|
|
28
|
+
async function fixPermissions(options) {
|
|
29
|
+
const { name } = options;
|
|
30
|
+
const root = await getVolumeMountpoint(name);
|
|
31
|
+
const result = await exec('chmod', ['-R', 'a+w', root]);
|
|
32
|
+
return result.ok;
|
|
33
|
+
}
|
|
28
34
|
async function rm(options) {
|
|
29
35
|
const { name, path } = options;
|
|
30
36
|
if (!path) {
|
|
@@ -82,4 +88,4 @@ async function prune() {
|
|
|
82
88
|
await exec('docker', ['volume', 'prune']);
|
|
83
89
|
return '';
|
|
84
90
|
}
|
|
85
|
-
export default { add, remove, list, show, prune, ls, rm, cat };
|
|
91
|
+
export default { add, remove, list, show, prune, ls, rm, cat, fixPermissions };
|
package/package.json
CHANGED
package/src/index.spec.ts
CHANGED
|
@@ -48,6 +48,17 @@ describe('volume manager', () => {
|
|
|
48
48
|
});
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
+
describe('fixPermissions', () => {
|
|
52
|
+
it('should fix write permissions on volume folder', async () => {
|
|
53
|
+
const outputs = [inspectOutput, ''];
|
|
54
|
+
execMocks.exec = jest.fn().mockImplementation(() => ({ ok: true, stdout: outputs.shift() }));
|
|
55
|
+
|
|
56
|
+
await expect(vm.fixPermissions({ name: 'test' })).resolves.toEqual(true);
|
|
57
|
+
expect(exec.exec).toHaveBeenCalledWith('docker', ['volume', 'inspect', 'test']);
|
|
58
|
+
expect(exec.exec).toHaveBeenCalledWith('chmod', ['-R', 'a+w', '/var/lib/docker/volumes/test/_data']);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
51
62
|
describe('ls', () => {
|
|
52
63
|
it('should list files of a volume and path', async () => {
|
|
53
64
|
const outputs = [inspectOutput, 'dir', inspectOutput, 'a.txt\nb.txt'];
|
package/src/index.ts
CHANGED
|
@@ -44,6 +44,14 @@ async function ls(options: NameAndPathOption) {
|
|
|
44
44
|
return files.stdout.trim().split('\n');
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
async function fixPermissions(options: NameOption) {
|
|
48
|
+
const { name } = options;
|
|
49
|
+
const root = await getVolumeMountpoint(name);
|
|
50
|
+
const result = await exec('chmod', ['-R', 'a+w', root]);
|
|
51
|
+
|
|
52
|
+
return result.ok;
|
|
53
|
+
}
|
|
54
|
+
|
|
47
55
|
async function rm(options: NameAndPathOption) {
|
|
48
56
|
const { name, path } = options;
|
|
49
57
|
|
|
@@ -122,4 +130,4 @@ async function prune() {
|
|
|
122
130
|
return '';
|
|
123
131
|
}
|
|
124
132
|
|
|
125
|
-
export default { add, remove, list, show, prune, ls, rm, cat };
|
|
133
|
+
export default { add, remove, list, show, prune, ls, rm, cat, fixPermissions };
|