Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes for azure agent #1664

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions appservice/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@microsoft/vscode-azext-azureappservice",
"author": "Microsoft Corporation",
"version": "2.3.4",
"version": "2.4.0",
"description": "Common tools for developing Azure App Service extensions for VS Code",
"tags": [
"azure",
Expand Down Expand Up @@ -40,9 +40,9 @@
"@azure/core-client": "^1.7.2",
"@azure/core-rest-pipeline": "^1.10.3",
"@azure/storage-blob": "^12.3.0",
"@microsoft/vscode-azext-azureutils": "^2.0.6",
"@microsoft/vscode-azext-azureutils": "2.1.0",
"@microsoft/vscode-azext-github": "^1.0.0",
"@microsoft/vscode-azext-utils": "^2.1.0",
"@microsoft/vscode-azext-utils": "2.2.0",
"dayjs": "^1.11.2",
"fs-extra": "^10.0.0",
"p-retry": "^3.0.1",
Expand Down
37 changes: 31 additions & 6 deletions appservice/src/createAppService/SiteNameStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import type { ResourceNameAvailability, WebSiteManagementClient } from '@azure/arm-appservice';
import { ResourceGroupListStep, StorageAccountListStep, resourceGroupNamingRules, storageAccountNamingRules } from '@microsoft/vscode-azext-azureutils';
import { AzureNameStep, IAzureNamingRules } from '@microsoft/vscode-azext-utils';
import { AgentInputBoxOptions, AzureNameStep, IAzureAgentInput, IAzureNamingRules, ParameterAgentMetadata } from '@microsoft/vscode-azext-utils';
import * as vscode from 'vscode';
import { createWebSiteClient } from '../utils/azureClients';
import { appInsightsNamingRules } from './AppInsightsListStep';
Expand All @@ -14,14 +14,27 @@ import { AppServicePlanListStep } from './AppServicePlanListStep';
import { appServicePlanNamingRules } from './AppServicePlanNameStep';
import { IAppServiceWizardContext } from './IAppServiceWizardContext';

interface SiteNameStepWizardContext extends IAppServiceWizardContext {
ui: IAzureAgentInput;
}

const siteNamingRules: IAzureNamingRules = {
minLength: 2,
maxLength: 60,
invalidCharsRegExp: /[^a-zA-Z0-9\-]/
};

export class SiteNameStep extends AzureNameStep<IAppServiceWizardContext> {
public async prompt(context: IAppServiceWizardContext): Promise<void> {
export class SiteNameStep extends AzureNameStep<SiteNameStepWizardContext> {
private _skipValidation: boolean;
private _inputBoxOptionsAgentMetadata: ParameterAgentMetadata | undefined;

constructor(skipValidation?: boolean, inputBoxOptionsAgentMetadata?: ParameterAgentMetadata) {
super();
this._skipValidation = skipValidation ?? false;
this._inputBoxOptionsAgentMetadata = inputBoxOptionsAgentMetadata;
}

public async prompt(context: SiteNameStepWizardContext): Promise<void> {
const client = await createWebSiteClient(context);

let placeHolder: string | undefined;
Expand All @@ -48,12 +61,24 @@ export class SiteNameStep extends AzureNameStep<IAppServiceWizardContext> {
prompt = vscode.l10n.t('Enter a globally unique name for the new web app.');
}

context.newSiteName = (await context.ui.showInputBox({
const options: AgentInputBoxOptions = {
prompt,
placeHolder,
validateInput: (name: string): string | undefined => this.validateSiteName(name),
asyncValidationTask: async (name: string): Promise<string | undefined> => await this.asyncValidateSiteName(client, name)
})).trim();
asyncValidationTask: async (name: string): Promise<string | undefined> => await this.asyncValidateSiteName(client, name),
agentMetadata: this._inputBoxOptionsAgentMetadata ?? {
parameterName: "siteName",
parameterDisplayTitle: "Site Name",
parameterDisplayDescription: "The name of the app service site.",
}
};

if (this._skipValidation) {
options.validateInput = undefined;
options.asyncValidationTask = undefined;
}

context.newSiteName = (await context.ui.showInputBox(options)).trim();
context.valuesToMask.push(context.newSiteName);

const namingRules: IAzureNamingRules[] = [resourceGroupNamingRules];
Expand Down
4 changes: 3 additions & 1 deletion azure/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { ServiceClient, ServiceClientOptions } from '@azure/core-client';
import type { PagedAsyncIterableIterator } from '@azure/core-paging';
import type { PipelineRequestOptions, PipelineResponse } from '@azure/core-rest-pipeline';
import type { Environment } from '@azure/ms-rest-azure-env';
import type { AzExtParentTreeItem, AzExtServiceClientCredentials, AzExtServiceClientCredentialsT2, AzExtTreeItem, AzureNameStep, AzureWizardExecuteStep, AzureWizardPromptStep, IActionContext, IAzureNamingRules, IAzureQuickPickItem, IAzureQuickPickOptions, IRelatedNameWizardContext, ISubscriptionActionContext, ISubscriptionContext, IWizardOptions, UIExtensionVariables } from '@microsoft/vscode-azext-utils';
import type { AzExtParentTreeItem, AzExtServiceClientCredentials, AzExtServiceClientCredentialsT2, AzExtTreeItem, AzureNameStep, AzureWizardExecuteStep, AzureWizardPromptStep, IActionContext, IAzureNamingRules, IAzureQuickPickItem, IAzureQuickPickOptions, IAzureUserInput, IRelatedNameWizardContext, ISubscriptionActionContext, ISubscriptionContext, IWizardOptions, UIExtensionVariables } from '@microsoft/vscode-azext-utils';
import { AzureSubscription } from '@microsoft/vscode-azureresources-api';
import { Disposable, LogOutputChannel, Progress, Uri } from 'vscode';

Expand Down Expand Up @@ -211,6 +211,8 @@ export interface IResourceGroupWizardContext extends ILocationWizardContext, IRe
* By default, users will be prompted to select an existing resource group if creating one fails with a 403 error. Set this to `true` to prevent that behavior
*/
suppress403Handling?: boolean;

ui: IAzureUserInput;
}

export declare const resourceGroupNamingRules: IAzureNamingRules;
Expand Down
4 changes: 2 additions & 2 deletions azure/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@microsoft/vscode-azext-azureutils",
"author": "Microsoft Corporation",
"version": "2.0.6",
"version": "2.1.0",
"description": "Common Azure utils for developing Azure extensions for VS Code",
"tags": [
"azure",
Expand Down Expand Up @@ -39,7 +39,7 @@
"@azure/core-client": "^1.6.0",
"@azure/core-rest-pipeline": "^1.9.0",
"@azure/logger": "^1.0.4",
"@microsoft/vscode-azext-utils": "^2.0.0",
"@microsoft/vscode-azext-utils": "2.2.0",
"semver": "^7.3.7",
"uuid": "^9.0.0"
},
Expand Down
23 changes: 19 additions & 4 deletions azure/src/wizard/LocationListStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import type { ExtendedLocation, Provider } from '@azure/arm-resources';
import type { Location } from '@azure/arm-resources-subscriptions';
import { AzureWizardPromptStep, IActionContext, IAzureQuickPickItem, IAzureQuickPickOptions, nonNullProp, nonNullValue } from '@microsoft/vscode-azext-utils';
import { AgentQuickPickItem, AgentQuickPickOptions, AzureWizardPromptStep, IActionContext, IAzureAgentInput, IAzureQuickPickItem, IAzureQuickPickOptions, nonNullProp, nonNullValue } from '@microsoft/vscode-azext-utils';
import * as vscode from 'vscode';
import * as types from '../../index';
import { createResourcesClient, createSubscriptionsClient } from '../clients';
Expand All @@ -31,6 +31,11 @@ interface ILocationWizardContextInternal extends types.ILocationWizardContext {
* The selected location. There's a small chance it's not supported by all providers if `setLocation` was used
*/
_location?: types.AzExtLocation;

/**
* Location list step is intended to be compatible with an {@link IAzureAgentInput}, so we re-type `ui`.
*/
ui: IAzureAgentInput;
}

export class LocationListStep<T extends ILocationWizardContextInternal> extends AzureWizardPromptStep<T> {
Expand Down Expand Up @@ -175,7 +180,16 @@ export class LocationListStep<T extends ILocationWizardContextInternal> extends
}

public async prompt(wizardContext: T): Promise<void> {
const options: IAzureQuickPickOptions = { placeHolder: vscode.l10n.t('Select a location for new resources.'), enableGrouping: true, ...this.options };
const options: AgentQuickPickOptions = {
placeHolder: vscode.l10n.t('Select a location for new resources.'),
enableGrouping: true,
agentMetadata: {
parameterName: 'location',
parameterDisplayTitle: vscode.l10n.t('Location'),
parameterDisplayDescription: vscode.l10n.t('The location where resources will be deployed.')
},
...this.options
};
wizardContext._location = (await wizardContext.ui.showQuickPick(this.getQuickPicks(wizardContext), options)).data;
wizardContext.telemetry.properties.locationType = wizardContext._location.type;
}
Expand All @@ -184,7 +198,7 @@ export class LocationListStep<T extends ILocationWizardContextInternal> extends
return !wizardContext._location;
}

protected async getQuickPicks(wizardContext: T): Promise<IAzureQuickPickItem<types.AzExtLocation>[]> {
protected async getQuickPicks(wizardContext: T): Promise<AgentQuickPickItem<IAzureQuickPickItem<types.AzExtLocation>>[]> {
let locations: types.AzExtLocation[] = await LocationListStep.getLocations(wizardContext);
locations = locations.sort(compareLocation);

Expand All @@ -193,7 +207,8 @@ export class LocationListStep<T extends ILocationWizardContextInternal> extends
label: nonNullProp(l, 'displayName'),
group: l.metadata?.regionCategory,
data: l,
description: LocationListStep.getQuickPickDescription?.(l)
description: LocationListStep.getQuickPickDescription?.(l),
agentMetadata: {}
};
});
}
Expand Down
Loading
Loading