Add Arc MIAA delete action back (#11901)

* Add Arc MIAA delete action back

* fix
This commit is contained in:
Charles Gagnon
2020-08-21 14:10:29 -07:00
committed by GitHub
parent b4d61a067e
commit a6efd56844
14 changed files with 259 additions and 253 deletions

View File

@@ -3,13 +3,13 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { AzdataOutput } from 'azdata-ext';
import * as os from 'os';
import * as vscode from 'vscode';
import { HttpClient } from './common/httpClient';
import * as loc from './localizedConstants';
import { executeCommand, executeSudoCommand, ExitCodeError } from './common/childProcess';
import { searchForCmd } from './common/utils';
import { AzdataOutput } from './typings/azdata-ext';
export const azdataHostname = 'https://aka.ms';
export const azdataUri = 'azdata-msi';

View File

@@ -3,13 +3,13 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as azdata from './typings/azdata-ext';
import * as azdataExt from 'azdata-ext';
import * as vscode from 'vscode';
import { findAzdata, IAzdataTool } from './azdata';
let localAzdata: IAzdataTool | undefined = undefined;
export async function activate(): Promise<azdata.IExtension> {
export async function activate(): Promise<azdataExt.IExtension> {
const outputChannel = vscode.window.createOutputChannel('azdata');
localAzdata = await checkForAzdata(outputChannel);
return {
@@ -40,6 +40,9 @@ export async function activate(): Promise<azdata.IExtension> {
},
sql: {
mi: {
delete: async (name: string) => {
return executeLocalAzdataCommand(['arc', 'sql', 'mi', 'delete', '-n', name]);
},
list: async () => {
return executeLocalAzdataCommand(['arc', 'sql', 'mi', 'list']);
},
@@ -51,7 +54,7 @@ export async function activate(): Promise<azdata.IExtension> {
};
}
async function executeLocalAzdataCommand<R>(args: string[], additionalEnvVars?: { [key: string]: string }): Promise<azdata.AzdataOutput<R>> {
async function executeLocalAzdataCommand<R>(args: string[], additionalEnvVars?: { [key: string]: string }): Promise<azdataExt.AzdataOutput<R>> {
if (!localAzdata) {
throw new Error('No azdata');
}

View File

@@ -3,221 +3,218 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
/**
* Covers defining what the azdata extension exports to other extensions
*
* IMPORTANT: THIS IS NOT A HARD DEFINITION unlike vscode; therefore no enums or classes should be defined here
* (const enums get evaluated when typescript -> javascript so those are fine)
*/
export const enum extension {
name = 'Microsoft.azdata'
}
declare module 'azdata-ext' {
/**
* Covers defining what the azdata extension exports to other extensions
*
* IMPORTANT: THIS IS NOT A HARD DEFINITION unlike vscode; therefore no enums or classes should be defined here
* (const enums get evaluated when typescript -> javascript so those are fine)
*/
export const enum extension {
name = 'Microsoft.azdata'
}
export interface DcEndpointListResult {
description: string,
endpoint: string,
name: string,
protocol: string
}
export interface DcEndpointListResult {
description: string, // "Management Proxy"
endpoint: string, // "https://10.91.86.39:30777"
name: string, // "mgmtproxy"
protocol: string // "https"
}
export interface SqlMiListResult {
name: string,
replicas: string,
serverEndpoint: string,
state: string
}
export interface SqlMiListResult {
name: string, // "arc-miaa"
replicas: string, // "1/1"
serverEndpoint: string,
state: string // "Ready"
}
export interface PostgresServerListResult {
name: string,
state: string,
workers: number
}
export interface PostgresServerListResult {
name: string, // "arc-pg"
state: string, // "Ready"
workers: number // 1
}
export interface DcConfigShowResult {
apiVersion: string,
kind: string,
metadata: {
creationTimestamp: string,
generation: number,
name: string,
namespace: string,
resourceVersion: string,
selfLink: string,
uid: string
},
spec: {
credentials: {
controllerAdmin: string,
dockerRegistry: string,
serviceAccount: string
export interface DcConfigShowResult {
apiVersion: string, // "arcdata.microsoft.com/v1alpha1"
kind: string, // "DataController"
metadata: {
creationTimestamp: string, // "2020-08-19T17:05:39Z"
generation: number, // /1
name: string, // "arc"
namespace: string, // "arc"
resourceVersion: string, // "200369"
selfLink: string, // "/apis/arcdata.microsoft.com/v1alpha1/namespaces/arc/datacontrollers/arc"
uid: string// "da72ed34-ee51-4bf0-b5c9-b0753834c5c1"
},
docker: {
imagePullPolicy: string,
imageTag: string,
registry: string,
repository: string
},
security: {
allowDumps: string,
allowNodeMetricsCollection: boolean,
allowPodMetricsCollection: boolean,
allowRunAsRoot: false
},
services: [
{
name: string,
port: number,
serviceType: string
},
{
name: string,
port: number,
serviceType: string
}
],
settings: {
spec: {
credentials: {
controllerAdmin: string, // "controller-login-secret"
dockerRegistry: string, // "mssql-private-registry"
serviceAccount: string, // "sa-mssql-controller"
},
docker: {
imagePullPolicy: string, // "Always"
imageTag: string, // "15.0.2000.41811_5"
registry: string, // "hlsaris.azurecr.io"
repository: string // "aris-p-master-dsmain-standard"
},
security: {
allowDumps: boolean, // true,
allowNodeMetricsCollection: boolean // true
allowPodMetricsCollection: boolean, // true
allowRunAsRoot: boolean // false
},
services: {
name: string, // "controller"
port: number, // 30080
serviceType: string // "NodePort"
}[],
settings: {
ElasticSearch: {
'vm.max_map_count': string
'vm.max_map_count': string // "-1"
},
controller: {
enableBilling: string,
'logs.rotation.days': string,
'logs.rotation.size': string
'enableBilling': string, // "True"
'logs.rotation.days': string, // "7"
'logs.rotation.size': string, // "5000"
}
},
storage: {
},
storage: {
data: {
accessMode: string,
className: string,
size: string
accessMode: string, // "ReadWriteOnce"
className: string, // "local-storage"
size: string, // "15Gi"
},
logs: {
accessMode: string,
className: string,
size: string
accessMode: string, // "ReadWriteOnce"
className: string, // "local-storage"
size: string, // "10Gi"
}
}
},
status: {
state: string
}
}
export interface SqlMiShowResult {
apiVersion: string, // "sql.arcdata.microsoft.com/v1alpha1"
kind: string, // "sqlmanagedinstance"
metadata: {
creationTimestamp: string, // "2020-08-19T17:35:45Z"
generation: number, // 1
name: string, // "miaa-instance"
namespace: string, // "arc"
resourceVersion: string, // "202623"
selfLink: string, // "/apis/sql.arcdata.microsoft.com/v1alpha1/namespaces/arc/sqlmanagedinstances/miaa-instance"
uid: string // "cea737aa-3f82-4f6a-9bed-2b51c2c33dff"
},
spec: {
storage: {
data: {
className: string, // "local-storage"
size: string // "5Gi"
},
logs: {
className: string, // "local-storage"
size: string // "5Gi"
}
}
},
status: {
readyReplicas: string, // "1/1"
state: string // "Ready"
}
}
export interface PostgresServerShowResult {
apiVersion: string, // "arcdata.microsoft.com/v1alpha1"
kind: string, // "postgresql-12"
metadata: {
creationTimestamp: string, // "2020-08-19T20:25:11Z"
generation: number, // 1
name: string, // "chgagnon-pg"
namespace: string, // "arc",
resourceVersion: string, // "214944",
selfLink: string, // "/apis/arcdata.microsoft.com/v1alpha1/namespaces/arc/postgresql-12s/chgagnon-pg",
uid: string, // "26d0f5bb-0c0b-4225-a6b5-5be2bf6feac0"
},
spec: {
backups: {
deltaMinutes: number, // 3,
fullMinutes: number, // 10,
tiers: [
{
retention: {
maximums: string[], // [ "6", "512MB" ],
minimums: string[], // [ "3" ]
},
storage: {
volumeSize: string, // "1Gi"
}
}
]
}
},
scale: {
shards: number // 1
status: {
state: string, // "Ready"
}
}
export interface SqlMiShowResult {
apiVersion: string, // "sql.arcdata.microsoft.com/v1alpha1"
kind: string, // "sqlmanagedinstance"
metadata: {
creationTimestamp: string, // "2020-08-19T17:35:45Z"
generation: number, // 1
name: string, // "miaa-instance"
namespace: string, // "arc"
resourceVersion: string, // "202623"
selfLink: string, // "/apis/sql.arcdata.microsoft.com/v1alpha1/namespaces/arc/sqlmanagedinstances/miaa-instance"
uid: string // "cea737aa-3f82-4f6a-9bed-2b51c2c33dff"
},
scheduling: {
default: {
resources: {
requests: {
memory: string, // "256Mi"
}
spec: {
storage: {
data: {
className: string, // "local-storage"
size: string // "5Gi"
},
logs: {
className: string, // "local-storage"
size: string // "5Gi"
}
}
},
storage: {
data: {
className: string, // "local-storage",
size: string // "5Gi"
status: {
readyReplicas: string, // "1/1"
state: string // "Ready"
}
}
export interface PostgresServerShowResult {
apiVersion: string, // "arcdata.microsoft.com/v1alpha1"
kind: string, // "postgresql-12"
metadata: {
creationTimestamp: string, // "2020-08-19T20:25:11Z"
generation: number, // 1
name: string, // "chgagnon-pg"
namespace: string, // "arc",
resourceVersion: string, // "214944",
selfLink: string, // "/apis/arcdata.microsoft.com/v1alpha1/namespaces/arc/postgresql-12s/chgagnon-pg",
uid: string, // "26d0f5bb-0c0b-4225-a6b5-5be2bf6feac0"
},
spec: {
backups: {
deltaMinutes: number, // 3,
fullMinutes: number, // 10,
tiers: [
{
retention: {
maximums: string[], // [ "6", "512MB" ],
minimums: string[], // [ "3" ]
},
storage: {
volumeSize: string, // "1Gi"
}
}
]
},
logs: {
className: string, // "local-storage",
size: string // "5Gi"
scale: {
shards: number // 1
},
scheduling: {
default: {
resources: {
requests: {
memory: string, // "256Mi"
}
}
}
},
storage: {
data: {
className: string, // "local-storage",
size: string // "5Gi"
},
logs: {
className: string, // "local-storage",
size: string // "5Gi"
}
}
},
status: {
readyPods: string, // "1/1",
state: string // "Ready"
}
}
export interface AzdataOutput<R> {
logs: string[],
result: R,
stderr: string[],
stdout: string[],
code?: number
}
export interface IExtension {
dc: {
endpoint: {
list(): Promise<AzdataOutput<DcEndpointListResult[]>>
},
config: {
show(): Promise<AzdataOutput<DcConfigShowResult>>
}
},
login(endpoint: string, username: string, password: string): Promise<AzdataOutput<void>>,
postgres: {
server: {
list(): Promise<AzdataOutput<PostgresServerListResult[]>>,
show(name: string): Promise<AzdataOutput<PostgresServerShowResult>>
}
},
sql: {
mi: {
delete(name: string): Promise<AzdataOutput<void>>,
list(): Promise<AzdataOutput<SqlMiListResult[]>>,
show(name: string): Promise<AzdataOutput<SqlMiShowResult>>
}
}
},
status: {
readyPods: string, // "1/1",
state: string // "Ready"
}
}
export interface AzdataOutput<R> {
logs: string[],
result: R,
stderr: string[],
stdout: string[],
code?: number
}
export interface IExtension {
dc: {
endpoint: {
list(): Promise<AzdataOutput<DcEndpointListResult[]>>
},
config: {
show(): Promise<AzdataOutput<DcConfigShowResult>>
}
},
login(endpoint: string, username: string, password: string): Promise<AzdataOutput<any>>,
postgres: {
server: {
list(): Promise<AzdataOutput<PostgresServerListResult[]>>,
show(name: string): Promise<AzdataOutput<PostgresServerShowResult>>
}
},
sql: {
mi: {
list(): Promise<AzdataOutput<SqlMiListResult[]>>,
show(name: string): Promise<AzdataOutput<SqlMiShowResult>>
}
}
}