minio uploads

Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
Andrey Platov
2021-08-29 11:39:33 +02:00
parent 02717f4450
commit 7e36bb8711
15 changed files with 319 additions and 17 deletions
+28 -1
View File
@@ -15,6 +15,7 @@
//
import { createWorkspace } from '.'
import { Client } from 'minio'
const mongoUrl = process.env.MONGO_URL
if (mongoUrl === undefined) {
@@ -28,13 +29,39 @@ if (transactorUrl === undefined) {
process.exit(1)
}
const minioEndpoint = process.env.MINIO_ENDPOINT
if (minioEndpoint === undefined) {
console.error('please provide minio endpoint')
process.exit(1)
}
const minioAccessKey = process.env.MINIO_ACCESS_KEY
if (minioAccessKey === undefined) {
console.error('please provide minio access key')
process.exit(1)
}
const minioSecretKey = process.env.MINIO_SECRET_KEY
if (minioSecretKey === undefined) {
console.error('please provide minio secret key')
process.exit(1)
}
const db = process.argv[2]
if (db === undefined) {
console.error('Please specify the database.')
process.exit(1)
}
const minio = new Client({
endPoint: minioEndpoint,
port: 9000,
useSSL: false,
accessKey: minioAccessKey,
secretKey: minioSecretKey
})
console.log('creating model...')
createWorkspace(mongoUrl, db, transactorUrl).then(() => {
createWorkspace(mongoUrl, db, transactorUrl, minio).then(() => {
console.log(`done.`)
}).catch(error => { console.error(error) })
+5 -1
View File
@@ -18,6 +18,7 @@ import { MongoClient, Document } from 'mongodb'
import core, { DOMAIN_TX, Tx } from '@anticrm/core'
import { createContributingClient } from '@anticrm/contrib'
import { encode } from 'jwt-simple'
import { Client } from 'minio'
import * as txJson from './model.tx.json'
@@ -26,7 +27,7 @@ const txes = (txJson as any).default as Tx[]
/**
* @public
*/
export async function createWorkspace (mongoUrl: string, dbName: string, clientUrl: string): Promise<void> {
export async function createWorkspace (mongoUrl: string, dbName: string, clientUrl: string, minio: Client): Promise<void> {
const client = new MongoClient(mongoUrl)
try {
await client.connect()
@@ -49,6 +50,9 @@ export async function createWorkspace (mongoUrl: string, dbName: string, clientU
await contrib.tx(tx)
}
contrib.close()
console.log('create minio bucket')
await minio.makeBucket(dbName, 'k8s')
} finally {
await client.close()
}