Skip to content
Merged
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
2 changes: 2 additions & 0 deletions src/commands/createContainerApp/IContainerAppContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@

import { IResourceGroupWizardContext } from '@microsoft/vscode-azext-azureutils';
import { ExecuteActivityContext } from "@microsoft/vscode-azext-utils";
import { ImageSourceValues } from '../../constants';
import { ContainerAppModel } from "../../tree/ContainerAppItem";
import { IDeployImageContext } from '../deployImage/IDeployImageContext';
export interface IContainerAppContext extends IResourceGroupWizardContext, IDeployImageContext {
managedEnvironmentId: string;
newContainerAppName?: string;
imageSource?: ImageSourceValues;

enableIngress?: boolean;
enableExternal?: boolean;
Expand Down
51 changes: 51 additions & 0 deletions src/commands/createContainerApp/ImageSourceListStep.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*---------------------------------------------------------------------------------------------
* 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, IWizardOptions } from "@microsoft/vscode-azext-utils";
import { ImageSource, ImageSourceValues } from "../../constants";
import { localize } from "../../utils/localize";
import { ContainerRegistryListStep } from "../deployImage/ContainerRegistryListStep";
import { EnvironmentVariablesListStep } from "./EnvironmentVariablesListStep";
import { IContainerAppContext } from './IContainerAppContext';

export class ImageSourceListStep extends AzureWizardPromptStep<IContainerAppContext> {
public async prompt(context: IContainerAppContext): Promise<void> {
const imageSourceLabels: string[] = [
localize('quickStartImage', 'Use quickstart image'),
localize('externalRegistry', 'Use existing image'),
// localize('buildFromProject', 'Build from project'),
];

const placeHolder: string = localize('imageBuildSourcePrompt', 'Select an image source for the container app');
const picks: IAzureQuickPickItem<ImageSourceValues | undefined>[] = [
{ label: imageSourceLabels[0], data: ImageSource.QuickStartImage, suppressPersistence: true },
{ label: imageSourceLabels[1], data: ImageSource.ExternalRegistry, suppressPersistence: true },
// { label: imageSourceLabels[2], data: undefined, suppressPersistence: true },
];

context.imageSource = (await context.ui.showQuickPick(picks, { placeHolder })).data;
}

public shouldPrompt(context: IContainerAppContext): boolean {
return !context.imageSource;
}

public async getSubWizard(context: IContainerAppContext): Promise<IWizardOptions<IContainerAppContext> | undefined> {
const promptSteps: AzureWizardPromptStep<IContainerAppContext>[] = [];

switch (context.imageSource) {
case ImageSource.QuickStartImage:
// Todo: @mmott
throw new Error('Not implemented yet');
case ImageSource.ExternalRegistry:
promptSteps.push(new ContainerRegistryListStep(), new EnvironmentVariablesListStep());
break;
default:
// Todo: Steps that lead to additional 'Build from project' options
}

return { promptSteps };
}
}
6 changes: 2 additions & 4 deletions src/commands/createContainerApp/createContainerApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ import { ManagedEnvironmentItem } from "../../tree/ManagedEnvironmentItem";
import { createActivityContext } from "../../utils/activityUtils";
import { localize } from "../../utils/localize";
import { containerAppEnvironmentExperience } from "../../utils/pickContainerApp";
import { ContainerRegistryListStep } from "../deployImage/ContainerRegistryListStep";
import { ContainerAppCreateStep } from "./ContainerAppCreateStep";
import { ContainerAppNameStep } from "./ContainerAppNameStep";
import { EnableIngressStep } from "./EnableIngressStep";
import { EnvironmentVariablesListStep } from "./EnvironmentVariablesListStep";
import { IContainerAppContext, IContainerAppWithActivityContext } from "./IContainerAppContext";
import { ImageSourceListStep } from "./ImageSourceListStep";
import { showContainerAppCreated } from "./showContainerAppCreated";

export async function createContainerApp(context: IActionContext & Partial<ICreateChildImplContext> & Partial<IContainerAppContext>, node?: ManagedEnvironmentItem): Promise<ContainerAppItem> {
Expand All @@ -36,8 +35,7 @@ export async function createContainerApp(context: IActionContext & Partial<ICrea

const promptSteps: AzureWizardPromptStep<IContainerAppWithActivityContext>[] = [
new ContainerAppNameStep(),
new ContainerRegistryListStep(),
new EnvironmentVariablesListStep(),
new ImageSourceListStep(),
new EnableIngressStep(),
];

Expand Down
21 changes: 21 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,27 @@ export enum ScaleRuleTypes {
Queue = "Azure queue"
}

export enum ImageSource {
/*
* Uses the default hello-world image with preset configurations
*/
QuickStartImage = 'quickStartImage',
/*
* Use an image stored in ACR or a third party registry
*/
ExternalRegistry = 'externalRegistry',
/*
* Build the image from your project locally using Docker (reqs. Dockerfile)
*/
LocalDockerBuild = 'localDockerBuild',
/*
* Build the image from your project remotely using ACR (reqs. Dockerfile)
*/
RemoteAcrBuild = 'remoteAcrBuild'
}

export type ImageSourceValues = typeof ImageSource[keyof typeof ImageSource];

export const acrDomain = 'azurecr.io';
export const dockerHubDomain = 'docker.io';
export const dockerHubRegistry = 'index.docker.io';
Expand Down