Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/scripts/update_api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { parseDocument } from "yaml";

const GH_BASE_URL = "https://raw.githubusercontent.com";
const DATA_SERVICES_REPO = "SwissDataScienceCenter/renku-data-services";
const DATA_SERVICES_RELEASE = "main";
const DATA_SERVICES_RELEASE = "leafty/fix-session-env-api";

async function main() {
argv.forEach((arg) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }),
},
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,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;
Expand All @@ -299,10 +303,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 & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@
"$ref": "#/components/schemas/EnvironmentKind"
}
],
"default": "custom"
"default": "CUSTOM"
}
},
"required": ["environment_image_source", "environment_kind"]
Expand Down Expand Up @@ -685,7 +685,7 @@
"$ref": "#/components/schemas/EnvironmentKind"
}
],
"default": "custom"
"default": "CUSTOM"
}
},
"required": [
Expand Down Expand Up @@ -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"
}
}
},
Expand Down Expand Up @@ -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": {
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
18 changes: 17 additions & 1 deletion client/src/features/sessionsV2/session.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading