Adding azure resource provider for mysql flexible server (#20529)

This commit is contained in:
rishky-msft
2022-09-07 22:24:18 +05:30
committed by GitHub
parent cbd3cccf68
commit 5c620264c4
8 changed files with 179 additions and 3 deletions

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 25.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="16px" height="16px" viewBox="0 0 16 16" style="enable-background:new 0 0 16 16;" xml:space="preserve">
<style type="text/css">
.st0{fill:#F6F6F6;fill-opacity:0;}
.st1{fill:#424242;}
.st2{fill:#FFFFFF;}
</style>
<path id="canvas" class="st0" d="M16,16H0V0h16V16z"/>
<path id="outline" class="st1" d="M15,3.2v9.6c0,1.9-2.6,2.9-5.4,3.2H7.2C4.3,15.8,1,14.7,1,12.8V3.2c0-1.9,2.7-3,5.6-3.2h2.3
C11.7,0.2,15,1.3,15,3.2z"/>
<path id="iconBg" class="st2" d="M7.8,1C4.6,1,2,2,2,3.2v9.6C2,14,5.3,15,8.4,15s5.6-1,5.6-2.2V3.2C14,2.1,10.9,1,7.8,1z M8,11H7
V7.7l-1.2,2.7c-0.1,0.2-0.3,0.2-0.4,0.2s-0.1-0.1-0.2-0.2L4,7.7V11H3V6h1l1.2,2.1c0.1,0.1,0.3,0.2,0.4,0.1l0.1-0.1L7,6h1V11z
M7.9,4.2C5.7,4.2,4,3.7,4,3.1S5.8,2,7.9,2c2.2,0,3.9,0.5,3.9,1.1S10.1,4.2,7.9,4.2z M13,12.5c0,0.3-0.2,0.5-0.5,0.5H9v-1h3v-1H9.5
C9.2,11,9,10.8,9,10.5V8h1v2h2V8h1V12.5z"/>
<g id="iconFg">
<path class="st1" d="M8,6v5H7V7.7l-1.2,2.7c-0.1,0.2-0.3,0.2-0.4,0.2s-0.1-0.1-0.2-0.2L4,7.7V11H3V6h1l1.2,2.1
c0.1,0.1,0.3,0.2,0.4,0.1l0.1-0.1L7,6H8z M12,8v2h-2V8H9v2.5C9,10.8,9.2,11,9.5,11H12v1H9v1h3.5c0.3,0,0.5-0.2,0.5-0.5V8H12z
M11.8,3.1C11.8,2.5,10,2,7.9,2C5.7,1.9,4,2.4,4,3.1s1.8,1.1,3.9,1.1C10.1,4.2,11.8,3.7,11.8,3.1z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><style>.icon-canvas-transparent{opacity:0;fill:#f6f6f6}.icon-vs-out{fill:#f6f6f6}.icon-vs-bg{fill:#424242}.icon-vs-fg{fill:#f0eff1}</style><path class="icon-canvas-transparent" d="M16 16H0V0h16v16z" id="canvas"/><path class="icon-vs-out" d="M15 3.25v9.595c0 1.852-2.583 2.925-5.445 3.155h-2.36C4.313 15.775 1 14.743 1 12.751V3.156C1 1.319 3.722.23 6.621 0h2.271C11.675.226 15 1.274 15 3.25z" id="outline"/><path class="icon-vs-bg" d="M7.777.952C4.637.952 2 2.031 2 3.156v9.595c0 1.219 3.289 2.297 6.383 2.297S14 14.017 14 12.845V3.249C14 2.077 10.918.952 7.777.952zM8 11H7V7.707l-1.217 2.672a.31.31 0 0 1-.566 0L4 7.707V11H3V6h1l1.231 2.128a.31.31 0 0 0 .538 0L7 6h1v5zm-.095-6.814c-2.172 0-3.932-.503-3.932-1.124 0-.62 1.761-1.124 3.932-1.124 2.172 0 3.932.503 3.932 1.124 0 .621-1.76 1.124-3.932 1.124zM13 12.471a.53.53 0 0 1-.529.529H9v-1h3v-1H9.529A.53.53 0 0 1 9 10.471V8h1v2h2V8h1v4.471z" id="iconBg"/><g id="iconFg"><path class="icon-vs-fg" d="M8 6v5H7V7.707l-1.217 2.672a.31.31 0 0 1-.566 0L4 7.707V11H3V6h1l1.231 2.128a.31.31 0 0 0 .538 0L7 6h1zm4 2v2h-2V8H9v2.471a.53.53 0 0 0 .529.529H12v1H9v1h3.471a.53.53 0 0 0 .529-.529V8h-1zm-.163-4.938c0-.62-1.761-1.124-3.932-1.124-2.172 0-3.932.503-3.932 1.124 0 .621 1.761 1.124 3.932 1.124 2.172 0 3.932-.503 3.932-1.124z"/></g></svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -0,0 +1,26 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ExtensionContext } from 'vscode';
import { azureResource } from 'azurecore';
import { IAzureResourceService } from '../../interfaces';
import { MysqlFlexibleServerTreeDataProvider } from './mysqlFlexibleServerTreeDataProvider';
export class MysqlFlexibleServerProvider implements azureResource.IAzureResourceProvider {
public constructor(
private _databaseServerService: IAzureResourceService<azureResource.AzureResourceDatabaseServer>,
private _extensionContext: ExtensionContext
) {
}
public getTreeDataProvider(): azureResource.IAzureResourceTreeDataProvider {
return new MysqlFlexibleServerTreeDataProvider(this._databaseServerService, this._extensionContext);
}
public get providerId(): string {
return 'azure.resource.providers.mysqlFlexibleServer';
}
}

View File

@@ -0,0 +1,41 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ResourceServiceBase, GraphData } from '../resourceTreeDataProviderBase';
import { azureResource } from 'azurecore';
interface DbServerGraphData extends GraphData {
properties: {
fullyQualifiedDomainName: string;
administratorLogin: string;
};
}
const serversQuery = `where type == "${azureResource.AzureResourceType.mysqlFlexibleServer}"`;
export class MysqlFlexibleServerService extends ResourceServiceBase<DbServerGraphData, azureResource.AzureResourceDatabaseServer> {
protected get query(): string {
return serversQuery;
}
protected convertResource(resource: DbServerGraphData): azureResource.AzureResourceDatabaseServer {
return {
id: resource.id,
name: resource.name,
fullName: resource.properties.fullyQualifiedDomainName,
loginName: resource.properties.administratorLogin,
defaultDatabaseName: '',
tenant: resource.tenantId,
subscription: {
id: resource.subscriptionId,
name: resource.subscriptionName
},
resourceGroup: resource.resourceGroup
};
}
}

View File

@@ -0,0 +1,81 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { TreeItemCollapsibleState, ExtensionContext } from 'vscode';
import * as nls from 'vscode-nls';
const localize = nls.loadMessageBundle();
import { AzureResourceItemType } from '../../constants';
import { generateGuid } from '../../utils';
import { IAzureResourceService } from '../../interfaces';
import { ResourceTreeDataProviderBase } from '../resourceTreeDataProviderBase';
import { azureResource } from 'azurecore';
import { Account, ExtensionNodeType, TreeItem } from 'azdata';
export class MysqlFlexibleServerTreeDataProvider extends ResourceTreeDataProviderBase<azureResource.AzureResourceDatabaseServer> {
private static readonly MYSQL_FLEXIBLE_SERVER_PROVIDER_ID = 'MySQL';
private static readonly CONTAINER_ID = 'azure.resource.providers.databaseServer.treeDataProvider.mysqlFlexibleServerContainer';
private static readonly CONTAINER_LABEL = localize('azure.resource.providers.databaseServer.treeDataProvider.mysqlFlexibleServerContainerLabel', "Azure Database for MySQL Flexible server");
public constructor(
databaseServerService: IAzureResourceService<azureResource.AzureResourceDatabaseServer>,
private _extensionContext: ExtensionContext
) {
super(databaseServerService);
}
protected getTreeItemForResource(databaseServer: azureResource.AzureResourceDatabaseServer, account: Account): TreeItem {
return {
id: `databaseServer_${databaseServer.id ? databaseServer.id : databaseServer.name}`,
label: this.browseConnectionMode ? `${databaseServer.name} (${MysqlFlexibleServerTreeDataProvider.CONTAINER_LABEL}, ${databaseServer.subscription.name})` : databaseServer.name,
iconPath: {
dark: this._extensionContext.asAbsolutePath('resources/dark/mysql_server_inverse.svg'),
light: this._extensionContext.asAbsolutePath('resources/light/mysql_server.svg')
},
collapsibleState: this.browseConnectionMode ? TreeItemCollapsibleState.None : TreeItemCollapsibleState.Collapsed,
contextValue: AzureResourceItemType.databaseServer,
payload: {
id: generateGuid(),
connectionName: undefined,
serverName: databaseServer.fullName,
databaseName: databaseServer.defaultDatabaseName,
userName: databaseServer.loginName,
password: '',
authenticationType: 'SqlLogin',
savePassword: true,
groupFullName: '',
groupId: '',
providerName: MysqlFlexibleServerTreeDataProvider.MYSQL_FLEXIBLE_SERVER_PROVIDER_ID,
saveProfile: false,
options: {
},
azureAccount: account.key.accountId,
azureTenantId: databaseServer.tenant,
azureResourceId: databaseServer.id,
azurePortalEndpoint: account.properties.providerSettings.settings.portalEndpoint
},
childProvider: MysqlFlexibleServerTreeDataProvider.MYSQL_FLEXIBLE_SERVER_PROVIDER_ID,
type: ExtensionNodeType.Server
};
}
protected createContainerNode(): azureResource.IAzureResourceNode {
return {
account: undefined,
subscription: undefined,
tenantId: undefined,
treeItem: {
id: MysqlFlexibleServerTreeDataProvider.CONTAINER_ID,
label: MysqlFlexibleServerTreeDataProvider.CONTAINER_LABEL,
iconPath: {
dark: this._extensionContext.asAbsolutePath('resources/dark/folder_inverse.svg'),
light: this._extensionContext.asAbsolutePath('resources/light/folder.svg')
},
collapsibleState: TreeItemCollapsibleState.Collapsed,
contextValue: AzureResourceItemType.databaseServerContainer
}
};
}
}

View File

@@ -347,7 +347,8 @@ declare module 'azurecore' {
azureArcService = 'microsoft.azuredata/datacontrollers', azureArcService = 'microsoft.azuredata/datacontrollers',
storageAccount = 'microsoft.storage/storageaccounts', storageAccount = 'microsoft.storage/storageaccounts',
logAnalytics = 'microsoft.operationalinsights/workspaces', logAnalytics = 'microsoft.operationalinsights/workspaces',
cosmosDbAccount = 'microsoft.documentdb/databaseaccounts' cosmosDbAccount = 'microsoft.documentdb/databaseaccounts',
mysqlFlexibleServer = 'microsoft.dbformysql/flexibleservers'
} }
export interface IAzureResourceProvider extends azdata.DataProvider { export interface IAzureResourceProvider extends azdata.DataProvider {

View File

@@ -39,6 +39,8 @@ import { PostgresServerArcProvider } from './azureResource/providers/postgresArc
import { PostgresServerArcService } from './azureResource/providers/postgresArcServer/postgresServerService'; import { PostgresServerArcService } from './azureResource/providers/postgresArcServer/postgresServerService';
import { CosmosDbMongoProvider } from './azureResource/providers/cosmosdb/mongo/cosmosDbMongoProvider'; import { CosmosDbMongoProvider } from './azureResource/providers/cosmosdb/mongo/cosmosDbMongoProvider';
import { CosmosDbMongoService } from './azureResource/providers/cosmosdb/mongo/cosmosDbMongoService'; import { CosmosDbMongoService } from './azureResource/providers/cosmosdb/mongo/cosmosDbMongoService';
import { MysqlFlexibleServerProvider } from './azureResource/providers/mysqlFlexibleServer/mysqlFlexibleServerProvider';
import { MysqlFlexibleServerService } from './azureResource/providers/mysqlFlexibleServer/mysqlFlexibleServerService';
import * as azurecore from 'azurecore'; import * as azurecore from 'azurecore';
import * as azureResourceUtils from './azureResource/utils'; import * as azureResourceUtils from './azureResource/utils';
import * as utils from './utils'; import * as utils from './utils';
@@ -136,7 +138,8 @@ export async function activate(context: vscode.ExtensionContext): Promise<azurec
new AzureResourceDatabaseProvider(new AzureResourceDatabaseService(), extensionContext), new AzureResourceDatabaseProvider(new AzureResourceDatabaseService(), extensionContext),
new SqlInstanceProvider(new SqlInstanceResourceService(), extensionContext), new SqlInstanceProvider(new SqlInstanceResourceService(), extensionContext),
new PostgresServerProvider(new PostgresServerService(), extensionContext), new PostgresServerProvider(new PostgresServerService(), extensionContext),
new CosmosDbMongoProvider(new CosmosDbMongoService(), extensionContext) new CosmosDbMongoProvider(new CosmosDbMongoService(), extensionContext),
new MysqlFlexibleServerProvider(new MysqlFlexibleServerService(), extensionContext)
]; ];
if (arcFeaturedEnabled) { if (arcFeaturedEnabled) {
providers.push( providers.push(

View File

@@ -28,7 +28,8 @@ export const ConnectionProviderAndExtensionMap = new Map<string, string>([
['PGSQL', 'microsoft.azuredatastudio-postgresql'], ['PGSQL', 'microsoft.azuredatastudio-postgresql'],
['KUSTO', 'microsoft.kusto'], ['KUSTO', 'microsoft.kusto'],
['LOGANALYTICS', 'microsoft.azuremonitor'], ['LOGANALYTICS', 'microsoft.azuremonitor'],
['COSMOSDB_MONGO', 'microsoft.azure-cosmosdb-ads-extension'] ['COSMOSDB_MONGO', 'microsoft.azure-cosmosdb-ads-extension'],
['MySQL', 'microsoft.azuredatastudio-mysql']
]); ]);
/** /**