mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Activate extensions contributing deployment providers (#14750)
This commit is contained in:
@@ -1016,6 +1016,11 @@
|
|||||||
"when": "mi-type=arc-mi"
|
"when": "mi-type=arc-mi"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"resourceDeploymentOptionsSources": [
|
||||||
|
{
|
||||||
|
"id": "arc.controllers"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -107,7 +107,12 @@
|
|||||||
"when": "azdata.found"
|
"when": "azdata.found"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
},
|
||||||
|
"resourceDeploymentOptionsSources": [
|
||||||
|
{
|
||||||
|
"id": "arc.controller.config.profiles"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"request": "^2.88.2",
|
"request": "^2.88.2",
|
||||||
|
|||||||
@@ -317,6 +317,11 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"resourceDeploymentValueProviders": [
|
||||||
|
{
|
||||||
|
"id": "subscription-id-to-tenant-id"
|
||||||
|
}
|
||||||
|
],
|
||||||
"hasAzureResourceProviders": true
|
"hasAzureResourceProviders": true
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -7,8 +7,13 @@ import * as vscode from 'vscode';
|
|||||||
import * as rd from 'resource-deployment';
|
import * as rd from 'resource-deployment';
|
||||||
import * as loc from '../localizedConstants';
|
import * as loc from '../localizedConstants';
|
||||||
|
|
||||||
|
interface OptionsSourceContribution {
|
||||||
|
id: string;
|
||||||
|
}
|
||||||
|
|
||||||
class OptionsSourcesService {
|
class OptionsSourcesService {
|
||||||
private _optionsSourceStore = new Map<string, rd.IOptionsSourceProvider>();
|
private _optionsSourceStore = new Map<string, rd.IOptionsSourceProvider>();
|
||||||
|
|
||||||
registerOptionsSourceProvider(provider: rd.IOptionsSourceProvider): vscode.Disposable {
|
registerOptionsSourceProvider(provider: rd.IOptionsSourceProvider): vscode.Disposable {
|
||||||
if (this._optionsSourceStore.has(provider.id)) {
|
if (this._optionsSourceStore.has(provider.id)) {
|
||||||
throw new Error(loc.optionsSourceAlreadyDefined(provider.id));
|
throw new Error(loc.optionsSourceAlreadyDefined(provider.id));
|
||||||
@@ -23,12 +28,23 @@ class OptionsSourcesService {
|
|||||||
this._optionsSourceStore.delete(providerId);
|
this._optionsSourceStore.delete(providerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
getOptionsSource(optionsSourceProviderId: string): rd.IOptionsSourceProvider {
|
async getOptionsSource(optionsSourceProviderId: string): Promise<rd.IOptionsSourceProvider> {
|
||||||
const optionsSource = this._optionsSourceStore.get(optionsSourceProviderId);
|
let optionsSource = this._optionsSourceStore.get(optionsSourceProviderId);
|
||||||
if (optionsSource === undefined) {
|
if (optionsSource === undefined) {
|
||||||
throw new Error(loc.noOptionsSourceDefined(optionsSourceProviderId));
|
// We don't have the provider registered yet so try to find and activate the extension that contributes it
|
||||||
|
const ext = vscode.extensions.all.find(extension => {
|
||||||
|
return !!(extension.packageJSON.contributes?.resourceDeploymentOptionsSources as OptionsSourceContribution[])?.find(optionsSource => optionsSource.id === optionsSourceProviderId);
|
||||||
|
});
|
||||||
|
if (ext) {
|
||||||
|
await ext.activate();
|
||||||
|
}
|
||||||
|
optionsSource = this._optionsSourceStore.get(optionsSourceProviderId);
|
||||||
|
// Still don't have it registered - is the extension not properly registering it?
|
||||||
|
if (optionsSource === undefined) {
|
||||||
|
throw new Error(loc.noOptionsSourceDefined(optionsSourceProviderId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return optionsSource;
|
return optionsSource!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ import * as vscode from 'vscode';
|
|||||||
import * as rd from 'resource-deployment';
|
import * as rd from 'resource-deployment';
|
||||||
import * as loc from '../localizedConstants';
|
import * as loc from '../localizedConstants';
|
||||||
|
|
||||||
|
interface ValueProviderContribution {
|
||||||
|
id: string;
|
||||||
|
}
|
||||||
|
|
||||||
class ValueProviderService {
|
class ValueProviderService {
|
||||||
private _valueProviderStore = new Map<string, rd.IValueProvider>();
|
private _valueProviderStore = new Map<string, rd.IValueProvider>();
|
||||||
registerValueProvider(provider: rd.IValueProvider): vscode.Disposable {
|
registerValueProvider(provider: rd.IValueProvider): vscode.Disposable {
|
||||||
@@ -23,10 +27,21 @@ class ValueProviderService {
|
|||||||
this._valueProviderStore.delete(providerId);
|
this._valueProviderStore.delete(providerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
getValueProvider(providerId: string): rd.IValueProvider {
|
async getValueProvider(providerId: string): Promise<rd.IValueProvider> {
|
||||||
const valueProvider = this._valueProviderStore.get(providerId);
|
let valueProvider = this._valueProviderStore.get(providerId);
|
||||||
if (valueProvider === undefined) {
|
if (valueProvider === undefined) {
|
||||||
throw new Error(loc.noValueProviderDefined(providerId));
|
// We don't have the provider registered yet so try to find and activate the extension that contributes it
|
||||||
|
const ext = vscode.extensions.all.find(extension => {
|
||||||
|
return !!(extension.packageJSON.contributes?.resourceDeploymentValueProviders as ValueProviderContribution[])?.find(valueProvider => valueProvider.id === providerId);
|
||||||
|
});
|
||||||
|
if (ext) {
|
||||||
|
await ext.activate();
|
||||||
|
}
|
||||||
|
valueProvider = this._valueProviderStore.get(providerId);
|
||||||
|
// Still don't have it registered - is the extension not properly registering it?
|
||||||
|
if (valueProvider === undefined) {
|
||||||
|
throw new Error(loc.noValueProviderDefined(providerId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return valueProvider;
|
return valueProvider;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -422,7 +422,7 @@ async function hookUpValueProviders(context: WizardPageContext): Promise<void> {
|
|||||||
console.error(`Could not find target component ${field.valueProvider.triggerField} when hooking up value providers for ${field.label}`);
|
console.error(`Could not find target component ${field.valueProvider.triggerField} when hooking up value providers for ${field.label}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const provider = valueProviderService.getValueProvider(field.valueProvider.providerId);
|
const provider = await valueProviderService.getValueProvider(field.valueProvider.providerId);
|
||||||
const updateFields = async () => {
|
const updateFields = async () => {
|
||||||
const targetComponentValue = await targetComponent.getValue();
|
const targetComponentValue = await targetComponent.getValue();
|
||||||
const newFieldValue = await provider.getValue(targetComponentValue?.toString() ?? '');
|
const newFieldValue = await provider.getValue(targetComponentValue?.toString() ?? '');
|
||||||
@@ -619,7 +619,7 @@ async function processOptionsTypeField(context: FieldContext): Promise<void> {
|
|||||||
throwUnless('optionsType' in context.fieldInfo.options, loc.optionsTypeNotFound);
|
throwUnless('optionsType' in context.fieldInfo.options, loc.optionsTypeNotFound);
|
||||||
if (context.fieldInfo.options.source?.providerId) {
|
if (context.fieldInfo.options.source?.providerId) {
|
||||||
try {
|
try {
|
||||||
context.fieldInfo.options.source.provider = optionsSourcesService.getOptionsSource(context.fieldInfo.options.source.providerId);
|
context.fieldInfo.options.source.provider = await optionsSourcesService.getOptionsSource(context.fieldInfo.options.source.providerId);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
disableControlButtons(context.container);
|
disableControlButtons(context.container);
|
||||||
|
|||||||
Reference in New Issue
Block a user