|
@@ -1,11 +1,14 @@
|
|
|
import { NotFoundError } from '$lib/server/errors';
|
|
import { NotFoundError } from '$lib/server/errors';
|
|
|
import { type GitClient, LocalClient } from '$lib/server/git';
|
|
import { type GitClient, LocalClient } from '$lib/server/git';
|
|
|
|
|
+import { K8sClient } from '$lib/server/k8s';
|
|
|
import type { Workspace } from '$lib/types/workspace';
|
|
import type { Workspace } from '$lib/types/workspace';
|
|
|
|
|
|
|
|
import { type AgentCatalog, GitAgentCatalog } from './agents';
|
|
import { type AgentCatalog, GitAgentCatalog } from './agents';
|
|
|
import { type DocumentCatalog, GitDocumentCatalog } from './documents';
|
|
import { type DocumentCatalog, GitDocumentCatalog } from './documents';
|
|
|
import { GitKBCatalog, type KBCatalog } from './kbs';
|
|
import { GitKBCatalog, type KBCatalog } from './kbs';
|
|
|
import { GitModelCatalog, type ModelCatalog } from './models';
|
|
import { GitModelCatalog, type ModelCatalog } from './models';
|
|
|
|
|
+import { K8sSecretCatalog, type SecretCatalog } from './secrets';
|
|
|
|
|
+import { K8sStackCatalog, type StackCatalog } from './stacks';
|
|
|
import { GitToolCatalog, type ToolCatalog } from './tools';
|
|
import { GitToolCatalog, type ToolCatalog } from './tools';
|
|
|
|
|
|
|
|
type WorkspaceCatalog = {
|
|
type WorkspaceCatalog = {
|
|
@@ -14,6 +17,8 @@ type WorkspaceCatalog = {
|
|
|
kbs: KBCatalog;
|
|
kbs: KBCatalog;
|
|
|
documents: DocumentCatalog;
|
|
documents: DocumentCatalog;
|
|
|
agents: AgentCatalog;
|
|
agents: AgentCatalog;
|
|
|
|
|
+ stacks: StackCatalog;
|
|
|
|
|
+ secrets: SecretCatalog;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
class Catalog {
|
|
class Catalog {
|
|
@@ -29,12 +34,17 @@ class Catalog {
|
|
|
constructor(workspaces: Workspace[]) {
|
|
constructor(workspaces: Workspace[]) {
|
|
|
for (const workspace of workspaces) {
|
|
for (const workspace of workspaces) {
|
|
|
// TODO: github support
|
|
// TODO: github support
|
|
|
- if (workspace.persistence.type === 'local') {
|
|
|
|
|
|
|
+ if (workspace.persistence.type === 'local' && workspace.deployment.type === 'k8s') {
|
|
|
const gitClient = new LocalClient({
|
|
const gitClient = new LocalClient({
|
|
|
directory: workspace.persistence.directory,
|
|
directory: workspace.persistence.directory,
|
|
|
authorEmail: workspace.persistence.authorEmail,
|
|
authorEmail: workspace.persistence.authorEmail,
|
|
|
authorName: workspace.persistence.authorName,
|
|
authorName: workspace.persistence.authorName,
|
|
|
});
|
|
});
|
|
|
|
|
+ const k8sClient = new K8sClient({
|
|
|
|
|
+ apiUrl: workspace.deployment.apiUrl,
|
|
|
|
|
+ token: workspace.deployment.token,
|
|
|
|
|
+ skipTlsVerify: workspace.deployment.skipTlsVerify ?? false,
|
|
|
|
|
+ });
|
|
|
this.#workspaces.set(workspace.id, {
|
|
this.#workspaces.set(workspace.id, {
|
|
|
workspace,
|
|
workspace,
|
|
|
gitClient,
|
|
gitClient,
|
|
@@ -44,6 +54,8 @@ class Catalog {
|
|
|
kbs: new GitKBCatalog(gitClient),
|
|
kbs: new GitKBCatalog(gitClient),
|
|
|
documents: new GitDocumentCatalog(gitClient),
|
|
documents: new GitDocumentCatalog(gitClient),
|
|
|
agents: new GitAgentCatalog(gitClient),
|
|
agents: new GitAgentCatalog(gitClient),
|
|
|
|
|
+ stacks: new K8sStackCatalog(k8sClient, workspace.deployment.namespace),
|
|
|
|
|
+ secrets: new K8sSecretCatalog(k8sClient, workspace.deployment.namespace),
|
|
|
},
|
|
},
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|