mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-25 01:25:36 -05:00
[SQL Migration] Properly respect user's encryptConnection and trustServerCertificate settings (#21824)
* WIP * Always get latest current connection * Update more references * Clean up * Clean up * vbump * Update comments * Address PR feedback * Separate into helper methods
This commit is contained in:
@@ -91,7 +91,7 @@ export class SavedAssessmentDialog {
|
||||
this.stateModel,
|
||||
this._serviceContextChangedEvent);
|
||||
|
||||
await wizardController.openWizard(this.stateModel.sourceConnectionId);
|
||||
await wizardController.openWizard();
|
||||
this._isOpen = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import { IconPath, IconPathHelper } from '../../constants/iconPathHelper';
|
||||
import * as styles from '../../constants/styles';
|
||||
import { EOL } from 'os';
|
||||
import { selectDatabasesFromList } from '../../constants/helper';
|
||||
import { getSourceConnectionProfile } from '../../api/sqlUtils';
|
||||
|
||||
const styleLeft: azdata.CssStyles = {
|
||||
'border': 'none',
|
||||
@@ -835,7 +836,7 @@ export class SqlDatabaseTree {
|
||||
let instanceTableValues: azdata.DeclarativeTableCellValue[][] = [];
|
||||
this._databaseTableValues = [];
|
||||
this._dbNames = this._model._databasesForAssessment;
|
||||
this._serverName = (await this._model.getSourceConnectionProfile()).serverName;
|
||||
this._serverName = (await getSourceConnectionProfile()).serverName;
|
||||
|
||||
// pre-select the entire list
|
||||
const selectedDbs = this._dbNames.filter(db => this._model._databasesForAssessment.includes(db));
|
||||
|
||||
@@ -14,6 +14,7 @@ import { WizardController } from '../../wizard/wizardController';
|
||||
import { getMigrationModeEnum, getMigrationTargetTypeEnum } from '../../constants/helper';
|
||||
import * as constants from '../../constants/strings';
|
||||
import { ServiceContextChangeEvent } from '../../dashboard/tabBase';
|
||||
import { getSourceConnectionProfile } from '../../api/sqlUtils';
|
||||
|
||||
export class RetryMigrationDialog {
|
||||
|
||||
@@ -27,12 +28,11 @@ export class RetryMigrationDialog {
|
||||
private async createMigrationStateModel(
|
||||
serviceContext: MigrationServiceContext,
|
||||
migration: DatabaseMigration,
|
||||
connectionId: string,
|
||||
serverName: string,
|
||||
api: mssql.IExtension,
|
||||
location: azureResource.AzureLocation): Promise<MigrationStateModel> {
|
||||
|
||||
const stateModel = new MigrationStateModel(this._context, connectionId, api.sqlMigration, api.tdeMigration);
|
||||
const stateModel = new MigrationStateModel(this._context, api.sqlMigration, api.tdeMigration);
|
||||
const sourceDatabaseName = migration.properties.sourceDatabaseName;
|
||||
const savedInfo: SavedInfo = {
|
||||
closedPage: 0,
|
||||
@@ -149,29 +149,26 @@ export class RetryMigrationDialog {
|
||||
}
|
||||
});
|
||||
|
||||
const activeConnection = await azdata.connection.getCurrentConnection();
|
||||
let connectionId: string = '';
|
||||
const activeConnection = await getSourceConnectionProfile();
|
||||
let serverName: string = '';
|
||||
if (!activeConnection) {
|
||||
const connection = await azdata.connection.openConnectionDialog();
|
||||
if (connection) {
|
||||
connectionId = connection.connectionId;
|
||||
serverName = connection.options.server;
|
||||
}
|
||||
} else {
|
||||
connectionId = activeConnection.connectionId;
|
||||
serverName = activeConnection.serverName;
|
||||
}
|
||||
|
||||
const api = (await vscode.extensions.getExtension(mssql.extension.name)?.activate()) as mssql.IExtension;
|
||||
const stateModel = await this.createMigrationStateModel(this._serviceContext, this._migration, connectionId, serverName, api, location!);
|
||||
const stateModel = await this.createMigrationStateModel(this._serviceContext, this._migration, serverName, api, location!);
|
||||
|
||||
if (await stateModel.loadSavedInfo()) {
|
||||
const wizardController = new WizardController(
|
||||
this._context,
|
||||
stateModel,
|
||||
this._serviceContextChangedEvent);
|
||||
await wizardController.openWizard(stateModel.sourceConnectionId);
|
||||
await wizardController.openWizard();
|
||||
} else {
|
||||
void vscode.window.showInformationMessage(constants.MIGRATION_CANNOT_RETRY);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import * as styles from '../../constants/styles';
|
||||
import * as utils from '../../api/utils';
|
||||
import { SKURecommendationPage } from '../../wizard/skuRecommendationPage';
|
||||
import { EOL } from 'os';
|
||||
import { getSourceConnectionProfile } from '../../api/sqlUtils';
|
||||
|
||||
export class GetAzureRecommendationDialog {
|
||||
private static readonly StartButtonText: string = constants.AZURE_RECOMMENDATION_START;
|
||||
@@ -333,7 +334,7 @@ export class GetAzureRecommendationDialog {
|
||||
this.skuRecommendationPage);
|
||||
break;
|
||||
case PerformanceDataSourceOptions.OpenExisting: {
|
||||
const serverName = (await this.migrationStateModel.getSourceConnectionProfile()).serverName;
|
||||
const serverName = (await getSourceConnectionProfile()).serverName;
|
||||
const errors: string[] = [];
|
||||
try {
|
||||
await this.skuRecommendationPage.startCardLoading();
|
||||
|
||||
@@ -45,7 +45,6 @@ export class TableMigrationSelectionDialog {
|
||||
const targetDatabaseInfo = this._model._sourceTargetMapping.get(this._sourceDatabaseName);
|
||||
if (targetDatabaseInfo) {
|
||||
const sourceTableList: TableInfo[] = await collectSourceDatabaseTableInfo(
|
||||
this._model.sourceConnectionId,
|
||||
this._sourceDatabaseName);
|
||||
|
||||
const targetTableList: TableInfo[] = await collectTargetDatabaseTableInfo(
|
||||
|
||||
@@ -10,6 +10,7 @@ import { validateIrDatabaseMigrationSettings, validateIrSqlDatabaseMigrationSett
|
||||
import { MigrationStateModel, MigrationTargetType, NetworkShare, ValidateIrState, ValidationResult } from '../../models/stateMachine';
|
||||
import { EOL } from 'os';
|
||||
import { IconPathHelper } from '../../constants/iconPathHelper';
|
||||
import { getEncryptConnectionValue, getSourceConnectionProfile, getTrustServerCertificateValue } from '../../api/sqlUtils';
|
||||
|
||||
const DialogName = 'ValidateIrDialog';
|
||||
|
||||
@@ -363,11 +364,10 @@ export class ValidateIrDialog {
|
||||
}
|
||||
|
||||
private async _validateDatabaseMigration(): Promise<void> {
|
||||
const sqlConnections = await azdata.connection.getConnections();
|
||||
const currentConnection = sqlConnections.find(
|
||||
value => value.connectionId === this._model.sourceConnectionId);
|
||||
const currentConnection = await getSourceConnectionProfile();
|
||||
const sourceServerName = currentConnection?.serverName!;
|
||||
const trustServerCertificate = currentConnection?.options?.trustServerCertificate === true;
|
||||
const encryptConnection = getEncryptConnectionValue(currentConnection);
|
||||
const trustServerCertificate = getTrustServerCertificateValue(currentConnection);
|
||||
const databaseCount = this._model._databasesForMigration.length;
|
||||
const sourceDatabaseName = this._model._databasesForMigration[0];
|
||||
const networkShare = this._model._databaseBackup.networkShares[0];
|
||||
@@ -385,6 +385,7 @@ export class ValidateIrDialog {
|
||||
const response = await validateIrDatabaseMigrationSettings(
|
||||
this._model,
|
||||
sourceServerName,
|
||||
encryptConnection,
|
||||
trustServerCertificate,
|
||||
sourceDatabase,
|
||||
network,
|
||||
@@ -447,11 +448,10 @@ export class ValidateIrDialog {
|
||||
}
|
||||
|
||||
private async _validateSqlDbMigration(): Promise<void> {
|
||||
const sqlConnections = await azdata.connection.getConnections();
|
||||
const currentConnection = sqlConnections.find(
|
||||
value => value.connectionId === this._model.sourceConnectionId);
|
||||
const currentConnection = await getSourceConnectionProfile();
|
||||
const sourceServerName = currentConnection?.serverName!;
|
||||
const trustServerCertificate = currentConnection?.options['trustServerCertificate'] === true;
|
||||
const encryptConnection = getEncryptConnectionValue(currentConnection);
|
||||
const trustServerCertificate = getTrustServerCertificateValue(currentConnection);
|
||||
const databaseCount = this._model._databasesForMigration.length;
|
||||
const sourceDatabaseName = this._model._databasesForMigration[0];
|
||||
const targetDatabaseName = this._model._sourceTargetMapping.get(sourceDatabaseName)?.databaseName ?? '';
|
||||
@@ -469,6 +469,7 @@ export class ValidateIrDialog {
|
||||
const response = await validateIrSqlDatabaseMigrationSettings(
|
||||
this._model,
|
||||
sourceServerName,
|
||||
encryptConnection,
|
||||
trustServerCertificate,
|
||||
sourceDatabase,
|
||||
targetDatabase,
|
||||
|
||||
Reference in New Issue
Block a user