diff --git a/src/components/Agents/InstalAgentInstruction/CLIInstallAgent.tsx b/src/components/Agents/InstalAgentInstruction/CLIInstallAgent.tsx
deleted file mode 100644
index af2e7bc5b..000000000
--- a/src/components/Agents/InstalAgentInstruction/CLIInstallAgent.tsx
+++ /dev/null
@@ -1,43 +0,0 @@
-import CodeBlock from "@flanksource-ui/ui/Code/CodeBlock";
-import Handlebars from "handlebars";
-import { useMemo } from "react";
-import { TemplateContextData } from "./InstallAgentModal";
-
-// This a Handlebars template for the Helm command to install the agent and the
-// kubernetes agent if the user has enabled it.
-const helmCommand = `helm repo add {{ chart }} {{ repoName }}/{{ chart }}
-
-helm repo update
-
-helm install mc-agent flanksource/mission-control-agent -n "{{{ namespace }}}" \\
- {{#each values}}
- --set {{{ this }}} \\
- {{/each}}
- --create-namespace
-
-{{#if kubeValues }}
-helm install mc-agent-kubernetes flanksource/mission-control-kubernetes -n "{{{ namespace }}}" \\
- {{#each kubeValues}}
- --set {{{ this }}} \\
- {{/each}}
-{{/if}}
-`;
-
-const template = Handlebars.compile(helmCommand);
-
-type Props = {
- data: TemplateContextData;
-};
-
-export default function CLIInstallAgent({ data }: Props) {
- const helmCommandTemplate = useMemo(() => {
- return template(data, {});
- }, [data]);
-
- return (
-
@@ -84,14 +70,6 @@ export function MoreInfoBox() {
);
}
-export type TemplateContextData = {
- namespace?: string;
- chart?: string;
- repoName?: string;
- values?: string[];
- kubeValues?: string[];
-};
-
type Props = {
isOpen: boolean;
onClose: () => void;
@@ -105,47 +83,82 @@ export default function InstallAgentModal({
generatedAgent,
agentFormValues
}: Props) {
- const [activeTab, setActiveTab] = useState<"cli" | "flux">("cli");
const baseUrl = useAgentsBaseURL();
const data = useMemo(() => {
const kubeOptions = agentFormValues?.kubernetes;
const pushTelemetry = agentFormValues?.pushTelemetry ?? undefined;
- return {
- chart: "mission-control-agent",
- namespace: "mission-control-agent",
- repoName: "flanksource",
- // You can add more values here to be passed to the template for the
- // values section of the HelmRelease
- values: [
- `upstream.createSecret=true`,
- `upstream.host=${baseUrl}`,
- `upstream.username=token`,
- `upstream.password=${generatedAgent?.access_token}`,
- `upstream.agentName=${agentFormValues?.name}`,
- ...(pushTelemetry?.enabled
- ? [
- `pushTelemetry.enabled=true`,
- `pushTelemetry.topologyName=${
- pushTelemetry.topologyName
- }-${agentFormValues?.name}`
- ]
- : [])
- ],
- // You can add more values here to be passed to the template for the
- // kubeValues section of the HelmRelease
- kubeValues: kubeOptions
+ return [
+ {
+ chart: "mission-control-agent",
+ namespace: "mission-control-agent",
+ repoName: "flanksource",
+ createNamespace: true,
+ createRepo: true,
+ updateHelmRepo: true,
+ releaseName: "mc-agent",
+ chartUrl: "https://flanksource.github.io/charts",
+ // You can add more values here to be passed to the template for the
+ // values section of the HelmRelease
+ values: [
+ {
+ key: "upstream.createSecret",
+ value: "true"
+ },
+ {
+ key: "upstream.host",
+ value: baseUrl
+ },
+ {
+ key: "upstream.username",
+ value: "token"
+ },
+ {
+ key: "upstream.password",
+ value: generatedAgent?.access_token
+ },
+ {
+ key: "upstream.agentName",
+ value: agentFormValues?.name
+ },
+ ...(pushTelemetry?.enabled
+ ? [
+ {
+ key: "pushTelemetry.enabled",
+ value: "true"
+ },
+ {
+ key: "pushTelemetry.topologyName",
+ value: `${pushTelemetry.topologyName}`
+ }
+ ]
+ : [])
+ ]
+ },
+ ...(kubeOptions?.enabled
? [
- `clusterName: "${agentFormValues?.name}"`,
- `scraper.schedule: "${kubeOptions.schedule}"`
+ {
+ chart: "mission-control-kubernetes",
+ namespace: "mission-control-agent",
+ repoName: "flanksource",
+ releaseName: "mc-agent-kubernetes",
+ values: [
+ {
+ key: "clusterName",
+ value: agentFormValues?.name
+ },
+ {
+ key: "scraper.schedule",
+ value: kubeOptions.schedule
+ }
+ ]
+ }
]
- : []
- } satisfies TemplateContextData;
+ : [])
+ ] satisfies ChartData[];
}, [agentFormValues, baseUrl, generatedAgent]);
- console.log(JSON.stringify(data, null, 2));
-
return (
- setActiveTab(v as any)}
- >
-
-
-
-
-
-
-
-
-
+
diff --git a/src/components/Agents/InstalAgentInstruction/__tests__/CLIInstallAgent.unit.test.tsx b/src/components/Agents/InstalAgentInstruction/__tests__/CLIInstallAgent.unit.test.tsx
deleted file mode 100644
index 7c77f9591..000000000
--- a/src/components/Agents/InstalAgentInstruction/__tests__/CLIInstallAgent.unit.test.tsx
+++ /dev/null
@@ -1,87 +0,0 @@
-import { render, screen } from "@testing-library/react";
-import { AuthContext, FakeUser, Roles } from "../../../../context";
-import InstallAgentModal from "../CLIInstallAgent";
-
-global.ResizeObserver = jest.fn().mockImplementation(() => ({
- observe: jest.fn(),
- unobserve: jest.fn(),
- disconnect: jest.fn()
-}));
-
-const mockInput = {
- chart: "mission-control-agent",
- namespace: "mission-control-agent",
- repoName: "flanksource",
- values: [
- "upstream.createSecret=true",
- "upstream.host=http://localhost:3000",
- "upstream.username=token",
- "upstream.password=password",
- "upstream.agentName=test-new-agent-instructions",
- "pushTelemetry.enabled=true",
- "pushTelemetry.topologyName=https://incident-commander.demo.aws.flanksource.com-test-new-agent-instructions"
- ]
-};
-
-const mockInputWithKubOptions = {
- chart: "mission-control-agent",
- namespace: "mission-control-agent",
- repoName: "flanksource",
- values: [
- "upstream.createSecret=true",
- "upstream.host=http://localhost:3000",
- "upstream.username=token",
- "upstream.password=password",
- "upstream.agentName=test-new-agent-instructions",
- "pushTelemetry.enabled=true",
- "pushTelemetry.topologyName=https://incident-commander.demo.aws.flanksource.com-test-new-agent-instructions"
- ],
- kubeValues: [
- 'clusterName: "test-new-agent-instructions"',
- 'scraper.schedule: "30m"'
- ]
-};
-
-describe("InstallAgentModal", () => {
- it("renders the Helm repository installation command", () => {
- render(
-