feat: Implement platform service providers for MinIO and MongoDB

- Added base interface and abstract class for platform service providers.
- Created MinIOProvider class for S3-compatible storage with deployment, provisioning, and deprovisioning functionalities.
- Implemented MongoDBProvider class for MongoDB service with similar capabilities.
- Introduced error handling utilities for better error management.
- Developed TokensComponent for managing registry tokens in the UI, including creation, deletion, and display of tokens.
This commit is contained in:
2025-11-25 04:20:19 +00:00
parent 9aa6906ca5
commit 8ebd677478
28 changed files with 3462 additions and 490 deletions

View File

@@ -6,6 +6,7 @@
import * as plugins from '../plugins.ts';
import { logger } from '../logging.ts';
import { getErrorMessage } from '../utils/error.ts';
import { OneboxDatabase } from './database.ts';
import { SqliteCertManager } from './certmanager.ts';
@@ -77,7 +78,7 @@ export class OneboxSslManager {
logger.success('SSL manager initialized with SmartACME DNS-01 challenge');
} catch (error) {
logger.error(`Failed to initialize SSL manager: ${error.message}`);
logger.error(`Failed to initialize SSL manager: ${getErrorMessage(error)}`);
throw error;
}
}
@@ -121,16 +122,23 @@ export class OneboxSslManager {
// Reload certificates in reverse proxy
await this.oneboxRef.reverseProxy.reloadCertificates();
// Return certificate data
// The certManager stores the cert to disk and database during getCertificateForDomain
// Look up the paths from the database
const dbCert = this.database.getSSLCertificate(domain);
if (!dbCert) {
throw new Error(`Certificate stored but not found in database for ${domain}`);
}
// Return certificate data from database
return {
certPath: cert.certFilePath,
keyPath: cert.keyFilePath,
fullChainPath: cert.chainFilePath || cert.certFilePath,
certPath: dbCert.certPath,
keyPath: dbCert.keyPath,
fullChainPath: dbCert.fullChainPath,
expiryDate: cert.validUntil,
issuer: cert.issuer || 'Let\'s Encrypt',
issuer: dbCert.issuer || 'Let\'s Encrypt',
};
} catch (error) {
logger.error(`Failed to acquire certificate for ${domain}: ${error.message}`);
logger.error(`Failed to acquire certificate for ${domain}: ${getErrorMessage(error)}`);
throw error;
}
}
@@ -164,7 +172,7 @@ export class OneboxSslManager {
// Reload certificates in reverse proxy
await this.oneboxRef.reverseProxy.reloadCertificates();
} catch (error) {
logger.error(`Failed to obtain certificate for ${domain}: ${error.message}`);
logger.error(`Failed to obtain certificate for ${domain}: ${getErrorMessage(error)}`);
throw error;
}
}
@@ -203,7 +211,7 @@ export class OneboxSslManager {
logger.success(`Certbot obtained certificate for ${domain}`);
} catch (error) {
throw new Error(`Failed to run certbot: ${error.message}`);
throw new Error(`Failed to run certbot: ${getErrorMessage(error)}`);
}
}
@@ -227,7 +235,7 @@ export class OneboxSslManager {
// Reload certificates in reverse proxy
await this.oneboxRef.reverseProxy.reloadCertificates();
} catch (error) {
logger.error(`Failed to renew certificate for ${domain}: ${error.message}`);
logger.error(`Failed to renew certificate for ${domain}: ${getErrorMessage(error)}`);
throw error;
}
}
@@ -270,14 +278,14 @@ export class OneboxSslManager {
await this.renewCertificate(dbCert.domain);
}
} catch (error) {
logger.error(`Failed to renew ${dbCert.domain}: ${error.message}`);
logger.error(`Failed to renew ${dbCert.domain}: ${getErrorMessage(error)}`);
// Continue with other certificates
}
}
logger.success('Certificate renewal check complete');
} catch (error) {
logger.error(`Failed to check expiring certificates: ${error.message}`);
logger.error(`Failed to check expiring certificates: ${getErrorMessage(error)}`);
throw error;
}
}
@@ -307,7 +315,7 @@ export class OneboxSslManager {
// Reload certificates in reverse proxy
await this.oneboxRef.reverseProxy.reloadCertificates();
} catch (error) {
logger.error(`Failed to renew all certificates: ${error.message}`);
logger.error(`Failed to renew all certificates: ${getErrorMessage(error)}`);
throw error;
}
}
@@ -358,7 +366,7 @@ export class OneboxSslManager {
return null;
} catch (error) {
logger.error(`Failed to get certificate expiry for ${domain}: ${error.message}`);
logger.error(`Failed to get certificate expiry for ${domain}: ${getErrorMessage(error)}`);
return null;
}
}