Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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/feat-1009-allow-dc-skip";

async function main() {
argv.forEach((arg) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,17 @@ export default function useDataConnectorConfiguration({
const savedCredentialFields = dataConnectorSecrets
? dataConnectorSecrets[dataConnector.id]?.map((s) => s.name)
: [];
return {
const result: SessionStartDataConnectorConfiguration = {
active: true,
dataConnector,
sensitiveFieldDefinitions,
sensitiveFieldValues,
saveCredentials: false,
savedCredentialFields,
sensitiveFieldDefinitions,
sensitiveFieldValues,
skip: false,
touched: false,
};
return result;
}),
[dataConnectors, dataConnectorSecrets]
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import type { SessionStartDataConnectorConfiguration } from "../../sessionsV2/startSessionOptionsV2.types";
import type { CloudStorageSchema } from "../components/cloudStorage/projectCloudStorage.types";
import {
dataConnectorsOverrideFromConfig,
getSchemaOptions,
storageDefinitionFromConfig,
} from "./projectCloudStorage.utils";

describe("storageDefinitionFromConfig", () => {
it("should return the correct storage definition", () => {
const config: SessionStartDataConnectorConfiguration = {
active: true,
skip: false,
touched: true,
dataConnector: {
id: "ULID-1",
etag: "foo",
Expand Down Expand Up @@ -79,21 +81,19 @@ describe("storageDefinitionFromConfig", () => {
saveCredentials: false,
savedCredentialFields: [],
};
const result = storageDefinitionFromConfig(config);
expect(result).toEqual({
configuration: {
type: "s3",
provider: "AWS",
access_key_id: "access key",
secret_access_key: "secret key",
const result = dataConnectorsOverrideFromConfig(config);
expect(result).toEqual([
{
configuration: {
type: "s3",
provider: "AWS",
access_key_id: "access key",
secret_access_key: "secret key",
},
data_connector_id: "ULID-1",
skip: false,
},
name: "example-storage",
readonly: true,
source_path: "bucket/my-source",
storage_id: "ULID-1",
storage_type: "s3",
target_path: "external_storage/aws",
});
]);
});

it("should return the correct schema options", () => {
Expand Down
49 changes: 26 additions & 23 deletions client/src/features/project/utils/projectCloudStorage.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
* limitations under the License.
*/

import { type SessionDataConnectorOverride } from "~/features/sessionsV2/api/sessionsV2.api";
import type {
RCloneConfig,
RCloneOption,
} from "../../dataConnectorsV2/api/data-connectors.api";
import { hasSchemaAccessMode } from "../../dataConnectorsV2/components/dataConnector.utils";
import type { SessionCloudStorageV2 } from "../../sessionsV2/sessionsV2.types";
import type { SessionStartDataConnectorConfiguration } from "../../sessionsV2/startSessionOptionsV2.types";
import type { CloudStorageGet } from "../components/cloudStorage/api/projectCloudStorage.api";
import {
CLOUD_OPTIONS_OVERRIDE,
Expand All @@ -35,17 +36,15 @@ import {
STORAGES_WITH_ACCESS_MODE,
} from "../components/cloudStorage/projectCloudStorage.constants";
import type {
CloudStorage,
CloudStorageCredential,
CloudStorageDetails,
CloudStorageOptionTypes,
CloudStorageSchemaOption,
CloudStorageProvider,
CloudStorageSchema,
CloudStorage,
CloudStorageSchemaOption,
} from "../components/cloudStorage/projectCloudStorage.types";

import { SessionStartDataConnectorConfiguration } from "../../sessionsV2/startSessionOptionsV2.types";

const LAST_POSITION = 1000;

export interface CloudStorageOptions extends RCloneOption {
Expand Down Expand Up @@ -324,8 +323,12 @@ export function findSensitive(

export function storageDefinitionAfterSavingCredentialsFromConfig(
cs: SessionStartDataConnectorConfiguration
) {
const newCs = { ...cs, saveCredentials: false };
): SessionStartDataConnectorConfiguration {
const newCs: SessionStartDataConnectorConfiguration = {
...cs,
saveCredentials: false,
touched: false,
};
const newStorage = { ...newCs.dataConnector.storage };
// The following two lines remove the sensitive fields from the storage configuration,
// which should be ok, but isn't; so keep in the sensitive fields.
Expand All @@ -339,27 +342,27 @@ export function storageDefinitionAfterSavingCredentialsFromConfig(
return newCs;
}

export function storageDefinitionFromConfig(
export function dataConnectorsOverrideFromConfig(
config: SessionStartDataConnectorConfiguration
): SessionCloudStorageV2 {
const storageDefinition = config.dataConnector.storage;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { sensitive_fields, ...s } = config.dataConnector.storage;
const newStorageDefinition = {
...s,
name: config.dataConnector.slug,
storage_id: config.dataConnector.id,
};
newStorageDefinition.configuration = { ...storageDefinition.configuration };
const sensitiveFieldValues = config.sensitiveFieldValues;
Object.entries(sensitiveFieldValues).forEach(([name, value]) => {
): SessionDataConnectorOverride[] {
if (!config.skip && !config.touched) {
return [];
}

const configuration = { ...config.dataConnector.storage.configuration };
Object.entries(config.sensitiveFieldValues).forEach(([name, value]) => {
if (value != null && value !== "") {
newStorageDefinition.configuration[name] = value;
configuration[name] = value;
} else {
delete newStorageDefinition.configuration[name];
delete configuration[name];
}
});
return newStorageDefinition;
const override: SessionDataConnectorOverride = {
skip: config.skip,
data_connector_id: config.dataConnector.id,
configuration,
};
return [override];
}

function overrideOptions(
Expand Down
27 changes: 11 additions & 16 deletions client/src/features/sessionsV2/DataConnectorSecretsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const CONTEXT_STRINGS = {
dataCy: "session-data-connector-credentials-modal",
header: "Session Storage Credentials",
testError:
"The data connector could not be mounted. Please retry with different credentials, or skip the test. If you skip, the data connector will still try to mount, using the provided credentials, at session launch time.",
"The data connector could not be mounted. Please retry with different credentials, or skip the data connector. If you skip, the data connector will not be mounted in the session.",
},
storage: {
continueButton: "Test and Save",
Expand Down Expand Up @@ -222,6 +222,8 @@ export default function DataConnectorSecretsModal({
newCloudStorageConfigs[index] = {
...dataConnectorConfigs[index],
active: false,
saveCredentials: false,
skip: true,
};
setDataConnectorConfigs(newCloudStorageConfigs);
onNext(newCloudStorageConfigs);
Expand All @@ -232,7 +234,10 @@ export default function DataConnectorSecretsModal({
if (dataConnectorConfigs == null || dataConnectorConfigs.length < 1)
return;

const config = { ...dataConnectorConfigs[index] };
const config: DataConnectorConfiguration = {
...dataConnectorConfigs[index],
touched: true,
};
const sensitiveFieldValues = { ...config.sensitiveFieldValues };
const { saveCredentials } = options;
if (saveCredentials === true || saveCredentials === false) {
Expand Down Expand Up @@ -349,12 +354,7 @@ function CredentialsButtons({
<XLg className={cx("bi", "me-1")} />
Cancel
</Button>
{context === "session" && (
<SkipConnectionTestButton
onSkip={onSkip}
validationResult={validationResult}
/>
)}
{context === "session" && <SkipConnectionTestButton onSkip={onSkip} />}
{context === "storage" && (
<ClearCredentialsButton
onSkip={onSkip}
Expand Down Expand Up @@ -441,6 +441,7 @@ function ProgressBreadcrumbs({
newCloudStorageConfigs[idx] = {
...dataConnectorConfigs[idx],
active: true,
skip: false,
};
setDataConnectorConfigs(newCloudStorageConfigs);
setIndex(idx);
Expand Down Expand Up @@ -615,8 +616,7 @@ function SensitiveFieldInput({

function SkipConnectionTestButton({
onSkip,
validationResult,
}: Pick<CredentialsButtonsProps, "onSkip" | "validationResult">) {
}: Pick<CredentialsButtonsProps, "onSkip">) {
const skipButtonRef = useRef<HTMLAnchorElement>(null);
return (
<>
Expand All @@ -627,12 +627,7 @@ function SkipConnectionTestButton({
</Button>
</span>
<UncontrolledTooltip target={skipButtonRef}>
Skip the connection test. At session launch, the storage will try to
mount
{validationResult.isError
? " using the provided credentials"
: " without any credentials"}
.
Skip the data connector. It will not be mounted in the session.
</UncontrolledTooltip>
</>
);
Expand Down
Loading
Loading