fix(imagemanager): prepare proper storage and retrieval of container images
This commit is contained in:
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@serve.zone/cloudly',
|
||||
version: '1.1.1',
|
||||
version: '1.1.2',
|
||||
description: 'A cloud manager leveraging Docker Swarmkit for multi-cloud operations including DigitalOcean, Hetzner Cloud, and Cloudflare, with integration support and robust configuration management system.'
|
||||
}
|
||||
|
@ -26,4 +26,12 @@ export class Image extends plugins.smartdata.SmartDataDbDoc<Image, plugins.serve
|
||||
public data: plugins.servezoneInterfaces.data.IImage['data'];
|
||||
|
||||
public async getVersions() {}
|
||||
|
||||
/**
|
||||
* returns a storage path
|
||||
* note: this is relative to the storage method defined by the imageManager
|
||||
*/
|
||||
public async getStoragePath(versionStringArg: string) {
|
||||
return `${this.data.name}:${versionStringArg}`.replace('/', '__')
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ export class ImageManager {
|
||||
cloudlyRef: Cloudly;
|
||||
public typedrouter = new plugins.typedrequest.TypedRouter();
|
||||
public smartbucketInstance: plugins.smartbucket.SmartBucket;
|
||||
public imageDir: plugins.smartbucket.Directory;
|
||||
|
||||
get db() {
|
||||
return this.cloudlyRef.mongodbConnector.smartdataDb;
|
||||
@ -83,11 +84,10 @@ export class ImageManager {
|
||||
'pullImageVersion',
|
||||
async (reqArg) => {
|
||||
const image = await this.CImage.getInstance({
|
||||
data: {
|
||||
name: reqArg.name,
|
||||
},
|
||||
id: reqArg.imageId,
|
||||
});
|
||||
const imageVersion = null;
|
||||
const imageVersion = image.data.versions.find((version) => version.versionString === reqArg.versionString);
|
||||
const readable = this.imageDir.fastGetStream(await image.getStoragePath(reqArg.versionString));
|
||||
const imageVirtualStream = new plugins.typedrequest.VirtualStream();
|
||||
return {
|
||||
imageStream: imageVirtualStream,
|
||||
@ -106,6 +106,10 @@ export class ImageManager {
|
||||
);
|
||||
const bucket = await this.smartbucketInstance.getBucketByName('cloudly-test');
|
||||
await bucket.fastPut({ path: 'test/test.txt', contents: 'hello' });
|
||||
|
||||
this.imageDir = await bucket.getDirectoryFromPath({
|
||||
path: 'images',
|
||||
});
|
||||
}
|
||||
|
||||
public async createImage(nameArg: string) {
|
||||
|
Reference in New Issue
Block a user