diff --git a/cypress/integration/distroSettings/host_section.ts b/cypress/integration/distroSettings/host_section.ts index 23c8873eeb..2b03d4473d 100644 --- a/cypress/integration/distroSettings/host_section.ts +++ b/cypress/integration/distroSettings/host_section.ts @@ -51,6 +51,20 @@ describe("host section", () => { save(); cy.validateToast("success", "Updated distro."); }); + + it("updates mountpoints", () => { + cy.contains("button", "Add Mountpoint").click(); + cy.getInputByLabel("Mountpoint").type("/data"); + + save(); + cy.validateToast("success", "Updated distro."); + + // Reset fields + cy.dataCy("delete-item-button").click(); + + save(); + cy.validateToast("success", "Updated distro."); + }); }); describe("using User Data bootstrap method", () => { diff --git a/src/gql/generated/types.ts b/src/gql/generated/types.ts index a884f8bd7f..c44a5538e2 100644 --- a/src/gql/generated/types.ts +++ b/src/gql/generated/types.ts @@ -5719,6 +5719,7 @@ export type DistroQuery = { disableShallowClone: boolean; isCluster: boolean; isVirtualWorkStation: boolean; + mountpoints?: Array | null; name: string; note: string; provider: Provider; diff --git a/src/gql/queries/distro.graphql b/src/gql/queries/distro.graphql index 991032030e..a8aad83f0a 100644 --- a/src/gql/queries/distro.graphql +++ b/src/gql/queries/distro.graphql @@ -61,6 +61,7 @@ query Distro($distroId: String!) { } isCluster isVirtualWorkStation + mountpoints name note plannerSettings { diff --git a/src/pages/distroSettings/tabs/HostTab/schemaFields.tsx b/src/pages/distroSettings/tabs/HostTab/schemaFields.tsx index 5e26595c99..08535c78ff 100644 --- a/src/pages/distroSettings/tabs/HostTab/schemaFields.tsx +++ b/src/pages/distroSettings/tabs/HostTab/schemaFields.tsx @@ -169,6 +169,27 @@ export const rootDir = { uiSchema: {}, }; +export const mountpoints = { + schema: { + type: "array" as "array", + title: "Mountpoints", + items: { + type: "string" as "string", + title: "Mountpoint", + default: "", + minLength: 1, + }, + }, + uiSchema: { + "ui:addButtonText": "Add Mountpoint", + "ui:description": "Mointpoints configured on the host.", + "ui:orderable": false, + items: { + "ui:placeholder": "/data", + }, + }, +}; + const serviceUser = { schema: { type: "string" as "string", @@ -548,6 +569,7 @@ export const setup = { workDir: workDir.schema, setupAsSudo: setupAsSudo.schema, setupScript: setupScript.schema, + mountpoints: mountpoints.schema, userSpawnAllowed: userSpawnAllowed.schema, }, uiSchema: (architecture: Arch, hasStaticProvider: boolean) => ({ @@ -558,6 +580,7 @@ export const setup = { setupAsSudo: setupAsSudo.uiSchema, workDir: workDir.uiSchema, setupScript: setupScript.uiSchema, + mountpoints: mountpoints.uiSchema, userSpawnAllowed: userSpawnAllowed.uiSchema(hasStaticProvider), isVirtualWorkStation: isVirtualWorkStation.uiSchema(architecture), icecreamSchedulerHost: icecreamSchedulerHost.uiSchema, diff --git a/src/pages/distroSettings/tabs/HostTab/transformers.test.ts b/src/pages/distroSettings/tabs/HostTab/transformers.test.ts index e91705685f..d043e20611 100644 --- a/src/pages/distroSettings/tabs/HostTab/transformers.test.ts +++ b/src/pages/distroSettings/tabs/HostTab/transformers.test.ts @@ -20,6 +20,13 @@ describe("host tab", () => { it("correctly converts from a form to GQL", () => { expect(formToGql(form, distroData)).toStrictEqual(gql); }); + + it("correctly converts from GQL to a form when mountpoints is null", () => { + expect(gqlToForm({ ...distroData, mountpoints: null })).toStrictEqual({ + ...form, + setup: { ...form.setup, mountpoints: [] }, + }); + }); }); const form: HostFormState = { @@ -35,6 +42,7 @@ const form: HostFormState = { isVirtualWorkStation: false, icecreamSchedulerHost: "", icecreamConfigPath: "", + mountpoints: ["/"], }, bootstrapSettings: { jasperBinaryDir: "/home/evg/jasper", diff --git a/src/pages/distroSettings/tabs/HostTab/transformers.ts b/src/pages/distroSettings/tabs/HostTab/transformers.ts index e71e286896..f8883a75d9 100644 --- a/src/pages/distroSettings/tabs/HostTab/transformers.ts +++ b/src/pages/distroSettings/tabs/HostTab/transformers.ts @@ -26,6 +26,7 @@ export const gqlToForm = ((data) => { hostAllocatorSettings, iceCreamSettings, isVirtualWorkStation, + mountpoints, setup, setupAsSudo, sshKey, @@ -48,6 +49,7 @@ export const gqlToForm = ((data) => { isVirtualWorkStation, icecreamSchedulerHost: iceCreamSettings.schedulerHost, icecreamConfigPath: iceCreamSettings.configPath, + mountpoints: mountpoints ?? [], }, bootstrapSettings: { jasperBinaryDir, @@ -101,6 +103,7 @@ export const formToGql = (( isVirtualWorkStation: setup.isVirtualWorkStation, setupAsSudo: setup.setupAsSudo, setup: setup.setupScript, + mountpoints: setup.mountpoints, sshKey: sshConfig.sshKey, sshOptions: sshConfig.sshOptions, user: sshConfig.user, diff --git a/src/pages/distroSettings/tabs/HostTab/types.ts b/src/pages/distroSettings/tabs/HostTab/types.ts index c0e4e6473a..c50ee8da74 100644 --- a/src/pages/distroSettings/tabs/HostTab/types.ts +++ b/src/pages/distroSettings/tabs/HostTab/types.ts @@ -22,6 +22,7 @@ export interface HostFormState { isVirtualWorkStation: boolean; icecreamSchedulerHost: string; icecreamConfigPath: string; + mountpoints: string[]; }; bootstrapSettings: { jasperBinaryDir: string; diff --git a/src/pages/distroSettings/tabs/testData.ts b/src/pages/distroSettings/tabs/testData.ts index 1ecdc6de0d..89482e86a3 100644 --- a/src/pages/distroSettings/tabs/testData.ts +++ b/src/pages/distroSettings/tabs/testData.ts @@ -118,6 +118,7 @@ const distroData: DistroQuery["distro"] = { userSpawnAllowed: false, validProjects: [], workDir: "/data/evg", + mountpoints: ["/"], }; export { distroData };