mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Additional SQL Proj cleanup (#19836)
This commit is contained in:
@@ -38,7 +38,7 @@ import { DashboardData, PublishData, Status } from '../models/dashboardData/dash
|
|||||||
import { getPublishDatabaseSettings, launchPublishTargetOption } from '../dialogs/publishDatabaseQuickpick';
|
import { getPublishDatabaseSettings, launchPublishTargetOption } from '../dialogs/publishDatabaseQuickpick';
|
||||||
import { launchCreateAzureServerQuickPick, getPublishToDockerSettings } from '../dialogs/deployDatabaseQuickpick';
|
import { launchCreateAzureServerQuickPick, getPublishToDockerSettings } from '../dialogs/deployDatabaseQuickpick';
|
||||||
import { DeployService } from '../models/deploy/deployService';
|
import { DeployService } from '../models/deploy/deployService';
|
||||||
import { AddItemOptions, EntryType, GenerateProjectFromOpenApiSpecOptions, IDatabaseReferenceProjectEntry, IDeploySettings, IPublishToDockerSettings, ISqlProject, ItemType, SqlTargetPlatform } from 'sqldbproj';
|
import { AddItemOptions, EntryType, GenerateProjectFromOpenApiSpecOptions, IDatabaseReferenceProjectEntry, ISqlProjectPublishSettings, IPublishToDockerSettings, ISqlProject, ItemType, SqlTargetPlatform } from 'sqldbproj';
|
||||||
import { AutorestHelper } from '../tools/autorestHelper';
|
import { AutorestHelper } from '../tools/autorestHelper';
|
||||||
import { createNewProjectFromDatabaseWithQuickpick } from '../dialogs/createProjectFromDatabaseQuickpick';
|
import { createNewProjectFromDatabaseWithQuickpick } from '../dialogs/createProjectFromDatabaseQuickpick';
|
||||||
import { addDatabaseReferenceQuickpick } from '../dialogs/addDatabaseReferenceQuickpick';
|
import { addDatabaseReferenceQuickpick } from '../dialogs/addDatabaseReferenceQuickpick';
|
||||||
@@ -320,27 +320,27 @@ export class ProjectsController {
|
|||||||
const project: Project = this.getProjectFromContext(context);
|
const project: Project = this.getProjectFromContext(context);
|
||||||
// Removing the path separator from the image base name to be able to add that in the telemetry. With the separator the name is flagged as user path which is not true
|
// Removing the path separator from the image base name to be able to add that in the telemetry. With the separator the name is flagged as user path which is not true
|
||||||
// We only need to know the image base parts so it's ok to use a different separator when adding to telemetry
|
// We only need to know the image base parts so it's ok to use a different separator when adding to telemetry
|
||||||
const dockerImageNameForTelemetry = deployProfile.localDbSetting?.dockerBaseImage ? deployProfile.localDbSetting.dockerBaseImage.replace(/\//gi, '_') : '';
|
const dockerImageNameForTelemetry = deployProfile.dockerSettings?.dockerBaseImage ? deployProfile.dockerSettings.dockerBaseImage.replace(/\//gi, '_') : '';
|
||||||
try {
|
try {
|
||||||
TelemetryReporter.createActionEvent(TelemetryViews.ProjectController, TelemetryActions.publishToContainer)
|
TelemetryReporter.createActionEvent(TelemetryViews.ProjectController, TelemetryActions.publishToContainer)
|
||||||
.withAdditionalProperties({ dockerBaseImage: dockerImageNameForTelemetry })
|
.withAdditionalProperties({ dockerBaseImage: dockerImageNameForTelemetry })
|
||||||
.send();
|
.send();
|
||||||
|
|
||||||
if (deployProfile && deployProfile.deploySettings) {
|
if (deployProfile && deployProfile.sqlProjectPublishSettings) {
|
||||||
let connectionUri: string | undefined;
|
let connectionUri: string | undefined;
|
||||||
if (deployProfile.localDbSetting) {
|
if (deployProfile.dockerSettings) {
|
||||||
void utils.showInfoMessageWithOutputChannel(constants.publishingProjectMessage, this._outputChannel);
|
void utils.showInfoMessageWithOutputChannel(constants.publishingProjectMessage, this._outputChannel);
|
||||||
connectionUri = await this.deployService.deployToContainer(deployProfile, project);
|
connectionUri = await this.deployService.deployToContainer(deployProfile, project);
|
||||||
if (connectionUri) {
|
if (connectionUri) {
|
||||||
deployProfile.deploySettings.connectionUri = connectionUri;
|
deployProfile.sqlProjectPublishSettings.connectionUri = connectionUri;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deployProfile.deploySettings.connectionUri) {
|
if (deployProfile.sqlProjectPublishSettings.connectionUri) {
|
||||||
const publishResult = await this.publishOrScriptProject(project, deployProfile.deploySettings, true);
|
const publishResult = await this.publishOrScriptProject(project, deployProfile.sqlProjectPublishSettings, true);
|
||||||
if (publishResult && publishResult.success) {
|
if (publishResult && publishResult.success) {
|
||||||
if (deployProfile.localDbSetting) {
|
if (deployProfile.dockerSettings) {
|
||||||
await this.connectionService.getConnection(deployProfile.localDbSetting, true, deployProfile.localDbSetting.dbName);
|
await this.connectionService.getConnection(deployProfile.dockerSettings, true, deployProfile.dockerSettings.dbName);
|
||||||
}
|
}
|
||||||
void vscode.window.showInformationMessage(constants.publishProjectSucceed);
|
void vscode.window.showInformationMessage(constants.publishProjectSucceed);
|
||||||
} else {
|
} else {
|
||||||
@@ -400,7 +400,7 @@ export class ProjectsController {
|
|||||||
|
|
||||||
if (publishTarget === constants.PublishTargetType.docker) {
|
if (publishTarget === constants.PublishTargetType.docker) {
|
||||||
const deployProfile = await getPublishToDockerSettings(project);
|
const deployProfile = await getPublishToDockerSettings(project);
|
||||||
if (deployProfile?.deploySettings && deployProfile?.localDbSetting) {
|
if (deployProfile?.sqlProjectPublishSettings && deployProfile?.dockerSettings) {
|
||||||
await this.publishToDockerContainer(project, deployProfile);
|
await this.publishToDockerContainer(project, deployProfile);
|
||||||
}
|
}
|
||||||
} else if (publishTarget === constants.PublishTargetType.newAzureServer) {
|
} else if (publishTarget === constants.PublishTargetType.newAzureServer) {
|
||||||
@@ -414,7 +414,7 @@ export class ProjectsController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
let settings: IDeploySettings | undefined = await getPublishDatabaseSettings(project);
|
let settings: ISqlProjectPublishSettings | undefined = await getPublishDatabaseSettings(project);
|
||||||
|
|
||||||
if (settings) {
|
if (settings) {
|
||||||
// 5. Select action to take
|
// 5. Select action to take
|
||||||
@@ -436,7 +436,7 @@ export class ProjectsController {
|
|||||||
* @param publish Whether to publish the deployment or just generate a script
|
* @param publish Whether to publish the deployment or just generate a script
|
||||||
* @returns The DacFx result of the deployment
|
* @returns The DacFx result of the deployment
|
||||||
*/
|
*/
|
||||||
public async publishOrScriptProject(project: Project, settings: IDeploySettings, publish: boolean): Promise<mssql.DacFxResult | undefined> {
|
public async publishOrScriptProject(project: Project, settings: ISqlProjectPublishSettings, publish: boolean): Promise<mssql.DacFxResult | undefined> {
|
||||||
const telemetryProps: Record<string, string> = {};
|
const telemetryProps: Record<string, string> = {};
|
||||||
const telemetryMeasures: Record<string, number> = {};
|
const telemetryMeasures: Record<string, number> = {};
|
||||||
const buildStartTime = new Date().getTime();
|
const buildStartTime = new Date().getTime();
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import * as path from 'path';
|
|||||||
import * as fse from 'fs-extra';
|
import * as fse from 'fs-extra';
|
||||||
import { AzureSqlClient } from '../models/deploy/azureSqlClient';
|
import { AzureSqlClient } from '../models/deploy/azureSqlClient';
|
||||||
import { IAccount } from 'vscode-mssql';
|
import { IAccount } from 'vscode-mssql';
|
||||||
import { IDeploySettings, ILocalDbSetting, IPublishToDockerSettings, ISqlProject } from 'sqldbproj';
|
import { ISqlProjectPublishSettings, IDockerSettings, IPublishToDockerSettings, ISqlProject } from 'sqldbproj';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create flow for Deploying a database using only VS Code-native APIs such as QuickPick
|
* Create flow for Deploying a database using only VS Code-native APIs such as QuickPick
|
||||||
@@ -252,7 +252,7 @@ export async function launchCreateAzureServerQuickPick(project: Project, azureSq
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
let settings: IDeploySettings | undefined = await getPublishDatabaseSettings(project, false);
|
let settings: ISqlProjectPublishSettings | undefined = await getPublishDatabaseSettings(project, false);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
// TODO add tenant
|
// TODO add tenant
|
||||||
@@ -278,7 +278,7 @@ export async function launchCreateAzureServerQuickPick(project: Project, azureSq
|
|||||||
export async function getPublishToDockerSettings(project: ISqlProject): Promise<IPublishToDockerSettings | undefined> {
|
export async function getPublishToDockerSettings(project: ISqlProject): Promise<IPublishToDockerSettings | undefined> {
|
||||||
const target = project.getProjectTargetVersion();
|
const target = project.getProjectTargetVersion();
|
||||||
const name = uiUtils.getPublishServerName(target);
|
const name = uiUtils.getPublishServerName(target);
|
||||||
let localDbSetting: ILocalDbSetting | undefined;
|
let localDbSetting: IDockerSettings | undefined;
|
||||||
// Deploy to docker selected
|
// Deploy to docker selected
|
||||||
let portNumber = await vscode.window.showInputBox({
|
let portNumber = await vscode.window.showInputBox({
|
||||||
title: constants.enterPortNumber(name),
|
title: constants.enterPortNumber(name),
|
||||||
@@ -394,7 +394,7 @@ export async function getPublishToDockerSettings(project: ISqlProject): Promise<
|
|||||||
localDbSetting.dbName = deploySettings.databaseName;
|
localDbSetting.dbName = deploySettings.databaseName;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
localDbSetting: localDbSetting,
|
dockerSettings: localDbSetting,
|
||||||
deploySettings: deploySettings,
|
sqlProjectPublishSettings: deploySettings,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import { getAgreementDisplayText, getConnectionName, getDockerBaseImages, getPub
|
|||||||
import { TelemetryActions, TelemetryReporter, TelemetryViews } from '../common/telemetry';
|
import { TelemetryActions, TelemetryReporter, TelemetryViews } from '../common/telemetry';
|
||||||
import { Deferred } from '../common/promise';
|
import { Deferred } from '../common/promise';
|
||||||
import { PublishOptionsDialog } from './publishOptionsDialog';
|
import { PublishOptionsDialog } from './publishOptionsDialog';
|
||||||
import { IDeploySettings, IPublishToDockerSettings } from 'sqldbproj';
|
import { ISqlProjectPublishSettings, IPublishToDockerSettings } from 'sqldbproj';
|
||||||
|
|
||||||
interface DataSourceDropdownValue extends azdataType.CategoryValue {
|
interface DataSourceDropdownValue extends azdataType.CategoryValue {
|
||||||
dataSource: SqlConnectionDataSource;
|
dataSource: SqlConnectionDataSource;
|
||||||
@@ -63,9 +63,9 @@ export class PublishDatabaseDialog {
|
|||||||
|
|
||||||
private toDispose: vscode.Disposable[] = [];
|
private toDispose: vscode.Disposable[] = [];
|
||||||
|
|
||||||
public publish: ((proj: Project, profile: IDeploySettings) => any) | undefined;
|
public publish: ((proj: Project, profile: ISqlProjectPublishSettings) => any) | undefined;
|
||||||
public publishToContainer: ((proj: Project, profile: IPublishToDockerSettings) => any) | undefined;
|
public publishToContainer: ((proj: Project, profile: IPublishToDockerSettings) => any) | undefined;
|
||||||
public generateScript: ((proj: Project, profile: IDeploySettings) => any) | undefined;
|
public generateScript: ((proj: Project, profile: ISqlProjectPublishSettings) => any) | undefined;
|
||||||
public readPublishProfile: ((profileUri: vscode.Uri) => any) | undefined;
|
public readPublishProfile: ((profileUri: vscode.Uri) => any) | undefined;
|
||||||
|
|
||||||
constructor(private project: Project) {
|
constructor(private project: Project) {
|
||||||
@@ -224,7 +224,7 @@ export class PublishDatabaseDialog {
|
|||||||
|
|
||||||
public async publishClick(): Promise<void> {
|
public async publishClick(): Promise<void> {
|
||||||
if (this.existingServerSelected) {
|
if (this.existingServerSelected) {
|
||||||
const settings: IDeploySettings = {
|
const settings: ISqlProjectPublishSettings = {
|
||||||
databaseName: this.targetDatabaseName,
|
databaseName: this.targetDatabaseName,
|
||||||
serverName: this.getServerName(),
|
serverName: this.getServerName(),
|
||||||
connectionUri: await this.getConnectionUri(),
|
connectionUri: await this.getConnectionUri(),
|
||||||
@@ -240,7 +240,7 @@ export class PublishDatabaseDialog {
|
|||||||
const baseImages = getDockerBaseImages(this.project.getProjectTargetVersion());
|
const baseImages = getDockerBaseImages(this.project.getProjectTargetVersion());
|
||||||
const imageInfo = baseImages.find(x => x.name === dockerBaseImage);
|
const imageInfo = baseImages.find(x => x.name === dockerBaseImage);
|
||||||
const settings: IPublishToDockerSettings = {
|
const settings: IPublishToDockerSettings = {
|
||||||
localDbSetting: {
|
dockerSettings: {
|
||||||
dbName: this.targetDatabaseName,
|
dbName: this.targetDatabaseName,
|
||||||
dockerBaseImage: dockerBaseImage,
|
dockerBaseImage: dockerBaseImage,
|
||||||
dockerBaseImageEula: imageInfo?.agreementInfo?.link?.url || '',
|
dockerBaseImageEula: imageInfo?.agreementInfo?.link?.url || '',
|
||||||
@@ -249,7 +249,7 @@ export class PublishDatabaseDialog {
|
|||||||
serverName: constants.defaultLocalServerName,
|
serverName: constants.defaultLocalServerName,
|
||||||
userName: constants.defaultLocalServerAdminName
|
userName: constants.defaultLocalServerAdminName
|
||||||
},
|
},
|
||||||
deploySettings: {
|
sqlProjectPublishSettings: {
|
||||||
databaseName: this.targetDatabaseName,
|
databaseName: this.targetDatabaseName,
|
||||||
serverName: constants.defaultLocalServerName,
|
serverName: constants.defaultLocalServerName,
|
||||||
connectionUri: '',
|
connectionUri: '',
|
||||||
@@ -270,7 +270,7 @@ export class PublishDatabaseDialog {
|
|||||||
TelemetryReporter.sendActionEvent(TelemetryViews.SqlProjectPublishDialog, TelemetryActions.generateScriptClicked);
|
TelemetryReporter.sendActionEvent(TelemetryViews.SqlProjectPublishDialog, TelemetryActions.generateScriptClicked);
|
||||||
|
|
||||||
const sqlCmdVars = this.getSqlCmdVariablesForPublish();
|
const sqlCmdVars = this.getSqlCmdVariablesForPublish();
|
||||||
const settings: IDeploySettings = {
|
const settings: ISqlProjectPublishSettings = {
|
||||||
databaseName: this.targetDatabaseName,
|
databaseName: this.targetDatabaseName,
|
||||||
serverName: this.getServerName(),
|
serverName: this.getServerName(),
|
||||||
connectionUri: await this.getConnectionUri(),
|
connectionUri: await this.getConnectionUri(),
|
||||||
|
|||||||
@@ -11,12 +11,12 @@ import { promptForPublishProfile } from './publishDatabaseDialog';
|
|||||||
import { getDefaultPublishDeploymentOptions, getVscodeMssqlApi } from '../common/utils';
|
import { getDefaultPublishDeploymentOptions, getVscodeMssqlApi } from '../common/utils';
|
||||||
import { IConnectionInfo, IFireWallRuleError } from 'vscode-mssql';
|
import { IConnectionInfo, IFireWallRuleError } from 'vscode-mssql';
|
||||||
import { getPublishServerName } from './utils';
|
import { getPublishServerName } from './utils';
|
||||||
import { IDeploySettings, ISqlProject, SqlTargetPlatform } from 'sqldbproj';
|
import { ISqlProjectPublishSettings, ISqlProject, SqlTargetPlatform } from 'sqldbproj';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create flow for Publishing a database using only VS Code-native APIs such as QuickPick
|
* Create flow for Publishing a database using only VS Code-native APIs such as QuickPick
|
||||||
*/
|
*/
|
||||||
export async function getPublishDatabaseSettings(project: ISqlProject, promptForConnection: boolean = true): Promise<IDeploySettings | undefined> {
|
export async function getPublishDatabaseSettings(project: ISqlProject, promptForConnection: boolean = true): Promise<ISqlProjectPublishSettings | undefined> {
|
||||||
|
|
||||||
// 1. Select publish settings file (optional)
|
// 1. Select publish settings file (optional)
|
||||||
// Create custom quickpick so we can control stuff like displaying the loading indicator
|
// Create custom quickpick so we can control stuff like displaying the loading indicator
|
||||||
@@ -207,7 +207,7 @@ export async function getPublishDatabaseSettings(project: ISqlProject, promptFor
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 6. Generate script/publish
|
// 6. Generate script/publish
|
||||||
let settings: IDeploySettings = {
|
let settings: ISqlProjectPublishSettings = {
|
||||||
databaseName: databaseName,
|
databaseName: databaseName,
|
||||||
serverName: connectionProfile?.server || '',
|
serverName: connectionProfile?.server || '',
|
||||||
connectionUri: connectionUri || '',
|
connectionUri: connectionUri || '',
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import type * as azdataType from 'azdata';
|
import type * as azdataType from 'azdata';
|
||||||
import { IDeploySettings, ISqlConnectionProperties } from 'sqldbproj';
|
import { ISqlProjectPublishSettings, ISqlConnectionProperties } from 'sqldbproj';
|
||||||
import { IAzureAccountSession } from 'vscode-mssql';
|
import { IAzureAccountSession } from 'vscode-mssql';
|
||||||
|
|
||||||
export enum AppSettingType {
|
export enum AppSettingType {
|
||||||
@@ -14,7 +14,7 @@ export enum AppSettingType {
|
|||||||
|
|
||||||
export interface ISqlDbDeployProfile {
|
export interface ISqlDbDeployProfile {
|
||||||
sqlDbSetting?: ISqlDbSetting;
|
sqlDbSetting?: ISqlDbSetting;
|
||||||
deploySettings?: IDeploySettings;
|
deploySettings?: ISqlProjectPublishSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IDeployAppIntegrationProfile {
|
export interface IDeployAppIntegrationProfile {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import * as vscode from 'vscode';
|
|||||||
import { ShellExecutionHelper } from '../../tools/shellExecutionHelper';
|
import { ShellExecutionHelper } from '../../tools/shellExecutionHelper';
|
||||||
import { AzureSqlClient } from './azureSqlClient';
|
import { AzureSqlClient } from './azureSqlClient';
|
||||||
import { ConnectionService } from '../connections/connectionService';
|
import { ConnectionService } from '../connections/connectionService';
|
||||||
import { ILocalDbSetting, IPublishToDockerSettings } from 'sqldbproj';
|
import { IDockerSettings, IPublishToDockerSettings } from 'sqldbproj';
|
||||||
|
|
||||||
interface DockerImageSpec {
|
interface DockerImageSpec {
|
||||||
label: string;
|
label: string;
|
||||||
@@ -92,22 +92,22 @@ export class DeployService {
|
|||||||
|
|
||||||
public async deployToContainer(profile: IPublishToDockerSettings, project: Project): Promise<string | undefined> {
|
public async deployToContainer(profile: IPublishToDockerSettings, project: Project): Promise<string | undefined> {
|
||||||
return await this.executeTask(constants.deployDbTaskName, async () => {
|
return await this.executeTask(constants.deployDbTaskName, async () => {
|
||||||
if (!profile.localDbSetting) {
|
if (!profile.dockerSettings) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.verifyDocker();
|
await this.verifyDocker();
|
||||||
this.logToOutput(constants.dockerImageMessage);
|
this.logToOutput(constants.dockerImageMessage);
|
||||||
this.logToOutput(profile.localDbSetting.dockerBaseImage);
|
this.logToOutput(profile.dockerSettings.dockerBaseImage);
|
||||||
|
|
||||||
this.logToOutput(constants.dockerImageEulaMessage);
|
this.logToOutput(constants.dockerImageEulaMessage);
|
||||||
this.logToOutput(profile.localDbSetting.dockerBaseImageEula);
|
this.logToOutput(profile.dockerSettings.dockerBaseImageEula);
|
||||||
|
|
||||||
const imageSpec = this.getDockerImageSpec(project.projectFileName, profile.localDbSetting.dockerBaseImage);
|
const imageSpec = this.getDockerImageSpec(project.projectFileName, profile.dockerSettings.dockerBaseImage);
|
||||||
|
|
||||||
// If profile name is not set use the docker name to have a unique name
|
// If profile name is not set use the docker name to have a unique name
|
||||||
if (!profile.localDbSetting.profileName) {
|
if (!profile.dockerSettings.profileName) {
|
||||||
profile.localDbSetting.profileName = imageSpec.containerName;
|
profile.dockerSettings.profileName = imageSpec.containerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logToOutput(constants.cleaningDockerImagesMessage);
|
this.logToOutput(constants.cleaningDockerImagesMessage);
|
||||||
@@ -128,7 +128,7 @@ export class DeployService {
|
|||||||
this.logToOutput(constants.runningDockerMessage);
|
this.logToOutput(constants.runningDockerMessage);
|
||||||
// Building the image and running the docker
|
// Building the image and running the docker
|
||||||
//
|
//
|
||||||
const createdDockerId: string | undefined = await this.runDockerContainer(imageSpec, profile.localDbSetting);
|
const createdDockerId: string | undefined = await this.runDockerContainer(imageSpec, profile.dockerSettings);
|
||||||
this.logToOutput(`Docker container created. Id: ${createdDockerId}`);
|
this.logToOutput(`Docker container created. Id: ${createdDockerId}`);
|
||||||
|
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ export class DeployService {
|
|||||||
|
|
||||||
if (runningDockerId) {
|
if (runningDockerId) {
|
||||||
this.logToOutput(constants.dockerContainerCreatedMessage(runningDockerId));
|
this.logToOutput(constants.dockerContainerCreatedMessage(runningDockerId));
|
||||||
return await this._connectionService.getConnection(profile.localDbSetting, false, 'master');
|
return await this._connectionService.getConnection(profile.dockerSettings, false, 'master');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.logToOutput(constants.dockerContainerFailedToRunErrorMessage);
|
this.logToOutput(constants.dockerContainerFailedToRunErrorMessage);
|
||||||
@@ -159,7 +159,7 @@ export class DeployService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private async runDockerContainer(dockerImageSpec: DockerImageSpec, profile: ILocalDbSetting): Promise<string | undefined> {
|
private async runDockerContainer(dockerImageSpec: DockerImageSpec, profile: IDockerSettings): Promise<string | undefined> {
|
||||||
|
|
||||||
// Sensitive data to remove from output console
|
// Sensitive data to remove from output console
|
||||||
const sensitiveData = [profile.password];
|
const sensitiveData = [profile.password];
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ export class SqlDatabaseProjectProvider implements dataworkspace.IProjectProvide
|
|||||||
* Gets the project tree data provider
|
* Gets the project tree data provider
|
||||||
* @param projectFilePath The project file Uri
|
* @param projectFilePath The project file Uri
|
||||||
*/
|
*/
|
||||||
async getProjectTreeDataProvider(projectFilePath: vscode.Uri): Promise<vscode.TreeDataProvider<BaseProjectTreeItem>> {
|
public async getProjectTreeDataProvider(projectFilePath: vscode.Uri): Promise<vscode.TreeDataProvider<BaseProjectTreeItem>> {
|
||||||
const provider = new SqlDatabaseProjectTreeViewProvider();
|
const provider = new SqlDatabaseProjectTreeViewProvider();
|
||||||
const project = await Project.openProject(projectFilePath.fsPath);
|
const project = await Project.openProject(projectFilePath.fsPath);
|
||||||
provider.load([project]);
|
provider.load([project]);
|
||||||
@@ -35,7 +35,7 @@ export class SqlDatabaseProjectProvider implements dataworkspace.IProjectProvide
|
|||||||
/**
|
/**
|
||||||
* Gets the supported project types
|
* Gets the supported project types
|
||||||
*/
|
*/
|
||||||
get supportedProjectTypes(): dataworkspace.IProjectType[] {
|
public get supportedProjectTypes(): dataworkspace.IProjectType[] {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
id: constants.emptyAzureDbSqlDatabaseProjectTypeId,
|
id: constants.emptyAzureDbSqlDatabaseProjectTypeId,
|
||||||
@@ -80,7 +80,7 @@ export class SqlDatabaseProjectProvider implements dataworkspace.IProjectProvide
|
|||||||
* @param sdkStyle whether project is sdk-style. Default is false
|
* @param sdkStyle whether project is sdk-style. Default is false
|
||||||
* @returns Uri of the newly created project file
|
* @returns Uri of the newly created project file
|
||||||
*/
|
*/
|
||||||
async createProject(name: string, location: vscode.Uri, projectTypeId: string, targetPlatform?: sqldbproj.SqlTargetPlatform, sdkStyle: boolean = false): Promise<vscode.Uri> {
|
public async createProject(name: string, location: vscode.Uri, projectTypeId: string, targetPlatform?: sqldbproj.SqlTargetPlatform, sdkStyle: boolean = false): Promise<vscode.Uri> {
|
||||||
|
|
||||||
if (!targetPlatform) {
|
if (!targetPlatform) {
|
||||||
const projectType = this.supportedProjectTypes.find(x => x.id === projectTypeId);
|
const projectType = this.supportedProjectTypes.find(x => x.id === projectTypeId);
|
||||||
@@ -102,7 +102,7 @@ export class SqlDatabaseProjectProvider implements dataworkspace.IProjectProvide
|
|||||||
/**
|
/**
|
||||||
* Opens and loads a .sqlproj file
|
* Opens and loads a .sqlproj file
|
||||||
*/
|
*/
|
||||||
openProject(projectFilePath: string): Promise<sqldbproj.ISqlProject> {
|
public openProject(projectFilePath: string): Promise<sqldbproj.ISqlProject> {
|
||||||
return Project.openProject(projectFilePath);
|
return Project.openProject(projectFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ export class SqlDatabaseProjectProvider implements dataworkspace.IProjectProvide
|
|||||||
/**
|
/**
|
||||||
* Gets the project actions to be placed on the dashboard toolbar
|
* Gets the project actions to be placed on the dashboard toolbar
|
||||||
*/
|
*/
|
||||||
get projectToolbarActions(): (dataworkspace.IProjectAction | dataworkspace.IProjectActionGroup)[] {
|
public get projectToolbarActions(): (dataworkspace.IProjectAction | dataworkspace.IProjectActionGroup)[] {
|
||||||
const addItemAction: dataworkspace.IProjectAction = {
|
const addItemAction: dataworkspace.IProjectAction = {
|
||||||
id: constants.addItemAction,
|
id: constants.addItemAction,
|
||||||
icon: IconPathHelper.add,
|
icon: IconPathHelper.add,
|
||||||
@@ -152,7 +152,7 @@ export class SqlDatabaseProjectProvider implements dataworkspace.IProjectProvide
|
|||||||
/**
|
/**
|
||||||
* Gets the data to be displayed in the project dashboard
|
* Gets the data to be displayed in the project dashboard
|
||||||
*/
|
*/
|
||||||
getDashboardComponents(projectFile: string): dataworkspace.IDashboardTable[] {
|
public getDashboardComponents(projectFile: string): dataworkspace.IDashboardTable[] {
|
||||||
const width = 200;
|
const width = 200;
|
||||||
const publishInfo: dataworkspace.IDashboardTable = {
|
const publishInfo: dataworkspace.IDashboardTable = {
|
||||||
name: constants.PublishHistory,
|
name: constants.PublishHistory,
|
||||||
@@ -177,11 +177,11 @@ export class SqlDatabaseProjectProvider implements dataworkspace.IProjectProvide
|
|||||||
return [publishInfo, buildInfo];
|
return [publishInfo, buildInfo];
|
||||||
}
|
}
|
||||||
|
|
||||||
get image(): ThemedIconPath {
|
public get image(): ThemedIconPath {
|
||||||
return IconPathHelper.dashboardSqlProj;
|
return IconPathHelper.dashboardSqlProj;
|
||||||
}
|
}
|
||||||
|
|
||||||
async openSqlNewProjectDialog(allowedTargetPlatforms?: sqldbproj.SqlTargetPlatform[]): Promise<vscode.Uri | undefined> {
|
public openSqlNewProjectDialog(allowedTargetPlatforms?: sqldbproj.SqlTargetPlatform[]): Promise<vscode.Uri | undefined> {
|
||||||
let targetPlatforms = Array.from(constants.targetPlatformToVersion.keys());
|
let targetPlatforms = Array.from(constants.targetPlatformToVersion.keys());
|
||||||
if (allowedTargetPlatforms) {
|
if (allowedTargetPlatforms) {
|
||||||
targetPlatforms = targetPlatforms.filter(p => allowedTargetPlatforms.toString().includes(p));
|
targetPlatforms = targetPlatforms.filter(p => allowedTargetPlatforms.toString().includes(p));
|
||||||
@@ -205,22 +205,22 @@ export class SqlDatabaseProjectProvider implements dataworkspace.IProjectProvide
|
|||||||
* Gets the list of .sql scripts contained in a project
|
* Gets the list of .sql scripts contained in a project
|
||||||
* @param projectFilePath
|
* @param projectFilePath
|
||||||
*/
|
*/
|
||||||
async getProjectScriptFiles(projectFilePath: string): Promise<string[]> {
|
public getProjectScriptFiles(projectFilePath: string): Promise<string[]> {
|
||||||
return await this.projectController.getProjectScriptFiles(projectFilePath);
|
return this.projectController.getProjectScriptFiles(projectFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Database Schema Provider version for a SQL project
|
* Gets the Database Schema Provider version for a SQL project
|
||||||
*/
|
*/
|
||||||
public async getProjectDatabaseSchemaProvider(projectFilePath: string): Promise<string> {
|
public getProjectDatabaseSchemaProvider(projectFilePath: string): Promise<string> {
|
||||||
return await this.projectController.getProjectDatabaseSchemaProvider(projectFilePath);
|
return this.projectController.getProjectDatabaseSchemaProvider(projectFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async generateProjectFromOpenApiSpec(options?: sqldbproj.GenerateProjectFromOpenApiSpecOptions): Promise<sqldbproj.ISqlProject | undefined> {
|
public generateProjectFromOpenApiSpec(options?: sqldbproj.GenerateProjectFromOpenApiSpecOptions): Promise<sqldbproj.ISqlProject | undefined> {
|
||||||
return await this.projectController.generateProjectFromOpenApiSpec(options);
|
return this.projectController.generateProjectFromOpenApiSpec(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
getPublishToDockerSettings(project: sqldbproj.ISqlProject): Promise<sqldbproj.IPublishToDockerSettings | undefined> {
|
public getPublishToDockerSettings(project: sqldbproj.ISqlProject): Promise<sqldbproj.IPublishToDockerSettings | undefined> {
|
||||||
return getPublishToDockerSettings(project);
|
return getPublishToDockerSettings(project);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -304,19 +304,28 @@ declare module 'sqldbproj' {
|
|||||||
connectionRetryTimeout?: number
|
connectionRetryTimeout?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ILocalDbSetting extends ISqlConnectionProperties {
|
/**
|
||||||
|
* Settings for creating the docker container a project is being published to
|
||||||
|
*/
|
||||||
|
export interface IDockerSettings extends ISqlConnectionProperties {
|
||||||
dockerBaseImage: string,
|
dockerBaseImage: string,
|
||||||
dockerBaseImageEula: string,
|
dockerBaseImageEula: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Settings for publishing a SQL Project to a docker container
|
||||||
|
*/
|
||||||
export interface IPublishToDockerSettings {
|
export interface IPublishToDockerSettings {
|
||||||
localDbSetting?: ILocalDbSetting;
|
dockerSettings?: IDockerSettings;
|
||||||
deploySettings?: IDeploySettings;
|
sqlProjectPublishSettings?: ISqlProjectPublishSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type DeploymentOptions = mssqlDeploymentOptions | vscodeMssqlDeploymentOptions;
|
export type DeploymentOptions = mssqlDeploymentOptions | vscodeMssqlDeploymentOptions;
|
||||||
|
|
||||||
export interface IDeploySettings {
|
/**
|
||||||
|
* Settings to use when publishing a SQL Project
|
||||||
|
*/
|
||||||
|
export interface ISqlProjectPublishSettings {
|
||||||
databaseName: string;
|
databaseName: string;
|
||||||
serverName: string;
|
serverName: string;
|
||||||
connectionUri: string;
|
connectionUri: string;
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ describe('deploy service', function (): void {
|
|||||||
it('Should deploy a database to docker container successfully', async function (): Promise<void> {
|
it('Should deploy a database to docker container successfully', async function (): Promise<void> {
|
||||||
const testContext = createContext();
|
const testContext = createContext();
|
||||||
const deployProfile: IPublishToDockerSettings = {
|
const deployProfile: IPublishToDockerSettings = {
|
||||||
localDbSetting: {
|
dockerSettings: {
|
||||||
dbName: 'test',
|
dbName: 'test',
|
||||||
password: 'PLACEHOLDER',
|
password: 'PLACEHOLDER',
|
||||||
port: 1433,
|
port: 1433,
|
||||||
@@ -102,7 +102,7 @@ describe('deploy service', function (): void {
|
|||||||
it('Should fail the deploy if docker is not running', async function (): Promise<void> {
|
it('Should fail the deploy if docker is not running', async function (): Promise<void> {
|
||||||
const testContext = createContext();
|
const testContext = createContext();
|
||||||
const deployProfile: IPublishToDockerSettings = {
|
const deployProfile: IPublishToDockerSettings = {
|
||||||
localDbSetting: {
|
dockerSettings: {
|
||||||
dbName: 'test',
|
dbName: 'test',
|
||||||
password: 'PLACEHOLDER',
|
password: 'PLACEHOLDER',
|
||||||
port: 1433,
|
port: 1433,
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import { Project } from '../../models/project';
|
|||||||
import { ProjectsController } from '../../controllers/projectController';
|
import { ProjectsController } from '../../controllers/projectController';
|
||||||
import { emptySqlDatabaseProjectTypeId } from '../../common/constants';
|
import { emptySqlDatabaseProjectTypeId } from '../../common/constants';
|
||||||
import { createContext, mockDacFxOptionsResult, TestContext } from '../testContext';
|
import { createContext, mockDacFxOptionsResult, TestContext } from '../testContext';
|
||||||
import { IDeploySettings, IPublishToDockerSettings } from 'sqldbproj';
|
import { ISqlProjectPublishSettings, IPublishToDockerSettings } from 'sqldbproj';
|
||||||
|
|
||||||
let testContext: TestContext;
|
let testContext: TestContext;
|
||||||
describe('Publish Database Dialog', () => {
|
describe('Publish Database Dialog', () => {
|
||||||
@@ -75,9 +75,9 @@ describe('Publish Database Dialog', () => {
|
|||||||
dialog.object.publishToExistingServer = true;
|
dialog.object.publishToExistingServer = true;
|
||||||
dialog.callBase = true;
|
dialog.callBase = true;
|
||||||
|
|
||||||
let profile: IDeploySettings | undefined;
|
let profile: ISqlProjectPublishSettings | undefined;
|
||||||
|
|
||||||
const expectedPublish: IDeploySettings = {
|
const expectedPublish: ISqlProjectPublishSettings = {
|
||||||
databaseName: 'MockDatabaseName',
|
databaseName: 'MockDatabaseName',
|
||||||
serverName: 'MockServer',
|
serverName: 'MockServer',
|
||||||
connectionUri: 'Mock|Connection|Uri',
|
connectionUri: 'Mock|Connection|Uri',
|
||||||
@@ -94,7 +94,7 @@ describe('Publish Database Dialog', () => {
|
|||||||
|
|
||||||
should(profile).deepEqual(expectedPublish);
|
should(profile).deepEqual(expectedPublish);
|
||||||
|
|
||||||
const expectedGenScript: IDeploySettings = {
|
const expectedGenScript: ISqlProjectPublishSettings = {
|
||||||
databaseName: 'MockDatabaseName',
|
databaseName: 'MockDatabaseName',
|
||||||
serverName: 'MockServer',
|
serverName: 'MockServer',
|
||||||
connectionUri: 'Mock|Connection|Uri',
|
connectionUri: 'Mock|Connection|Uri',
|
||||||
@@ -112,7 +112,7 @@ describe('Publish Database Dialog', () => {
|
|||||||
should(profile).deepEqual(expectedGenScript);
|
should(profile).deepEqual(expectedGenScript);
|
||||||
|
|
||||||
const expectedContainerPublishProfile: IPublishToDockerSettings = {
|
const expectedContainerPublishProfile: IPublishToDockerSettings = {
|
||||||
localDbSetting: {
|
dockerSettings: {
|
||||||
dbName: 'MockDatabaseName',
|
dbName: 'MockDatabaseName',
|
||||||
dockerBaseImage: '',
|
dockerBaseImage: '',
|
||||||
password: '',
|
password: '',
|
||||||
@@ -122,7 +122,7 @@ describe('Publish Database Dialog', () => {
|
|||||||
dockerBaseImageEula: ''
|
dockerBaseImageEula: ''
|
||||||
|
|
||||||
},
|
},
|
||||||
deploySettings: {
|
sqlProjectPublishSettings: {
|
||||||
databaseName: 'MockDatabaseName',
|
databaseName: 'MockDatabaseName',
|
||||||
serverName: 'localhost',
|
serverName: 'localhost',
|
||||||
connectionUri: '',
|
connectionUri: '',
|
||||||
|
|||||||
Reference in New Issue
Block a user