mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-05-20 15:25:07 +01:00
fix vcore username
This commit is contained in:
parent
8b4eaa95ea
commit
9db1edca03
@ -22,7 +22,7 @@ export const CloudShellTerminalComponent: React.FC<CloudShellTerminalProps> = ({
|
|||||||
const term = new Terminal({
|
const term = new Terminal({
|
||||||
cursorBlink: true,
|
cursorBlink: true,
|
||||||
cursorStyle: 'bar',
|
cursorStyle: 'bar',
|
||||||
fontFamily: 'Courier New, monospace',
|
fontFamily: 'monospace',
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
theme: {
|
theme: {
|
||||||
background: "#1e1e1e",
|
background: "#1e1e1e",
|
||||||
@ -38,18 +38,6 @@ export const CloudShellTerminalComponent: React.FC<CloudShellTerminalProps> = ({
|
|||||||
if (terminalRef.current) {
|
if (terminalRef.current) {
|
||||||
term.open(terminalRef.current);
|
term.open(terminalRef.current);
|
||||||
xtermRef.current = term;
|
xtermRef.current = term;
|
||||||
|
|
||||||
// Ensure the CSS is injected only once
|
|
||||||
if (!document.getElementById("xterm-custom-style")) {
|
|
||||||
const style = document.createElement("style");
|
|
||||||
style.id = "xterm-custom-style"; // Unique ID to prevent duplicates
|
|
||||||
style.innerHTML = `
|
|
||||||
.xterm-text-layer {
|
|
||||||
transform: translateX(10px); /* Adds left padding */
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
document.head.appendChild(style);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fitAddon) {
|
if (fitAddon) {
|
||||||
@ -76,11 +64,6 @@ export const CloudShellTerminalComponent: React.FC<CloudShellTerminalProps> = ({
|
|||||||
}
|
}
|
||||||
window.removeEventListener('resize', handleResize);
|
window.removeEventListener('resize', handleResize);
|
||||||
term.dispose(); // Clean up XTerm instance
|
term.dispose(); // Clean up XTerm instance
|
||||||
|
|
||||||
const styleElement = document.getElementById("xterm-custom-style");
|
|
||||||
if (styleElement) {
|
|
||||||
styleElement.remove(); // Clean up CSS on unmount
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}, []);
|
}, []);
|
||||||
|
@ -108,8 +108,8 @@ export const commands = (terminalKind: TerminalKind, config?: CommandConfig): st
|
|||||||
"source ~/.bashrc",
|
"source ~/.bashrc",
|
||||||
// 8. Verify mongosh installation
|
// 8. Verify mongosh installation
|
||||||
"mongosh --version",
|
"mongosh --version",
|
||||||
// 9. Login to MongoDBmongosh mongodb+srv://<credentials>@neesharma-stage-mongo-vcore.mongocluster.cosmos.azure.com/?authMechanism=SCRAM-SHA-256&retrywrites=false&maxIdleTimeMS=120000\u0007
|
// 10. Login to MongoDBmongosh mongodb+srv://<credentials>@neesharma-stage-mongo-vcore.mongocluster.cosmos.azure.com/?authMechanism=SCRAM-SHA-256&retrywrites=false&maxIdleTimeMS=120000\u0007
|
||||||
`mongosh "mongodb+srv://nrj:@${config.endpoint}/?authMechanism=SCRAM-SHA-256&retrywrites=false&maxIdleTimeMS=120000" --tls --tlsAllowInvalidCertificates`
|
`read -p "Enter username: " username && mongosh "mongodb+srv://$username:@${config.endpoint}/?authMechanism=SCRAM-SHA-256&retrywrites=false&maxIdleTimeMS=120000" --tls --tlsAllowInvalidCertificates`
|
||||||
];
|
];
|
||||||
case TerminalKind.Cassandra:
|
case TerminalKind.Cassandra:
|
||||||
return [
|
return [
|
||||||
|
@ -52,7 +52,6 @@ export const getUserSettings = async (): Promise<Settings> => {
|
|||||||
apiVersion: "2023-02-01-preview"
|
apiVersion: "2023-02-01-preview"
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(resp);
|
|
||||||
return resp;
|
return resp;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -69,16 +68,13 @@ export const putEphemeralUserSettings = async (userSubscriptionId: string, userR
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const resp = await armRequest({
|
return await armRequest({
|
||||||
host: configContext.ARM_ENDPOINT,
|
host: configContext.ARM_ENDPOINT,
|
||||||
path: `/providers/Microsoft.Portal/userSettings/cloudconsole`,
|
path: `/providers/Microsoft.Portal/userSettings/cloudconsole`,
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
apiVersion: "2023-02-01-preview",
|
apiVersion: "2023-02-01-preview",
|
||||||
body: ephemeralSettings
|
body: ephemeralSettings
|
||||||
});
|
});
|
||||||
|
|
||||||
return resp;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const verifyCloudShellProviderRegistration = async(subscriptionId: string) => {
|
export const verifyCloudShellProviderRegistration = async(subscriptionId: string) => {
|
||||||
|
@ -23,6 +23,12 @@ export const enum SessionType {
|
|||||||
Ephemeral = "Ephemeral"
|
Ephemeral = "Ephemeral"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const enum UserInputs {
|
||||||
|
NoReset = "1",
|
||||||
|
ConfigureVNet = "2",
|
||||||
|
ResetVNet = "3"
|
||||||
|
};
|
||||||
|
|
||||||
export type Settings = {
|
export type Settings = {
|
||||||
properties: UserSettingProperties
|
properties: UserSettingProperties
|
||||||
};
|
};
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { RelayNamespaceResponse, VnetModel, VnetSettings } from "Explorer/Tabs/CloudShellTab/DataModels";
|
import { RelayNamespaceResponse, UserInputs, VnetModel, VnetSettings } from "Explorer/Tabs/CloudShellTab/DataModels";
|
||||||
import { listKeys } from "Utils/arm/generatedClients/cosmos/databaseAccounts";
|
import { listKeys } from "Utils/arm/generatedClients/cosmos/databaseAccounts";
|
||||||
import { Terminal } from "xterm";
|
import { Terminal } from "xterm";
|
||||||
import { TerminalKind } from "../../../Contracts/ViewModels";
|
import { TerminalKind } from "../../../Contracts/ViewModels";
|
||||||
@ -16,18 +16,7 @@ export const startCloudShellTerminal = async (terminal: Terminal, shellType: Ter
|
|||||||
|
|
||||||
// validate that the subscription id is registered in the CloudShell namespace
|
// validate that the subscription id is registered in the CloudShell namespace
|
||||||
terminal.writeln("");
|
terminal.writeln("");
|
||||||
try {
|
await ensureCloudShellRegistration(terminal);
|
||||||
terminal.writeln("\x1B[34mVerifying CloudShell provider registration...\x1B[0m");
|
|
||||||
const response: any = await verifyCloudShellProviderRegistration(userContext.subscriptionId);
|
|
||||||
if (response.registrationState !== "Registered") {
|
|
||||||
terminal.writeln("\x1B[33mCloudShell provider registration is not found. Registering now...\x1B[0m");
|
|
||||||
await registerCloudShellProvider(userContext.subscriptionId);
|
|
||||||
terminal.writeln("\x1B[32mCloudShell provider registration completed successfully.\x1B[0m");
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
terminal.writeln("\x1B[31mError: Unable to verify CloudShell provider registration.\x1B[0m");
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
|
|
||||||
terminal.writeln("");
|
terminal.writeln("");
|
||||||
terminal.writeln("\x1B[34mFetching user settings...\x1B[0m");
|
terminal.writeln("\x1B[34mFetching user settings...\x1B[0m");
|
||||||
@ -68,14 +57,13 @@ export const startCloudShellTerminal = async (terminal: Terminal, shellType: Ter
|
|||||||
|
|
||||||
terminal.focus();
|
terminal.focus();
|
||||||
|
|
||||||
let isDefaultSetting = false;
|
|
||||||
const handleKeyPress = terminal.onKey(async ({ key }: { key: string }) => {
|
const handleKeyPress = terminal.onKey(async ({ key }: { key: string }) => {
|
||||||
terminal.writeln("")
|
terminal.writeln("")
|
||||||
if (key === "1") {
|
if (key === UserInputs.NoReset) {
|
||||||
terminal.writeln("\x1B[34mYou selected option 1: Proceeding with current/default settings.\x1B[0m");
|
terminal.writeln("\x1B[34mYou selected option 1: Proceeding with current/default settings.\x1B[0m");
|
||||||
handleKeyPress.dispose();
|
handleKeyPress.dispose();
|
||||||
}
|
}
|
||||||
else if (key === "2") {
|
else if (key === UserInputs.ConfigureVNet) {
|
||||||
terminal.writeln("\x1B[34mYou selected option 2: Please provide the following details.\x1B[0m");
|
terminal.writeln("\x1B[34mYou selected option 2: Please provide the following details.\x1B[0m");
|
||||||
handleKeyPress.dispose();
|
handleKeyPress.dispose();
|
||||||
|
|
||||||
@ -118,7 +106,7 @@ export const startCloudShellTerminal = async (terminal: Terminal, shellType: Ter
|
|||||||
location: vNetConfig.location
|
location: vNetConfig.location
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else if (key === "3") {
|
else if (key === UserInputs.ResetVNet) {
|
||||||
terminal.writeln("\x1B[34mYou selected option 3: Resetting VNet settings to default.\x1B[0m");
|
terminal.writeln("\x1B[34mYou selected option 3: Resetting VNet settings to default.\x1B[0m");
|
||||||
|
|
||||||
vNetSettings = {};
|
vNetSettings = {};
|
||||||
@ -346,26 +334,38 @@ const provisionCloudShellSession = async(
|
|||||||
return reject(err);
|
return reject(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
// trigger callback to provision console internal
|
|
||||||
let provisionConsoleResponse;
|
let provisionConsoleResponse;
|
||||||
try {
|
const retryCount = 3;
|
||||||
provisionConsoleResponse = await provisionConsole(userContext.subscriptionId, resolvedRegion);
|
for (let i = 0; i < retryCount; i++) {
|
||||||
} catch (err) {
|
terminal.writeln(`\x1B[34mAttempting to provision console (Attempt ${i + 1}/${retryCount})...\x1B[0m`);
|
||||||
terminal.writeln(LogError('Unable to provision console.'));
|
// trigger callback to provision console internal
|
||||||
return reject(err);
|
try {
|
||||||
|
provisionConsoleResponse = await provisionConsole(userContext.subscriptionId, resolvedRegion);
|
||||||
|
} catch (err) {
|
||||||
|
terminal.writeln(LogError('Unable to provision console.'));
|
||||||
|
return reject(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add check for provisioning state
|
||||||
|
if (provisionConsoleResponse.properties.provisioningState !== "Succeeded") {
|
||||||
|
await wait(5000);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add check for provisioning state
|
// Add check for provisioning state
|
||||||
if (provisionConsoleResponse.properties.provisioningState !== "Succeeded") {
|
if (provisionConsoleResponse.properties.provisioningState !== "Succeeded") {
|
||||||
terminal.writeln(LogError("Failed to provision console."));
|
terminal.writeln(`\x1B[1;31mUnable to provision, Provisioning state: ${provisionConsoleResponse.properties.provisioningState}\x1B[0m`);
|
||||||
return reject(new Error("Failed to provision console."));
|
return reject(new Error("Unable to provision, Provisioning state: ${provisionConsoleResponse.properties.provisioningState}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
terminal.writeln("\x1B[34mConnecting to CloudShell Terminal...\x1B[0m");
|
terminal.writeln("\x1B[34mConnecting to CloudShell Terminal...\x1B[0m");
|
||||||
// connect the terminal
|
// connect the terminal
|
||||||
let connectTerminalResponse;
|
let connectTerminalResponse;
|
||||||
try {
|
try {
|
||||||
connectTerminalResponse = await connectTerminal(provisionConsoleResponse.properties.uri, { rows: terminal.rows, cols: terminal.cols });
|
connectTerminalResponse = await connectTerminal(provisionConsoleResponse.properties.uri, { rows: terminal.rows, cols: terminal.cols});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
terminal.writeln(LogError(`Unable to connect terminal. ${err}`));
|
terminal.writeln(LogError(`Unable to connect terminal. ${err}`));
|
||||||
return reject(err);
|
return reject(err);
|
||||||
@ -394,3 +394,21 @@ const provisionCloudShellSession = async(
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const ensureCloudShellRegistration = async(terminal: Terminal) => {
|
||||||
|
try {
|
||||||
|
terminal.writeln("\x1B[34mVerifying CloudShell provider registration...\x1B[0m");
|
||||||
|
const response: any = await verifyCloudShellProviderRegistration(userContext.subscriptionId);
|
||||||
|
if (response.registrationState !== "Registered") {
|
||||||
|
terminal.writeln("\x1B[33mCloudShell provider registration is not found. Registering now...\x1B[0m");
|
||||||
|
await registerCloudShellProvider(userContext.subscriptionId);
|
||||||
|
terminal.writeln("\x1B[32mCloudShell provider registration completed successfully.\x1B[0m");
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
terminal.writeln("\x1B[31mError: Unable to verify CloudShell provider registration.\x1B[0m");
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const wait = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user