diff --git a/extensions/azurecore/package.json b/extensions/azurecore/package.json index decdb9937a..2a640f01a0 100644 --- a/extensions/azurecore/package.json +++ b/extensions/azurecore/package.json @@ -322,11 +322,6 @@ } ] }, - "resourceDeploymentValueProviders": [ - { - "id": "subscription-id-to-tenant-id" - } - ], "hasAzureResourceProviders": true }, "dependencies": { diff --git a/extensions/azurecore/src/extension.ts b/extensions/azurecore/src/extension.ts index a8cd482006..e07da2e472 100644 --- a/extensions/azurecore/src/extension.ts +++ b/extensions/azurecore/src/extension.ts @@ -8,7 +8,6 @@ import * as vscode from 'vscode'; import { promises as fs } from 'fs'; import * as path from 'path'; import * as os from 'os'; -import * as resourceDeployment from 'resource-deployment'; import { AppContext } from './appContext'; import { AzureAccountProviderService } from './account-provider/azureAccountProviderService'; @@ -115,40 +114,6 @@ export async function activate(context: vscode.ExtensionContext): Promise { - context.subscriptions.push(api.registerValueProvider({ - id: 'subscription-id-to-tenant-id', - getValue: async (triggerValue: string) => { - if (triggerValue === '') { - return ''; - } - let accounts: azurecore.AzureAccount[] = []; - try { - accounts = await azdata.accounts.getAllAccounts(); - } catch (err) { - console.warn(`Error fetching accounts for subscription-id-to-tenant-id provider : ${err}`); - return ''; - } - - for (const account of accounts) { - // Ignore any errors - they'll be logged in the called function and we still want to look - // at any subscriptions that are returned - worst case we'll just return an empty string if we didn't - // find the matching subscription - const subs = await azureResourceUtils.getSubscriptions(appContext, account, true); - const sub = subs.subscriptions.find(sub => sub.id === triggerValue); - if (sub) { - return sub.tenant; - } - - } - console.error(`Unable to find subscription with ID ${triggerValue} when mapping subscription ID to tenant ID`); - return ''; - } - })); - }).then(undefined, err => console.error('Error registering Azure ResourceDeployment value provider ', err)); - return { getSubscriptions(account?: azurecore.AzureAccount, ignoreErrors?: boolean, selectedOnly: boolean = false): Promise { return selectedOnly diff --git a/extensions/azurecore/src/typings/ref.d.ts b/extensions/azurecore/src/typings/ref.d.ts index a86808d402..558e12bbe2 100644 --- a/extensions/azurecore/src/typings/ref.d.ts +++ b/extensions/azurecore/src/typings/ref.d.ts @@ -7,5 +7,4 @@ /// /// /// -/// /// diff --git a/extensions/resource-deployment/src/typings/resource-deployment.d.ts b/extensions/resource-deployment/src/typings/resource-deployment.d.ts index 246df8da1b..0d3d48c582 100644 --- a/extensions/resource-deployment/src/typings/resource-deployment.d.ts +++ b/extensions/resource-deployment/src/typings/resource-deployment.d.ts @@ -27,12 +27,16 @@ declare module 'resource-deployment' { export type InputValueType = string | number | boolean | undefined; export interface IValueProvider { + /** + * The ID associated with this value provider. Fields use this ID in the package.json to indicate which provider to use to get the value for that field. + * Each ID must be globally unique - an error will be thrown if the same ID is already registered. + */ readonly id: string, /** * Gets a calculated value based on the given input values. * @param triggerValues A map of the trigger field names and their current values specified in the valueProvider field info */ - getValue(triggerValues: string | {[key: string]: InputValueType}): Promise; + getValue(triggerValues: {[key: string]: InputValueType}): Promise; } /** @@ -44,6 +48,12 @@ declare module 'resource-deployment' { export interface IExtension { registerOptionsSourceProvider(provider: IOptionsSourceProvider): vscode.Disposable, + /** + * Registers a value provider that resource deployment definitions can use to dynamically fetch the value for specified fields. + * @param provider The provider to register + * @returns A disposable is returned that will unregister the provider when is disposed - this should be used to ensure + * that the provider is unregistered when the extension is uninstalled/deactivated. + */ registerValueProvider(provider: IValueProvider): vscode.Disposable } }