Refactor push image to be a wizard, show ACR create pick (#4146)

This commit is contained in:
Brandon Waterloo [MSFT] 2023-11-07 11:22:31 -05:00 коммит произвёл GitHub
Родитель 0c33ed0670
Коммит 5372c56b45
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
13 изменённых файлов: 292 добавлений и 133 удалений

Просмотреть файл

@ -1,99 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IActionContext, NoResourceFoundError } from '@microsoft/vscode-azext-utils';
import { parseDockerLikeImageName } from '@microsoft/vscode-container-client';
import { CommonRegistry } from '@microsoft/vscode-docker-registries';
import * as vscode from 'vscode';
import { ext } from '../../extensionVariables';
import { TaskCommandRunnerFactory } from '../../runtimes/runners/TaskCommandRunnerFactory';
import { ImageTreeItem } from '../../tree/images/ImageTreeItem';
import { UnifiedRegistryItem } from '../../tree/registries/UnifiedRegistryTreeDataProvider';
import { registryExperience } from '../../utils/registryExperience';
import { addImageTaggingTelemetry, tagImage } from './tagImage';
export async function pushImage(context: IActionContext, node: ImageTreeItem | undefined): Promise<void> {
if (!node) {
await ext.imagesTree.refresh(context);
node = await ext.imagesTree.showTreeItemPicker<ImageTreeItem>(ImageTreeItem.contextValue, {
...context,
noItemFoundErrorMessage: vscode.l10n.t('No images are available to push'),
});
}
let connectedRegistry: UnifiedRegistryItem<CommonRegistry> | undefined;
if (!node.fullTag.includes('/')) {
// The registry to push to is indeterminate--could be Docker Hub, or could need tagging.
const prompt: boolean = vscode.workspace.getConfiguration('docker').get('promptForRegistryWhenPushingImages', true);
// If the prompt setting is true, we'll ask; if not we'll assume Docker Hub.
if (prompt) {
try {
connectedRegistry = await registryExperience<CommonRegistry>(context, { contextValueFilter: { include: [/commonregistry/i] } });
} catch (error) {
if (error instanceof NoResourceFoundError) {
// Do nothing, move on without a selected registry
} else {
// Rethrow
throw error;
}
}
} else {
// Try to find a connected Docker Hub registry (primarily for login credentials)
connectedRegistry = await registryExperience<CommonRegistry>(
context,
{
registryFilter: { include: [ext.dockerHubRegistryDataProvider.label] },
contextValueFilter: { include: /commonregistry/i },
skipIfOne: true
}
);
}
} else {
// The registry to push to is determinate. If there's a connected registry in the tree view, we'll try to find it, to perform login ahead of time.
// Registry path is everything up to the last slash.
const progressOptions: vscode.ProgressOptions = {
location: vscode.ProgressLocation.Notification,
title: vscode.l10n.t('Fetching login credentials...'),
};
connectedRegistry = await vscode.window.withProgress(progressOptions, async () => await tryGetConnectedRegistryForPath(context, node.parent.label));
}
// Give the user a chance to modify the tag however they want
const finalTag = await tagImage(context, node, connectedRegistry);
const baseImagePath = connectedRegistry.wrappedItem.baseUrl.authority;
if (connectedRegistry && finalTag.startsWith(baseImagePath)) {
// If a registry was found/chosen and is still the same as the final tag's registry, try logging in
await vscode.commands.executeCommand('vscode-docker.registries.logInToDockerCli', connectedRegistry);
}
addImageTaggingTelemetry(context, finalTag, '');
const client = await ext.runtimeManager.getClient();
const taskCRF = new TaskCommandRunnerFactory(
{
taskName: finalTag
}
);
await taskCRF.getCommandRunner()(
client.pushImage({ imageRef: finalTag })
);
}
async function tryGetConnectedRegistryForPath(context: IActionContext, baseImagePath: string): Promise<UnifiedRegistryItem<CommonRegistry> | undefined> {
const baseImageNameInfo = parseDockerLikeImageName(baseImagePath);
const allRegistries = await ext.registriesTree.getConnectedRegistries(baseImageNameInfo.registry);
let matchedRegistry = allRegistries.find((registry) => registry.wrappedItem.baseUrl.authority === baseImageNameInfo.registry);
if (!matchedRegistry) {
matchedRegistry = await registryExperience<CommonRegistry>(context, { contextValueFilter: { include: [/commonregistry/i] } });
}
return matchedRegistry;
}

Просмотреть файл

@ -0,0 +1,36 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { AzureWizardPromptStep, IAzureQuickPickItem } from '@microsoft/vscode-azext-utils';
import { CommonRegistry } from '@microsoft/vscode-docker-registries';
import * as vscode from 'vscode';
import { ext } from '../../../extensionVariables';
import { UnifiedRegistryItem } from '../../../tree/registries/UnifiedRegistryTreeDataProvider';
import { createAzureRegistry } from '../../registries/azure/createAzureRegistry';
import { PushImageWizardContext } from './PushImageWizardContext';
export class CreatePickAcrPromptStep extends AzureWizardPromptStep<PushImageWizardContext> {
public async prompt(wizardContext: PushImageWizardContext): Promise<void> {
const acrs = await ext.registriesRoot.getChildren(wizardContext.azureSubscriptionNode) as UnifiedRegistryItem<CommonRegistry>[];
const picks: IAzureQuickPickItem<string | UnifiedRegistryItem<CommonRegistry>>[] = acrs.map(acr => <IAzureQuickPickItem<UnifiedRegistryItem<CommonRegistry>>>{ label: acr.wrappedItem.label, data: acr });
picks.push({ label: vscode.l10n.t('$(plus) Create new Azure Container Registry...'), data: 'create' });
const response = await wizardContext.ui.showQuickPick(picks, { placeHolder: vscode.l10n.t('Select an Azure Container Registry to push to') });
if (response.data === 'create') {
const createdAcrName = await createAzureRegistry(wizardContext, wizardContext.azureSubscriptionNode);
const acrNodes = await ext.registriesRoot.getChildren(wizardContext.azureSubscriptionNode) as UnifiedRegistryItem<CommonRegistry>[];
const selectedAcrNode = acrNodes.find(acrNode => acrNode.wrappedItem.label === createdAcrName);
wizardContext.connectedRegistry = selectedAcrNode;
} else {
wizardContext.connectedRegistry = response.data as UnifiedRegistryItem<CommonRegistry>;
}
}
public shouldPrompt(wizardContext: PushImageWizardContext): boolean {
return !!wizardContext.azureSubscriptionNode;
}
}

Просмотреть файл

@ -0,0 +1,18 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { AzureWizardPromptStep } from '@microsoft/vscode-azext-utils';
import { tagImage } from '../tagImage';
import { PushImageWizardContext } from './PushImageWizardContext';
export class FinalTagPromptStep extends AzureWizardPromptStep<PushImageWizardContext> {
public async prompt(wizardContext: PushImageWizardContext): Promise<void> {
wizardContext.finalTag = await tagImage(wizardContext, wizardContext.node, wizardContext.connectedRegistry);
}
public shouldPrompt(wizardContext: PushImageWizardContext): boolean {
return !wizardContext.finalTag;
}
}

Просмотреть файл

@ -0,0 +1,67 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { AzureWizardPromptStep, IActionContext, NoResourceFoundError } from '@microsoft/vscode-azext-utils';
import { parseDockerLikeImageName } from '@microsoft/vscode-container-client';
import { CommonRegistry } from '@microsoft/vscode-docker-registries';
import * as vscode from 'vscode';
import { ext } from '../../../extensionVariables';
import { NormalizedImageNameInfo } from '../../../tree/images/NormalizedImageNameInfo';
import { AzureSubscriptionRegistryItem, isAzureSubscriptionRegistryItem } from '../../../tree/registries/Azure/AzureRegistryDataProvider';
import { UnifiedRegistryItem } from '../../../tree/registries/UnifiedRegistryTreeDataProvider';
import { registryExperience } from '../../../utils/registryExperience';
import { PushImageWizardContext } from './PushImageWizardContext';
export class GetRegistryTargetPromptStep extends AzureWizardPromptStep<PushImageWizardContext> {
public async configureBeforePrompt(wizardContext: PushImageWizardContext): Promise<void> {
// If the image is qualified (has a slash), we'll look for a matching registry in the tree view
if (this.registryIsDeterminate(wizardContext.initialTag)) {
wizardContext.connectedRegistry = await this.tryGetConnectedRegistryForPath(wizardContext, wizardContext.initialTag);
}
}
public async prompt(wizardContext: PushImageWizardContext): Promise<void> {
try {
const pickedNode = await registryExperience<CommonRegistry | AzureSubscriptionRegistryItem>(wizardContext, { contextValueFilter: { include: [/commonregistry/i, /azuresubscription/i] } });
if (isAzureSubscriptionRegistryItem(pickedNode.wrappedItem)) {
// An Azure subscription node was chosen. The CreatePickAcrPromptStep will be activated, instead of the generic RecursiveQuickPickStep that would normally be used.
wizardContext.azureSubscriptionNode = pickedNode as UnifiedRegistryItem<AzureSubscriptionRegistryItem>;
} else {
wizardContext.connectedRegistry = pickedNode as UnifiedRegistryItem<CommonRegistry>;
}
} catch (error) {
if (error instanceof NoResourceFoundError) {
// Do nothing, move on without a selected registry
} else {
// Rethrow
throw error;
}
}
}
public shouldPrompt(wizardContext: PushImageWizardContext): boolean {
return !wizardContext.connectedRegistry && !this.registryIsDeterminate(wizardContext.initialTag) && this.shouldPromptForRegistry;
}
private async tryGetConnectedRegistryForPath(context: IActionContext, baseImagePath: string): Promise<UnifiedRegistryItem<CommonRegistry> | undefined> {
const baseImageNameInfo = parseDockerLikeImageName(baseImagePath);
const normalizedImageNameInfo = new NormalizedImageNameInfo(baseImageNameInfo);
const allRegistries = await vscode.window.withProgress({
location: vscode.ProgressLocation.Notification,
title: vscode.l10n.t('Determining registry to push to...'),
}, () => ext.registriesTree.getConnectedRegistries(normalizedImageNameInfo.normalizedRegistry));
return allRegistries.find((registry) => registry.wrappedItem.baseUrl.authority === normalizedImageNameInfo.normalizedRegistry);
}
private get shouldPromptForRegistry(): boolean {
return vscode.workspace.getConfiguration('docker').get('promptForRegistryWhenPushingImages', true);
}
private registryIsDeterminate(imageName: string): boolean {
return imageName.includes('/');
}
}

Просмотреть файл

@ -0,0 +1,33 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { AzureWizardExecuteStep } from '@microsoft/vscode-azext-utils';
import { ext } from '../../../extensionVariables';
import { TaskCommandRunnerFactory } from '../../../runtimes/runners/TaskCommandRunnerFactory';
import { addImageTaggingTelemetry } from '../tagImage';
import { PushImageWizardContext } from './PushImageWizardContext';
export class ImagePushStep extends AzureWizardExecuteStep<PushImageWizardContext> {
public priority: number = 300;
public async execute(wizardContext: PushImageWizardContext): Promise<void> {
addImageTaggingTelemetry(wizardContext, wizardContext.finalTag, '');
const client = await ext.runtimeManager.getClient();
const taskCRF = new TaskCommandRunnerFactory(
{
taskName: wizardContext.finalTag
}
);
await taskCRF.getCommandRunner()(
client.pushImage({ imageRef: wizardContext.finalTag })
);
}
public shouldExecute(wizardContext: PushImageWizardContext): boolean {
return true;
}
}

Просмотреть файл

@ -0,0 +1,20 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IActionContext } from '@microsoft/vscode-azext-utils';
import { CommonRegistry } from '@microsoft/vscode-docker-registries';
import { ImageTreeItem } from '../../../tree/images/ImageTreeItem';
import { AzureSubscriptionRegistryItem } from '../../../tree/registries/Azure/AzureRegistryDataProvider';
import { UnifiedRegistryItem } from '../../../tree/registries/UnifiedRegistryTreeDataProvider';
export interface PushImageWizardContext extends IActionContext {
connectedRegistry?: UnifiedRegistryItem<CommonRegistry>;
finalTag?: string;
initialTag: string;
node: ImageTreeItem;
azureSubscriptionNode?: UnifiedRegistryItem<AzureSubscriptionRegistryItem>;
}

Просмотреть файл

@ -0,0 +1,29 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { AzureWizardExecuteStep } from '@microsoft/vscode-azext-utils';
import { parseDockerLikeImageName } from '@microsoft/vscode-container-client';
import * as vscode from 'vscode';
import { NormalizedImageNameInfo } from '../../../tree/images/NormalizedImageNameInfo';
import { PushImageWizardContext } from './PushImageWizardContext';
export class RegistryLoginStep extends AzureWizardExecuteStep<PushImageWizardContext> {
public priority: number = 200;
public async execute(wizardContext: PushImageWizardContext): Promise<void> {
await vscode.commands.executeCommand('vscode-docker.registries.logInToDockerCli', wizardContext.connectedRegistry);
}
public shouldExecute(wizardContext: PushImageWizardContext): boolean {
// If a registry was found/chosen and is still the same as the final tag's registry, try logging in
if (!wizardContext.connectedRegistry) {
return false;
}
const baseAuthority = wizardContext.connectedRegistry.wrappedItem.baseUrl.authority;
const desiredRegistry = new NormalizedImageNameInfo(parseDockerLikeImageName(wizardContext.finalTag)).normalizedRegistry;
return desiredRegistry === baseAuthority;
}
}

Просмотреть файл

@ -0,0 +1,45 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { AzureWizard, IActionContext } from '@microsoft/vscode-azext-utils';
import * as vscode from 'vscode';
import { ext } from '../../../extensionVariables';
import { ImageTreeItem } from '../../../tree/images/ImageTreeItem';
import { CreatePickAcrPromptStep } from './CreatePickAcrPromptStep';
import { FinalTagPromptStep } from './FinalTagPromptStep';
import { GetRegistryTargetPromptStep } from './GetRegistryTargetPromptStep';
import { ImagePushStep } from './ImagePushStep';
import { PushImageWizardContext } from './PushImageWizardContext';
import { RegistryLoginStep } from './RegistryLoginStep';
export async function pushImage(context: IActionContext, node: ImageTreeItem | undefined): Promise<void> {
if (!node) {
await ext.imagesTree.refresh(context);
node = await ext.imagesTree.showTreeItemPicker<ImageTreeItem>(ImageTreeItem.contextValue, {
...context,
noItemFoundErrorMessage: vscode.l10n.t('No images are available to push'),
});
}
const wizardContext = context as PushImageWizardContext;
wizardContext.initialTag = node.fullTag;
wizardContext.node = node;
const wizard = new AzureWizard(wizardContext, {
promptSteps: [
new GetRegistryTargetPromptStep(),
new CreatePickAcrPromptStep(),
new FinalTagPromptStep(),
],
executeSteps: [
new RegistryLoginStep(),
new ImagePushStep(),
],
showLoadingPrompt: true,
});
await wizard.prompt();
await wizard.execute();
}

Просмотреть файл

@ -37,7 +37,7 @@ import { copyFullTag } from "./images/copyFullTag";
import { inspectImage } from "./images/inspectImage";
import { pruneImages } from "./images/pruneImages";
import { pullImage } from "./images/pullImage";
import { pushImage } from "./images/pushImage";
import { pushImage } from "./images/pushImage/pushImage";
import { removeImage } from "./images/removeImage";
import { removeImageGroup } from "./images/removeImageGroup";
import { runAzureCliImage } from "./images/runAzureCliImage";

Просмотреть файл

@ -13,17 +13,12 @@ import { AzureRegistrySkuStep } from '../../../tree/registries/Azure/createWizar
import { IAzureRegistryWizardContext } from '../../../tree/registries/Azure/createWizard/IAzureRegistryWizardContext';
import { UnifiedRegistryItem } from '../../../tree/registries/UnifiedRegistryTreeDataProvider';
import { getAzExtAzureUtils } from '../../../utils/lazyPackages';
import { registryExperience } from '../../../utils/registryExperience';
import { subscriptionExperience } from '../../../utils/registryExperience';
export async function createAzureRegistry(context: IActionContext, node?: UnifiedRegistryItem<AzureSubscriptionRegistryItem>): Promise<void> {
export async function createAzureRegistry(context: IActionContext, node?: UnifiedRegistryItem<AzureSubscriptionRegistryItem>): Promise<string> {
if (!node) {
node = await registryExperience<AzureSubscriptionRegistryItem>(context,
{
contextValueFilter: { include: /azuresubscription/i },
registryFilter: { include: [ext.azureRegistryDataProvider.label] }
}
);
node = await subscriptionExperience(context);
}
const registryItem = node.wrappedItem;
@ -60,4 +55,6 @@ export async function createAzureRegistry(context: IActionContext, node?: Unifie
void window.showInformationMessage(`Successfully created registry "${newRegistryName}".`);
void ext.registriesTree.refresh();
return newRegistryName;
}

Просмотреть файл

@ -9,10 +9,9 @@ import { AzureWizard, AzureWizardExecuteStep, AzureWizardPromptStep, IActionCont
import { CommonTag } from '@microsoft/vscode-docker-registries';
import { Uri, env, l10n, window } from "vscode";
import { ext } from "../../../extensionVariables";
import { AzureSubscriptionRegistryItem } from '../../../tree/registries/Azure/AzureRegistryDataProvider';
import { UnifiedRegistryItem } from '../../../tree/registries/UnifiedRegistryTreeDataProvider';
import { getAzExtAppService, getAzExtAzureUtils } from '../../../utils/lazyPackages';
import { registryExperience } from '../../../utils/registryExperience';
import { registryExperience, subscriptionExperience } from '../../../utils/registryExperience';
import { DockerAssignAcrPullRoleStep } from './DockerAssignAcrPullRoleStep';
import { DockerSiteCreateStep } from './DockerSiteCreateStep';
import { DockerWebhookCreateStep } from './DockerWebhookCreateStep';
@ -31,10 +30,7 @@ export async function deployImageToAzure(context: IActionContext, node?: Unified
const vscAzureAppService = await getAzExtAppService();
const promptSteps: AzureWizardPromptStep<IAppServiceWizardContext>[] = [];
const subscriptionItem = await registryExperience<AzureSubscriptionRegistryItem>(context, {
registryFilter: { include: [ext.azureRegistryDataProvider.label] },
contextValueFilter: { include: /azuresubscription/i },
});
const subscriptionItem = await subscriptionExperience(context);
const subscriptionContext = createSubscriptionContext(subscriptionItem.wrappedItem.subscription);
const wizardContext: IActionContext & Partial<IAppServiceContainerWizardContext> = {
...context,

Просмотреть файл

@ -1,3 +1,8 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { CommonRegistry, CommonRegistryRoot, RegistryDataProvider, isCommonRegistryItem, isRegistry } from '@microsoft/vscode-docker-registries';
import * as vscode from 'vscode';
import { ext } from '../../extensionVariables';
@ -192,15 +197,12 @@ export class UnifiedRegistryTreeDataProvider implements vscode.TreeDataProvider<
if (imageBaseName) {
if (imageBaseName === 'docker.io') {
registryRoots = registryRoots.filter(r => (r.wrappedItem as CommonRegistryRoot).label === ext.dockerHubRegistryDataProvider.label);
}
else if (imageBaseName.endsWith('azurecr.io')) {
} else if (imageBaseName.endsWith('azurecr.io')) {
registryRoots = registryRoots.filter(r => (r.wrappedItem as CommonRegistryRoot).label === ext.azureRegistryDataProvider.label);
findAzureRegistryOnly = true;
}
else if (imageBaseName === 'ghcr.io') {
} else if (imageBaseName === 'ghcr.io') {
registryRoots = registryRoots.filter(r => (r.wrappedItem as CommonRegistryRoot).label === ext.githubRegistryDataProvider.label);
}
else {
} else {
registryRoots = registryRoots.filter(
r => (r.wrappedItem as CommonRegistryRoot).label !== 'Docker Hub'
&& (r.wrappedItem as CommonRegistryRoot).label !== 'Azure'

Просмотреть файл

@ -3,10 +3,11 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { AzureWizardPromptStep, ContextValueFilterQuickPickOptions, GenericQuickPickStep, IActionContext, PickFilter, QuickPickWizardContext, RecursiveQuickPickStep, UserCancelledError, runQuickPickWizard } from '@microsoft/vscode-azext-utils';
import { ContextValueFilterQuickPickOptions, GenericQuickPickStep, IActionContext, IWizardOptions, PickFilter, QuickPickWizardContext, RecursiveQuickPickStep, UserCancelledError, runQuickPickWizard } from '@microsoft/vscode-azext-utils';
import { CommonRegistryItem } from '@microsoft/vscode-docker-registries';
import { MessageItem, TreeItem, commands, l10n, window } from 'vscode';
import { ext } from '../extensionVariables';
import { AzureSubscriptionRegistryItem } from '../tree/registries/Azure/AzureRegistryDataProvider';
import { isConnectRegistryTreeItem } from '../tree/registries/ConnectRegistryTreeItem';
import { UnifiedRegistryItem, UnifiedRegistryTreeDataProvider } from '../tree/registries/UnifiedRegistryTreeDataProvider';
@ -33,7 +34,7 @@ export async function registryExperience<TNode extends CommonRegistryItem>(conte
if (registryRoots.length === 0 || (registryRoots.length === 1 && isConnectRegistryTreeItem(registryRoots[0].wrappedItem))) {
const add: MessageItem = { title: l10n.t('Connect Registry...') };
void window.showErrorMessage(
l10n.t('No registry providers are connected. Please connect a registry provider to continue.'),
l10n.t('No registry providers are connected. Please connect a registry provider and try again to continue.'),
...[add])
.then((result) => {
if (result === add) {
@ -44,23 +45,26 @@ export async function registryExperience<TNode extends CommonRegistryItem>(conte
throw new UserCancelledError();
}
// get the registry provider unified item
const promptSteps: AzureWizardPromptStep<QuickPickWizardContext>[] = [
new RegistryQuickPickStep(ext.registriesTree, options)
];
if (options?.contextValueFilter) {
promptSteps.push(new RecursiveQuickPickStep(ext.registriesTree, options as ContextValueFilterQuickPickOptions));
}
const unifiedRegistryItem = await runQuickPickWizard<UnifiedRegistryItem<TNode>>(context, {
hideStepCount: true,
promptSteps: promptSteps,
promptSteps: [
new RegistryProviderQuickPickStep(ext.registriesTree, options)
],
});
return unifiedRegistryItem;
}
export async function subscriptionExperience(context: IActionContext): Promise<UnifiedRegistryItem<AzureSubscriptionRegistryItem>> {
return registryExperience<AzureSubscriptionRegistryItem>(context,
{
registryFilter: { include: [ext.azureRegistryDataProvider.label] },
contextValueFilter: { include: /azuresubscription/i },
skipIfOne: true
}
);
}
export class RegistryPickFilter implements PickFilter {
public constructor(private readonly options: RegistryExperienceOptions) { }
@ -87,7 +91,7 @@ export class RegistryPickFilter implements PickFilter {
}
}
export class RegistryQuickPickStep extends GenericQuickPickStep<QuickPickWizardContext, RegistryExperienceOptions> {
export class RegistryProviderQuickPickStep extends GenericQuickPickStep<QuickPickWizardContext, RegistryExperienceOptions> {
public readonly pickFilter: PickFilter;
public constructor(
@ -97,4 +101,15 @@ export class RegistryQuickPickStep extends GenericQuickPickStep<QuickPickWizardC
super(treeDataProvider, pickOptions, { placeHolder: l10n.t('Select registry provider') });
this.pickFilter = new RegistryPickFilter(pickOptions);
}
public async getSubWizard(wizardContext: QuickPickWizardContext): Promise<IWizardOptions<QuickPickWizardContext>> {
if (this.pickOptions.contextValueFilter) {
return {
promptSteps: [new RecursiveQuickPickStep(this.treeDataProvider, this.pickOptions as ContextValueFilterQuickPickOptions)],
hideStepCount: true,
};
}
return undefined;
}
}