Added check for .toLowerCase and added upgrade message for clarity. (#20187)

Co-authored-by: Candice Ye <canye@microsoft.com>
This commit is contained in:
Candice Ye
2022-07-28 13:52:26 -07:00
committed by GitHub
parent d3073a33fe
commit 28d5382dc3
8 changed files with 76 additions and 42 deletions

View File

@@ -253,6 +253,10 @@ export function deletingInstance(name: string): string { return localize('arc.de
export function installingExtension(name: string): string { return localize('arc.installingExtension', "Installing extension '{0}'...", name); }
export function extensionInstalled(name: string): string { return localize('arc.extensionInstalled', "Extension '{0}' has been installed.", name); }
export function updatingInstance(name: string): string { return localize('arc.updatingInstance', "Updating instance '{0}'...", name); }
export function upgradingDirectDC(name: string, desiredVersion: string, resourceGroup: string): string { return localize('arc.upgradingDirectDC', "Upgrading data controller '{0}' with command 'az arcdata dc upgrade --desired-version {1} --name {0} --resource-group {2}'", name, desiredVersion, resourceGroup); }
export function upgradingIndirectDC(name: string, desiredVersion: string, namespace: string): string { return localize('arc.upgradingIndirectDC', "Upgrading data controller '{0}' with command 'az arcdata dc upgrade --desired-version {1} --name {0} --k8s-namespace {2} --use-k8s'", name, desiredVersion, namespace); }
export function upgradingDirectMiaa(name: string, resourceGroup: string): string { return localize('arc.upgradingDirectMiaa', "Upgrading SQL MIAA '{0}' with command 'az sql mi-arc upgrade --name {0} --resource-group {1}'", name, resourceGroup); }
export function upgradingIndirectMiaa(name: string, namespace: string): string { return localize('arc.upgradingIndirectMiaa', "Upgrading SQL MIAA '{0}' with command 'az sql mi-arc upgrade --name {0} --k8s-namespace {1} --use-k8s'", name, namespace); }
export function instanceDeleted(name: string): string { return localize('arc.instanceDeleted', "Instance '{0}' deleted", name); }
export function instanceUpdated(name: string): string { return localize('arc.instanceUpdated', "Instance '{0}' updated", name); }
export function extensionsDropped(name: string): string { return localize('arc.extensionsDropped', "Extensions '{0}' dropped", name); }

View File

@@ -100,7 +100,7 @@ export class MiaaModel extends ResourceModel {
try {
try {
let result;
if (this.controllerModel.info.connectionMode === ConnectionMode.direct) {
if (this.controllerModel.info.connectionMode.toLowerCase() === ConnectionMode.direct) {
result = await this._azApi.az.sql.miarc.show(
this.info.name,
{

View File

@@ -222,15 +222,15 @@ export class ControllerUpgradesPage extends DashboardPage {
try {
upgradeButton.enabled = false;
vscode.window.showInformationMessage(loc.upgradingController('kubectl get datacontrollers -A\' should not be localized.'));
await vscode.window.withProgress(
{
location: vscode.ProgressLocation.Notification,
title: loc.updatingInstance(this._controllerModel.info.name),
cancellable: true
},
async (_progress, _token): Promise<void> => {
if (nextVersion !== '') {
if (this._controllerModel.info.connectionMode === ConnectionMode.direct) {
if (this._controllerModel.info.connectionMode.toLowerCase() === ConnectionMode.direct) {
await vscode.window.withProgress(
{
location: vscode.ProgressLocation.Notification,
title: loc.upgradingDirectDC(this._controllerModel.info.name, nextVersion, this._controllerModel.info.resourceGroup),
cancellable: true
},
async (_progress, _token): Promise<void> => {
if (nextVersion !== '') {
await this._azApi.az.arcdata.dc.upgrade(
nextVersion,
this._controllerModel.info.name,
@@ -238,24 +238,41 @@ export class ControllerUpgradesPage extends DashboardPage {
undefined, // Indirect mode argument - namespace
);
} else {
vscode.window.showInformationMessage(loc.noUpgrades);
}
try {
await this._controllerModel.refresh(false, this._controllerModel.info.namespace);
} catch (error) {
vscode.window.showErrorMessage(loc.refreshFailed(error));
}
}
);
} else {
await vscode.window.withProgress(
{
location: vscode.ProgressLocation.Notification,
title: loc.upgradingIndirectDC(this._controllerModel.info.name, nextVersion, this._controllerModel.info.namespace),
cancellable: true
},
async (_progress, _token): Promise<void> => {
if (nextVersion !== '') {
await this._azApi.az.arcdata.dc.upgrade(
nextVersion,
this._controllerModel.info.name,
undefined, // Direct mode argument - resourceGroup
this._controllerModel.info.namespace,
);
} else {
vscode.window.showInformationMessage(loc.noUpgrades);
}
try {
await this._controllerModel.refresh(false, this._controllerModel.info.namespace);
} catch (error) {
vscode.window.showErrorMessage(loc.refreshFailed(error));
}
} else {
vscode.window.showInformationMessage(loc.noUpgrades);
}
try {
await this._controllerModel.refresh(false, this._controllerModel.info.namespace);
} catch (error) {
vscode.window.showErrorMessage(loc.refreshFailed(error));
}
}
);
);
}
} catch (error) {
console.log(error);
}

View File

@@ -220,7 +220,7 @@ export class MiaaBackupsPage extends DashboardPage {
cancellable: false
},
async (_progress, _token): Promise<void> => {
if (this._miaaModel.controllerModel.info.connectionMode === ConnectionMode.direct) {
if (this._miaaModel.controllerModel.info.connectionMode.toLowerCase() === ConnectionMode.direct) {
await this._azApi.az.sql.miarc.update(
this._miaaModel.info.name,
this._saveArgs,

View File

@@ -132,7 +132,7 @@ export class MiaaComputeAndStoragePage extends DashboardPage {
},
async (_progress, _token): Promise<void> => {
try {
if (this._miaaModel.controllerModel.info.connectionMode === ConnectionMode.direct) {
if (this._miaaModel.controllerModel.info.connectionMode.toLowerCase() === ConnectionMode.direct) {
await this._azApi.az.sql.miarc.update(
this._miaaModel.info.name,
this.saveArgs,

View File

@@ -243,7 +243,7 @@ export class MiaaDashboardOverviewPage extends DashboardPage {
cancellable: false
},
async (_progress, _token) => {
if (this._controllerModel.info.connectionMode === ConnectionMode.direct) {
if (this._controllerModel.info.connectionMode.toLowerCase() === ConnectionMode.direct) {
return await this._azApi.az.sql.miarc.delete(
this._miaaModel.info.name,
{

View File

@@ -160,7 +160,7 @@ export class MiaaUpgradeManagementPage extends DashboardPage {
private async getMiaaVersion(): Promise<string | undefined> {
try {
let miaaShowResult;
if (this._controllerModel.info.connectionMode === ConnectionMode.direct || this._controllerModel.controllerConfig?.spec.settings.azure.connectionMode.toLowerCase() === ConnectionMode.direct) {
if (this._controllerModel.info.connectionMode.toLowerCase() === ConnectionMode.direct || this._controllerModel.controllerConfig?.spec.settings.azure.connectionMode.toLowerCase() === ConnectionMode.direct) {
miaaShowResult = await this._azApi.az.sql.miarc.show(
this._miaaModel.info.name,
{
@@ -263,14 +263,14 @@ export class MiaaUpgradeManagementPage extends DashboardPage {
try {
upgradeButton.enabled = false;
vscode.window.showInformationMessage(loc.upgradingMiaa('kubectl get sqlmi -A\' should not be localized.'));
await vscode.window.withProgress(
{
location: vscode.ProgressLocation.Notification,
title: loc.updatingInstance(this._miaaModel.info.name),
cancellable: true
},
async (_progress, _token): Promise<void> => {
if (this._controllerModel.info.connectionMode === ConnectionMode.direct) {
if (this._controllerModel.info.connectionMode.toLowerCase() === ConnectionMode.direct) {
await vscode.window.withProgress(
{
location: vscode.ProgressLocation.Notification,
title: loc.upgradingDirectMiaa(this._miaaModel.info.name, this._controllerModel.info.resourceGroup),
cancellable: true
},
async (_progress, _token): Promise<void> => {
await this._azApi.az.sql.miarc.upgrade(
this._miaaModel.info.name,
{
@@ -278,7 +278,21 @@ export class MiaaUpgradeManagementPage extends DashboardPage {
namespace: undefined
}
);
} else {
try {
await this._controllerModel.refresh(false, this._controllerModel.info.namespace);
} catch (error) {
vscode.window.showErrorMessage(loc.refreshFailed(error));
}
}
);
} else {
await vscode.window.withProgress(
{
location: vscode.ProgressLocation.Notification,
title: loc.upgradingIndirectMiaa(this._miaaModel.info.name, this._controllerModel.info.namespace),
cancellable: true
},
async (_progress, _token): Promise<void> => {
await this._azApi.az.sql.miarc.upgrade(
this._miaaModel.info.name,
{
@@ -286,15 +300,14 @@ export class MiaaUpgradeManagementPage extends DashboardPage {
namespace: this._controllerModel.info.namespace,
}
);
try {
await this._controllerModel.refresh(false, this._controllerModel.info.namespace);
} catch (error) {
vscode.window.showErrorMessage(loc.refreshFailed(error));
}
}
try {
await this._controllerModel.refresh(false, this._controllerModel.info.namespace);
} catch (error) {
vscode.window.showErrorMessage(loc.refreshFailed(error));
}
}
);
);
}
} catch (error) {
console.log(error);
}

View File

@@ -204,7 +204,7 @@ export class ConnectToControllerDialog extends ControllerDialogBase {
controllerModel.info.connectionMode = <string>controllerModel.controllerConfig?.spec.settings.azure.connectionMode.toLowerCase();
controllerModel.info.location = <string>controllerModel.controllerConfig?.spec.settings.azure.location;
if (controllerModel.info.connectionMode === ConnectionMode.direct) {
if (controllerModel.info.connectionMode.toLowerCase() === ConnectionMode.direct) {
const rawCustomLocation = <string>controllerModel.controllerConfig?.metadata.annotations['management.azure.com/customLocation'];
const exp = /custom[lL]ocations\/([\S]*)/;
controllerModel.info.customLocation = <string>exp.exec(rawCustomLocation)?.pop();