mirror of
https://github.com/tale/headplane.git
synced 2026-08-13 15:07:24 +00:00
feat: reach an initial working stage
This commit is contained in:
@@ -2,11 +2,11 @@ import { hp_getConfig } from '~server/context/global';
|
||||
import { HeadplaneConfig } from '~server/context/parser';
|
||||
import log from '~server/utils/log';
|
||||
import { Integration } from './abstract';
|
||||
import dockerIntegration from './docker';
|
||||
import kubernetesIntegration from './kubernetes';
|
||||
import procIntegration from './proc';
|
||||
// import dockerIntegration from './docker';
|
||||
// import kubernetesIntegration from './kubernetes';
|
||||
// import procIntegration from './proc';
|
||||
|
||||
let runtimeIntegration: Integration<unknown> | undefined = undefined;
|
||||
const runtimeIntegration: Integration<unknown> | undefined = undefined;
|
||||
|
||||
export function hp_getIntegration() {
|
||||
return runtimeIntegration;
|
||||
@@ -15,24 +15,22 @@ export function hp_getIntegration() {
|
||||
export async function hp_loadIntegration(
|
||||
context: HeadplaneConfig['integration'],
|
||||
) {
|
||||
const integration = getIntegration(context);
|
||||
if (!integration) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await integration.isAvailable();
|
||||
if (!res) {
|
||||
log.error('INTG', 'Integration %s is not available', integration);
|
||||
return;
|
||||
}
|
||||
} catch (error) {
|
||||
log.error('INTG', 'Failed to load integration %s: %s', integration, error);
|
||||
log.debug('INTG', 'Loading error: %o', error);
|
||||
return;
|
||||
}
|
||||
|
||||
runtimeIntegration = integration;
|
||||
// const integration = getIntegration(context);
|
||||
// if (!integration) {
|
||||
// return;
|
||||
// }
|
||||
// try {
|
||||
// const res = await integration.isAvailable();
|
||||
// if (!res) {
|
||||
// log.error('INTG', 'Integration %s is not available', integration);
|
||||
// return;
|
||||
// }
|
||||
// } catch (error) {
|
||||
// log.error('INTG', 'Failed to load integration %s: %s', integration, error);
|
||||
// log.debug('INTG', 'Loading error: %o', error);
|
||||
// return;
|
||||
// }
|
||||
// runtimeIntegration = integration;
|
||||
}
|
||||
|
||||
function getIntegration(integration: HeadplaneConfig['integration']) {
|
||||
@@ -50,23 +48,23 @@ function getIntegration(integration: HeadplaneConfig['integration']) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (docker?.enabled) {
|
||||
log.info('INTG', 'Using Docker integration');
|
||||
return new dockerIntegration(integration?.docker);
|
||||
}
|
||||
// if (docker?.enabled) {
|
||||
// log.info('INTG', 'Using Docker integration');
|
||||
// return new dockerIntegration(integration?.docker);
|
||||
// }
|
||||
|
||||
if (k8s?.enabled) {
|
||||
log.info('INTG', 'Using Kubernetes integration');
|
||||
return new kubernetesIntegration(integration?.kubernetes);
|
||||
}
|
||||
// if (k8s?.enabled) {
|
||||
// log.info('INTG', 'Using Kubernetes integration');
|
||||
// return new kubernetesIntegration(integration?.kubernetes);
|
||||
// }
|
||||
|
||||
if (proc?.enabled) {
|
||||
log.info('INTG', 'Using Proc integration');
|
||||
return new procIntegration(integration?.proc);
|
||||
}
|
||||
// if (proc?.enabled) {
|
||||
// log.info('INTG', 'Using Proc integration');
|
||||
// return new procIntegration(integration?.proc);
|
||||
// }
|
||||
}
|
||||
|
||||
// IMPORTANT THIS IS A SIDE EFFECT ON INIT
|
||||
// TODO: Switch this to the new singleton system
|
||||
const context = hp_getConfig();
|
||||
hp_loadIntegration(context.integration);
|
||||
// hp_loadIntegration(context.integration);
|
||||
|
||||
Reference in New Issue
Block a user