Browse Source

make-bucket command

pull/1/head
Rob Colbert 3 years ago
parent
commit
910cccfbd3
  1. 11
      .vscode/launch.json
  2. 10
      app/services/minio.js
  3. 14
      dtp-libertylinks-cli.js

11
.vscode/launch.json

@ -16,6 +16,17 @@
"env": { "env": {
"HTTP_BIND_PORT": "3333" "HTTP_BIND_PORT": "3333"
} }
},
{
"type": "pwa-node",
"request": "launch",
"name": "web:libertylinks-cli",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder:dtp-libertylinks}/dtp-libertylinks-cli.js",
"console": "integratedTerminal",
"args": ["--action=make-bucket", "images"]
} }
] ]
} }

10
app/services/minio.js

@ -32,6 +32,16 @@ class MinioService extends SiteService {
this.log.info(`stopping ${module.exports.name} service`); this.log.info(`stopping ${module.exports.name} service`);
} }
async makeBucket (name, region) {
try {
const result = await this.minio.makeBucket(name, region);
return result;
} catch (error) {
this.log.error('failed to create bucket on MinIO', { name, region, error });
throw error;
}
}
async uploadFile (fileInfo) { async uploadFile (fileInfo) {
try { try {
const result = await this.minio.fPutObject( const result = await this.minio.fPutObject(

14
dtp-libertylinks-cli.js

@ -91,6 +91,16 @@ module.deleteOtpAccount = async (target) => {
} }
}; };
module.makeBucket = async (target) => {
const { minio: minioService } = module.services;
try {
module.log.info('creating bucket', { target });
await minioService.makeBucket(target, 'us-east-1');
} catch (error) {
module.log.error('failed to create bucket', { target, error });
}
};
/* /*
* SERVER INIT * SERVER INIT
*/ */
@ -137,6 +147,10 @@ module.deleteOtpAccount = async (target) => {
await module.revokePermission(target, module.app.options.permission); await module.revokePermission(target, module.app.options.permission);
break; break;
case 'make-bucket':
await module.makeBucket(target);
break;
case 'delete-otp': case 'delete-otp':
await module.deleteOtpAccount(target); await module.deleteOtpAccount(target);
break; break;

Loading…
Cancel
Save