diff --git a/client/src/features/admin/UpdateSessionEnvironmentButton.tsx b/client/src/features/admin/UpdateSessionEnvironmentButton.tsx index f33cc21e60..79b8cec8bf 100644 --- a/client/src/features/admin/UpdateSessionEnvironmentButton.tsx +++ b/client/src/features/admin/UpdateSessionEnvironmentButton.tsx @@ -116,14 +116,10 @@ function UpdateSessionEnvironmentModal({ uid: data.uid ?? undefined, working_directory: data.working_directory?.trim() || undefined, strip_path_prefix: data.strip_path_prefix, - // TODO: The API spec needs to be fixed to describe value resets here - // TODO: See https://github.com/SwissDataScienceCenter/renku-data-services/issues/985 ...(commandParsed.data ? { command: commandParsed.data } - : ({ command: null } as any)), // eslint-disable-line @typescript-eslint/no-explicit-any - ...(argsParsed.data - ? { args: argsParsed.data } - : ({ args: null } as any)), // eslint-disable-line @typescript-eslint/no-explicit-any + : { command: null }), + ...(argsParsed.data ? { args: argsParsed.data } : { args: null }), }, }); }, diff --git a/client/src/features/sessionsV2/api/sessionLaunchersV2.generated-api.ts b/client/src/features/sessionsV2/api/sessionLaunchersV2.generated-api.ts index ad44044b04..0a34981ae6 100644 --- a/client/src/features/sessionsV2/api/sessionLaunchersV2.generated-api.ts +++ b/client/src/features/sessionsV2/api/sessionLaunchersV2.generated-api.ts @@ -290,6 +290,10 @@ export type EnvironmentPost = { }; export type EnvironmentWorkingDirectoryPatch = string; export type EnvironmentMountDirectoryPatch = string; +export type EnvironmentPatchCommand = string[] | null; +export type EnvironmentPatchArgs = string[] | null; +export type IsArchivedPatch = boolean; +export type StripPathPrefixPatch = boolean; export type EnvironmentPatch = { name?: SessionName; description?: Description; @@ -300,10 +304,10 @@ export type EnvironmentPatch = { working_directory?: EnvironmentWorkingDirectoryPatch; mount_directory?: EnvironmentMountDirectoryPatch; port?: EnvironmentPort; - command?: EnvironmentCommand; - args?: EnvironmentArgs; - is_archived?: IsArchived; - strip_path_prefix?: StripPathPrefix; + command?: EnvironmentPatchCommand; + args?: EnvironmentPatchArgs; + is_archived?: IsArchivedPatch; + strip_path_prefix?: StripPathPrefixPatch; }; export type EnvironmentKind = "GLOBAL" | "CUSTOM"; export type EnvironmentWithImageGet = Environment & { diff --git a/client/src/features/sessionsV2/api/sessionLaunchersV2.openapi.json b/client/src/features/sessionsV2/api/sessionLaunchersV2.openapi.json index 885859f023..da13f94ff9 100644 --- a/client/src/features/sessionsV2/api/sessionLaunchersV2.openapi.json +++ b/client/src/features/sessionsV2/api/sessionLaunchersV2.openapi.json @@ -655,7 +655,7 @@ "$ref": "#/components/schemas/EnvironmentKind" } ], - "default": "custom" + "default": "CUSTOM" } }, "required": ["environment_image_source", "environment_kind"] @@ -685,7 +685,7 @@ "$ref": "#/components/schemas/EnvironmentKind" } ], - "default": "custom" + "default": "CUSTOM" } }, "required": [ @@ -855,16 +855,16 @@ "$ref": "#/components/schemas/EnvironmentPort" }, "command": { - "$ref": "#/components/schemas/EnvironmentCommand" + "$ref": "#/components/schemas/EnvironmentPatchCommand" }, "args": { - "$ref": "#/components/schemas/EnvironmentArgs" + "$ref": "#/components/schemas/EnvironmentPatchArgs" }, "is_archived": { - "$ref": "#/components/schemas/IsArchived" + "$ref": "#/components/schemas/IsArchivedPatch" }, "strip_path_prefix": { - "$ref": "#/components/schemas/StripPathPrefix" + "$ref": "#/components/schemas/StripPathPrefixPatch" } } }, @@ -1242,6 +1242,15 @@ "description": "The command that will be run i.e. will overwrite the image Dockerfile ENTRYPOINT, equivalent to command in Kubernetes", "minItems": 1 }, + "EnvironmentPatchCommand": { + "type": "array", + "description": "The command that will be run i.e. will overwrite the image Dockerfile ENTRYPOINT, equivalent to command in Kubernetes", + "items": { + "type": "string" + }, + "nullable": true, + "minItems": 1 + }, "EnvironmentArgs": { "type": "array", "items": { @@ -1250,11 +1259,24 @@ "description": "The arguments that will follow the command, i.e. will overwrite the image Dockerfile CMD, equivalent to args in Kubernetes", "minItems": 1 }, + "EnvironmentPatchArgs": { + "type": "array", + "description": "The arguments that will follow the command, i.e. will overwrite the image Dockerfile CMD, equivalent to args in Kubernetes", + "items": { + "type": "string" + }, + "nullable": true, + "minItems": 1 + }, "IsArchived": { "type": "boolean", "description": "Whether this environment is archived and not for use in new projects or not", "default": false }, + "IsArchivedPatch": { + "type": "boolean", + "description": "Whether this environment is archived and not for use in new projects or not" + }, "Build": { "description": "A container image build", "type": "object", @@ -1332,6 +1354,10 @@ "default": false, "description": "If set to true the default url and the base path where sessions are\nserved will be removed from all URL paths before the requests reach\nthe server running in the session. So the server in the session will\nreceive HTTP requests whose base path will be \"/\". However this will\nnot work unless the server running inside the session can be made\naware that paths are rewritten. For example, if the application/server\nrunning in the session serves a HTML page that then loads javascript\nand CSS, the path where these assets should be loaded from in the browser\nwill not be \"/\" but it has to include the prefix that was stripped. And\nthe server from the session that generated the HTML page needs to know\nwhat is the full base path (including the part that was stripped) so that\nit can make the URLs to such assets be reachable from the browser." }, + "StripPathPrefixPatch": { + "type": "boolean", + "description": "If set to true the default url and the base path where sessions are\nserved will be removed from all URL paths before the requests reach\nthe server running in the session. So the server in the session will\nreceive HTTP requests whose base path will be \"/\". However this will\nnot work unless the server running inside the session can be made\naware that paths are rewritten. For example, if the application/server\nrunning in the session serves a HTML page that then loads javascript\nand CSS, the path where these assets should be loaded from in the browser\nwill not be \"/\" but it has to include the prefix that was stripped. And\nthe server from the session that generated the HTML page needs to know\nwhat is the full base path (including the part that was stripped) so that\nit can make the URLs to such assets be reachable from the browser." + }, "BuildPatch": { "description": "The requested update of a container image build", "type": "object", diff --git a/client/src/features/sessionsV2/session.utils.ts b/client/src/features/sessionsV2/session.utils.ts index 7dd4442086..989ecba0be 100644 --- a/client/src/features/sessionsV2/session.utils.ts +++ b/client/src/features/sessionsV2/session.utils.ts @@ -180,7 +180,23 @@ export function getFormattedEnvironmentValuesForEdit( environmentSelect === "global" || environmentSelect === "custom + image" ) { - return getFormattedEnvironmentValues(data); + const result = getFormattedEnvironmentValues(data); + if (!result.success) { + return result; + } + const { data: environment } = result; + const commandParsed = safeParseJSONStringArray(data.command); + const argsParsed = safeParseJSONStringArray(data.args); + return { + ...result, + data: { + ...environment, + ...(commandParsed.data + ? { command: commandParsed.data } + : { command: null }), + ...(argsParsed.data ? { args: argsParsed.data } : { args: null }), + }, + }; } const {