mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
SQL MIAA list now accounts for new text output from Azure CLI (#20305)
* SQL MIAA list now accounts for new text output in line 1 * Version bump Co-authored-by: Candice Ye <canye@microsoft.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
"name": "arc",
|
"name": "arc",
|
||||||
"displayName": "%arc.displayName%",
|
"displayName": "%arc.displayName%",
|
||||||
"description": "%arc.description%",
|
"description": "%arc.description%",
|
||||||
"version": "1.5.0",
|
"version": "1.5.1",
|
||||||
"publisher": "Microsoft",
|
"publisher": "Microsoft",
|
||||||
"license": "https://raw.githubusercontent.com/Microsoft/azuredatastudio/main/LICENSE.txt",
|
"license": "https://raw.githubusercontent.com/Microsoft/azuredatastudio/main/LICENSE.txt",
|
||||||
"icon": "images/extension.png",
|
"icon": "images/extension.png",
|
||||||
|
|||||||
@@ -371,3 +371,15 @@ export function getTimeStamp(dateTime: string | undefined): number {
|
|||||||
export function checkISOTimeString(dateTime: string): boolean {
|
export function checkISOTimeString(dateTime: string): boolean {
|
||||||
return /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d.*Z/.test(dateTime);
|
return /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d.*Z/.test(dateTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses out the SQL MIAA list from the raw json output
|
||||||
|
* @param raw The raw version output from az sql mi-arc list
|
||||||
|
*/
|
||||||
|
export function parseMiaaList(raw: string): string | undefined {
|
||||||
|
// The output of az sql mi-arc list looks like:
|
||||||
|
// 'Found 1 Arc-enabled SQL Managed Instances in namespace testns1\r\n[\r\n {\r\n "name": "sqlinstance1",\r\n "primaryEndpoint": "20.236.10.81,1422",\r\n "replicas": "3/3",\r\n "state": "Ready"\r\n }\r\n]'
|
||||||
|
const lines = raw.split('\n');
|
||||||
|
lines.splice(0, 1);
|
||||||
|
return lines.join('\n');
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
import { ControllerInfo, ResourceType } from 'arc';
|
import { ControllerInfo, ResourceType } from 'arc';
|
||||||
import * as azExt from 'az-ext';
|
import * as azExt from 'az-ext';
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
|
import { parseMiaaList } from '../common/utils';
|
||||||
import * as loc from '../localizedConstants';
|
import * as loc from '../localizedConstants';
|
||||||
import { AzureArcTreeDataProvider } from '../ui/tree/azureArcTreeDataProvider';
|
import { AzureArcTreeDataProvider } from '../ui/tree/azureArcTreeDataProvider';
|
||||||
|
|
||||||
@@ -110,14 +111,15 @@ export class ControllerModel {
|
|||||||
}));
|
}));
|
||||||
}),
|
}),
|
||||||
this._azApi.az.sql.miarc.list({ resourceGroup: undefined, namespace: namespace }, this.azAdditionalEnvVars).then(result => {
|
this._azApi.az.sql.miarc.list({ resourceGroup: undefined, namespace: namespace }, this.azAdditionalEnvVars).then(result => {
|
||||||
newRegistrations.push(...result.stdout.map(r => {
|
let miaaList = parseMiaaList(result.stdout.toString());
|
||||||
|
let jsonList: azExt.SqlMiListResult[] = JSON.parse(<string>miaaList);
|
||||||
|
newRegistrations.push(...jsonList.map(r => {
|
||||||
return {
|
return {
|
||||||
instanceName: r.name,
|
instanceName: r.name,
|
||||||
state: r.state,
|
state: r.state,
|
||||||
instanceType: ResourceType.sqlManagedInstances
|
instanceType: ResourceType.sqlManagedInstances
|
||||||
};
|
};
|
||||||
}));
|
}));
|
||||||
|
|
||||||
})
|
})
|
||||||
]).then(() => {
|
]).then(() => {
|
||||||
this._registrations = newRegistrations;
|
this._registrations = newRegistrations;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"name": "azcli",
|
"name": "azcli",
|
||||||
"displayName": "%azcli.arc.displayName%",
|
"displayName": "%azcli.arc.displayName%",
|
||||||
"description": "%azcli.arc.description%",
|
"description": "%azcli.arc.description%",
|
||||||
"version": "1.5.0",
|
"version": "1.5.1",
|
||||||
"publisher": "Microsoft",
|
"publisher": "Microsoft",
|
||||||
"license": "https://raw.githubusercontent.com/Microsoft/azuredatastudio/main/LICENSE.txt",
|
"license": "https://raw.githubusercontent.com/Microsoft/azuredatastudio/main/LICENSE.txt",
|
||||||
"icon": "images/extension.png",
|
"icon": "images/extension.png",
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ export class AzTool implements azExt.IAzApi {
|
|||||||
// Additional arguments
|
// Additional arguments
|
||||||
},
|
},
|
||||||
additionalEnvVars?: azExt.AdditionalEnvVars
|
additionalEnvVars?: azExt.AdditionalEnvVars
|
||||||
): Promise<azExt.AzOutput<azExt.SqlMiListResult[]>> => {
|
): Promise<azExt.AzOutput<azExt.SqlMiListRawOutput>> => {
|
||||||
const argsArray = ['sql', 'mi-arc', 'list'];
|
const argsArray = ['sql', 'mi-arc', 'list'];
|
||||||
if (args.resourceGroup) {
|
if (args.resourceGroup) {
|
||||||
argsArray.push('--resource-group', args.resourceGroup);
|
argsArray.push('--resource-group', args.resourceGroup);
|
||||||
@@ -216,7 +216,8 @@ export class AzTool implements azExt.IAzApi {
|
|||||||
argsArray.push('--k8s-namespace', args.namespace);
|
argsArray.push('--k8s-namespace', args.namespace);
|
||||||
argsArray.push('--use-k8s');
|
argsArray.push('--use-k8s');
|
||||||
}
|
}
|
||||||
return this.executeCommand<azExt.SqlMiListResult[]>(argsArray, additionalEnvVars);
|
return this.executeCommand<azExt.SqlMiListRawOutput>(argsArray, additionalEnvVars);
|
||||||
|
|
||||||
},
|
},
|
||||||
show: (
|
show: (
|
||||||
name: string,
|
name: string,
|
||||||
|
|||||||
7
extensions/azcli/src/typings/az-ext.d.ts
vendored
7
extensions/azcli/src/typings/az-ext.d.ts
vendored
@@ -29,6 +29,11 @@ declare module 'az-ext' {
|
|||||||
protocol: string // "https"
|
protocol: string // "https"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface SqlMiListRawOutput {
|
||||||
|
text: string,
|
||||||
|
miaaList: SqlMiListResult[]
|
||||||
|
}
|
||||||
|
|
||||||
export interface SqlMiListResult {
|
export interface SqlMiListResult {
|
||||||
name: string, // "arc-miaa"
|
name: string, // "arc-miaa"
|
||||||
replicas: string, // "1/1"
|
replicas: string, // "1/1"
|
||||||
@@ -592,7 +597,7 @@ declare module 'az-ext' {
|
|||||||
},
|
},
|
||||||
// Additional arguments
|
// Additional arguments
|
||||||
additionalEnvVars?: AdditionalEnvVars
|
additionalEnvVars?: AdditionalEnvVars
|
||||||
): Promise<AzOutput<SqlMiListResult[]>>,
|
): Promise<AzOutput<SqlMiListRawOutput>>,
|
||||||
show(
|
show(
|
||||||
name: string,
|
name: string,
|
||||||
args: {
|
args: {
|
||||||
|
|||||||
Reference in New Issue
Block a user