From baecc49d8628514b47062ce049932439529e0471 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sat, 18 May 2024 17:59:04 -0600 Subject: [PATCH] feat: add network swarm json --- .../cluster/modify-swarm-settings.tsx | 79 +- drizzle/0013_blushing_starjammers.sql | 1 + drizzle/meta/0013_snapshot.json | 2392 +++++++++++++++++ drizzle/meta/_journal.json | 7 + server/db/schema/application.ts | 73 +- server/utils/builders/index.ts | 4 +- server/utils/docker/utils.ts | 8 + 7 files changed, 2505 insertions(+), 59 deletions(-) create mode 100644 drizzle/0013_blushing_starjammers.sql create mode 100644 drizzle/meta/0013_snapshot.json diff --git a/components/dashboard/application/advanced/cluster/modify-swarm-settings.tsx b/components/dashboard/application/advanced/cluster/modify-swarm-settings.tsx index 53675279..e556650b 100644 --- a/components/dashboard/application/advanced/cluster/modify-swarm-settings.tsx +++ b/components/dashboard/application/advanced/cluster/modify-swarm-settings.tsx @@ -109,6 +109,16 @@ const ServiceModeSwarmSchema = z }) .strict(); +const NetworkSwarmSchema = z.array( + z + .object({ + Target: z.string().optional(), + Aliases: z.array(z.string()).optional(), + DriverOpts: z.object({}).optional(), + }) + .strict(), +); + const LabelsSwarmSchema = z.record(z.string()); const createStringToJSONSchema = (schema: z.ZodTypeAny) => { @@ -165,6 +175,7 @@ const addSwarmSettings = z.object({ ).nullable(), modeSwarm: createStringToJSONSchema(ServiceModeSwarmSchema).nullable(), labelsSwarm: createStringToJSONSchema(LabelsSwarmSchema).nullable(), + networkSwarm: createStringToJSONSchema(NetworkSwarmSchema).nullable(), }); type AddSwarmSettings = z.infer; @@ -195,6 +206,7 @@ export const AddSwarmSettings = ({ applicationId }: Props) => { rollbackConfigSwarm: null, modeSwarm: null, labelsSwarm: null, + networkSwarm: null, }, resolver: zodResolver(addSwarmSettings), }); @@ -223,6 +235,9 @@ export const AddSwarmSettings = ({ applicationId }: Props) => { labelsSwarm: data.labelsSwarm ? JSON.stringify(data.labelsSwarm, null, 2) : null, + networkSwarm: data.networkSwarm + ? JSON.stringify(data.networkSwarm, null, 2) + : null, }); } }, [form, form.reset, data]); @@ -237,6 +252,7 @@ export const AddSwarmSettings = ({ applicationId }: Props) => { rollbackConfigSwarm: data.rollbackConfigSwarm, modeSwarm: data.modeSwarm, labelsSwarm: data.labelsSwarm, + networkSwarm: data.networkSwarm, }) .then(async () => { toast.success("Swarm settings updated"); @@ -618,12 +634,69 @@ export const AddSwarmSettings = ({ applicationId }: Props) => { )} /> - + ( + + Network + + + + + Check the interface + + + + + +
+														{`[
+  {
+	"Target" : string | undefined;
+	"Aliases" : string[] | undefined;
+	"DriverOpts" : { [key: string]: string } | undefined;
+  }
+]`}
+													
+
+
+
+
+ +