mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-04 09:35:38 -05:00
Canye/fix refresh (#19424)
* Bump version of arc and azcli to 1.3.0 * Fixed refresh to do dc config show and endpoint list first, then check the connectionmode * Await calls to refresh indirect and direct * Made sql mi-arc delete also handle direct mode. Made customlocation for sql mi create work again, regex problem. Co-authored-by: Candice Ye <canye@microsoft.com>
This commit is contained in:
@@ -64,20 +64,20 @@ export class ControllerModel {
|
||||
if (node) {
|
||||
this.treeDataProvider.refreshNode(node);
|
||||
} else {
|
||||
await this.refresh(false, this.info.resourceGroup, this.info.namespace);
|
||||
await this.refresh(false, this.info.namespace);
|
||||
}
|
||||
}
|
||||
|
||||
public async refresh(showErrors: boolean = true, resourceGroup: string, namespace: string): Promise<void> {
|
||||
if (this.info.connectionMode === ConnectionMode.direct) {
|
||||
this.refreshDirectMode(showErrors, resourceGroup, namespace);
|
||||
public async refresh(showErrors: boolean = true, namespace: string): Promise<void> {
|
||||
await this.refreshController(showErrors, namespace);
|
||||
if (this._controllerConfig?.spec.settings.azure.connectionMode === ConnectionMode.direct) {
|
||||
await this.refreshDirectMode(this._controllerConfig?.spec.settings.azure.resourceGroup, namespace);
|
||||
} else {
|
||||
this.refreshIndirectMode(showErrors, namespace);
|
||||
await this.refreshIndirectMode(namespace);
|
||||
}
|
||||
}
|
||||
|
||||
public async refreshDirectMode(showErrors: boolean = true, resourceGroup: string, namespace: string): Promise<void> {
|
||||
const newRegistrations: Registration[] = [];
|
||||
public async refreshController(showErrors: boolean = true, namespace: string): Promise<void> {
|
||||
await Promise.all([
|
||||
this._azApi.az.arcdata.dc.config.show(namespace, this.azAdditionalEnvVars).then(result => {
|
||||
this._controllerConfig = result.stdout;
|
||||
@@ -106,92 +106,66 @@ export class ControllerModel {
|
||||
}
|
||||
this._onEndpointsUpdated.fire(this._endpoints);
|
||||
throw err;
|
||||
}),
|
||||
Promise.all([
|
||||
this._azApi.az.postgres.arcserver.list(namespace, this.azAdditionalEnvVars).then(result => {
|
||||
newRegistrations.push(...result.stdout.map(r => {
|
||||
return {
|
||||
instanceName: r.name,
|
||||
state: r.state,
|
||||
instanceType: ResourceType.postgresInstances
|
||||
};
|
||||
}));
|
||||
}),
|
||||
this._azApi.az.sql.miarc.list({ resourceGroup: resourceGroup, namespace: undefined }, this.azAdditionalEnvVars).then(result => {
|
||||
newRegistrations.push(...result.stdout.map(r => {
|
||||
return {
|
||||
instanceName: r.name,
|
||||
state: r.state,
|
||||
instanceType: ResourceType.sqlManagedInstances
|
||||
};
|
||||
}));
|
||||
|
||||
})
|
||||
]).then(() => {
|
||||
this._registrations = newRegistrations;
|
||||
this.registrationsLastUpdated = new Date();
|
||||
this._onRegistrationsUpdated.fire(this._registrations);
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
||||
public async refreshIndirectMode(showErrors: boolean = true, namespace: string): Promise<void> {
|
||||
public async refreshDirectMode(resourceGroup: string, namespace: string): Promise<void> {
|
||||
const newRegistrations: Registration[] = [];
|
||||
await Promise.all([
|
||||
this._azApi.az.arcdata.dc.config.show(namespace, this.azAdditionalEnvVars).then(result => {
|
||||
this._controllerConfig = result.stdout;
|
||||
this.configLastUpdated = new Date();
|
||||
this._onConfigUpdated.fire(this._controllerConfig);
|
||||
}).catch(err => {
|
||||
// If an error occurs show a message so the user knows something failed but still
|
||||
// fire the event so callers hooking into this can handle the error (e.g. so dashboards don't show the
|
||||
// loading icon forever)
|
||||
if (showErrors) {
|
||||
vscode.window.showErrorMessage(loc.fetchConfigFailed(this.info.name, err));
|
||||
}
|
||||
this._onConfigUpdated.fire(this._controllerConfig);
|
||||
throw err;
|
||||
this._azApi.az.postgres.arcserver.list(namespace, this.azAdditionalEnvVars).then(result => {
|
||||
newRegistrations.push(...result.stdout.map(r => {
|
||||
return {
|
||||
instanceName: r.name,
|
||||
state: r.state,
|
||||
instanceType: ResourceType.postgresInstances
|
||||
};
|
||||
}));
|
||||
}),
|
||||
this._azApi.az.arcdata.dc.endpoint.list(namespace, this.azAdditionalEnvVars).then(result => {
|
||||
this._endpoints = result.stdout;
|
||||
this.endpointsLastUpdated = new Date();
|
||||
this._onEndpointsUpdated.fire(this._endpoints);
|
||||
}).catch(err => {
|
||||
// If an error occurs show a message so the user knows something failed but still
|
||||
// fire the event so callers can know to update (e.g. so dashboards don't show the
|
||||
// loading icon forever)
|
||||
if (showErrors) {
|
||||
vscode.window.showErrorMessage(loc.fetchEndpointsFailed(this.info.name, err));
|
||||
}
|
||||
this._onEndpointsUpdated.fire(this._endpoints);
|
||||
throw err;
|
||||
}),
|
||||
Promise.all([
|
||||
this._azApi.az.postgres.arcserver.list(namespace, this.azAdditionalEnvVars).then(result => {
|
||||
newRegistrations.push(...result.stdout.map(r => {
|
||||
return {
|
||||
instanceName: r.name,
|
||||
state: r.state,
|
||||
instanceType: ResourceType.postgresInstances
|
||||
};
|
||||
}));
|
||||
}),
|
||||
this._azApi.az.sql.miarc.list({ resourceGroup: undefined, namespace: namespace }, this.azAdditionalEnvVars).then(result => {
|
||||
newRegistrations.push(...result.stdout.map(r => {
|
||||
return {
|
||||
instanceName: r.name,
|
||||
state: r.state,
|
||||
instanceType: ResourceType.sqlManagedInstances
|
||||
};
|
||||
}));
|
||||
this._azApi.az.sql.miarc.list({ resourceGroup: resourceGroup, namespace: undefined }, this.azAdditionalEnvVars).then(result => {
|
||||
newRegistrations.push(...result.stdout.map(r => {
|
||||
return {
|
||||
instanceName: r.name,
|
||||
state: r.state,
|
||||
instanceType: ResourceType.sqlManagedInstances
|
||||
};
|
||||
}));
|
||||
|
||||
})
|
||||
]).then(() => {
|
||||
this._registrations = newRegistrations;
|
||||
this.registrationsLastUpdated = new Date();
|
||||
this._onRegistrationsUpdated.fire(this._registrations);
|
||||
})
|
||||
]);
|
||||
]).then(() => {
|
||||
this._registrations = newRegistrations;
|
||||
this.registrationsLastUpdated = new Date();
|
||||
this._onRegistrationsUpdated.fire(this._registrations);
|
||||
});
|
||||
}
|
||||
|
||||
public async refreshIndirectMode(namespace: string): Promise<void> {
|
||||
const newRegistrations: Registration[] = [];
|
||||
await Promise.all([
|
||||
this._azApi.az.postgres.arcserver.list(namespace, this.azAdditionalEnvVars).then(result => {
|
||||
newRegistrations.push(...result.stdout.map(r => {
|
||||
return {
|
||||
instanceName: r.name,
|
||||
state: r.state,
|
||||
instanceType: ResourceType.postgresInstances
|
||||
};
|
||||
}));
|
||||
}),
|
||||
this._azApi.az.sql.miarc.list({ resourceGroup: undefined, namespace: namespace }, this.azAdditionalEnvVars).then(result => {
|
||||
newRegistrations.push(...result.stdout.map(r => {
|
||||
return {
|
||||
instanceName: r.name,
|
||||
state: r.state,
|
||||
instanceType: ResourceType.sqlManagedInstances
|
||||
};
|
||||
}));
|
||||
|
||||
})
|
||||
]).then(() => {
|
||||
this._registrations = newRegistrations;
|
||||
this.registrationsLastUpdated = new Date();
|
||||
this._onRegistrationsUpdated.fire(this._registrations);
|
||||
});
|
||||
}
|
||||
|
||||
public get endpoints(): azExt.DcEndpointListResult[] {
|
||||
|
||||
Reference in New Issue
Block a user