Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
13 changes: 13 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,22 @@
"command": "containerApps.addScaleRule",
"title": "%containerApps.addScaleRule%",
"category": "Azure Container Apps"
},
{
"command": "containerApps.deploy",
"title": "%containerApps.deploy%",
"category": "Azure Container Apps",
"icon": "$(cloud-upload)"
}
],
"menus": {
"azureWorkspaceDeploy": [
{
"command": "containerApps.deploy",
"when": "view == azureWorkspace",
"group": "navigation@3"
}
],
Comment thread
MicroFish91 marked this conversation as resolved.
"view/item/context": [
{
"command": "containerApps.createManagedEnvironment",
Expand Down
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"containerApps.enableOutputTimestamps": "Prepends each line displayed in the output channel with a timestamp.",
"containerApps.browse": "Browse",
"containerApps.createContainerApp": "Create Container App...",
"containerApps.deploy": "Deploy to Container App...",
"containerApps.deployImage": "Update Image in Container App...",
"containerApps.deployImageApi": "Update Image in Container App (API)...",
"containerApps.deleteContainerApp": "Delete Container App...",
Expand Down
21 changes: 18 additions & 3 deletions src/commands/createContainerApp/ImageSourceListStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,36 @@ import { EnvironmentVariablesListStep } from "./EnvironmentVariablesListStep";
import { IContainerAppContext } from './IContainerAppContext';
import { setQuickStartImage } from "./setQuickStartImage";

interface ImageSourceOptions {
useQuickStartImage?: boolean;
}
export class ImageSourceListStep extends AzureWizardPromptStep<IContainerAppContext> {
Comment thread
MicroFish91 marked this conversation as resolved.
Outdated
constructor(private readonly options?: ImageSourceOptions) {
super();
}

public async prompt(context: IContainerAppContext): Promise<void> {
const imageSourceLabels: string[] = [
localize('quickStartImage', 'Use quickstart image'),
localize('externalRegistry', 'Use existing image'),
localize('quickStartImage', 'Use quickstart image'),
localize('updateImage', 'Update image in Container App')
// 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[0], data: ImageSource.ExternalRegistry, suppressPersistence: true },
// { label: imageSourceLabels[2], data: undefined, suppressPersistence: true },
Comment thread
MicroFish91 marked this conversation as resolved.
];

if (this.options?.useQuickStartImage) {
picks.unshift({ label: imageSourceLabels[1], data: ImageSource.QuickStartImage, suppressPersistence: true });
} else {
if (context.targetContainer?.template?.containers?.[0]?.image) {
picks.push({ label: imageSourceLabels[2], data: ImageSource.ExternalRegistry, suppressPersistence: true });
Comment thread
MicroFish91 marked this conversation as resolved.
Outdated
}
}

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

Expand Down
3 changes: 2 additions & 1 deletion src/commands/createContainerApp/createContainerApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ export async function createContainerApp(context: IActionContext & Partial<ICrea
};

const title: string = localize('createContainerApp', 'Create Container App');
const useQuickStartImage: boolean = true;

const promptSteps: AzureWizardPromptStep<IContainerAppWithActivityContext>[] = [
new ContainerAppNameStep(),
new ImageSourceListStep(),
new ImageSourceListStep({ useQuickStartImage }),
Comment thread
MicroFish91 marked this conversation as resolved.
Outdated
new EnableIngressStep(),
];

Expand Down
4 changes: 3 additions & 1 deletion src/commands/deployImage/IDeployImageContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
import type { ContainerApp, EnvironmentVar } from "@azure/arm-appcontainers";
import type { ContainerRegistryManagementModels } from '@azure/arm-containerregistry';
import { ISubscriptionActionContext } from '@microsoft/vscode-azext-utils';
import { SupportedRegistries } from '../../constants';
import { ImageSourceValues, SupportedRegistries } from '../../constants';

export interface IDeployImageContext extends ISubscriptionActionContext {
deployMethod?: ImageSourceValues;
Comment thread
MicroFish91 marked this conversation as resolved.
Outdated

targetContainer?: ContainerApp;
registryDomain?: SupportedRegistries;

Expand Down
34 changes: 34 additions & 0 deletions src/commands/deployImage/deploy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ContainerApp } from "@azure/arm-appcontainers";
import { AzureWizard, AzureWizardPromptStep } from "@microsoft/vscode-azext-utils";
import { ContainerAppItem } from "../../tree/ContainerAppItem";
import { localize } from "../../utils/localize";
import { pickContainerApp } from "../../utils/pickContainerApp";
import { ImageSourceListStep } from "../createContainerApp/ImageSourceListStep";
import { IDeployImageContext } from "./IDeployImageContext";

export async function deployContainerApp(context: IDeployImageContext): Promise<void> {
Comment thread
MicroFish91 marked this conversation as resolved.
Outdated
const promptSteps: AzureWizardPromptStep<IDeployImageContext>[] = [];
const wizardContext: IDeployImageContext = context;
const wizard: AzureWizard<IDeployImageContext> = new AzureWizard(wizardContext, {
promptSteps
});

context.targetContainer = await getContainerApp(context); //may need to change so it is more easy to add create
Comment thread
MicroFish91 marked this conversation as resolved.
Outdated

const useQuickStartImage: boolean = false
Comment thread
MicroFish91 marked this conversation as resolved.
Outdated
promptSteps.push(new ImageSourceListStep({ useQuickStartImage }));
Comment thread
bwateratmsft marked this conversation as resolved.
Outdated

await wizard.prompt();
}

async function getContainerApp(context: IDeployImageContext, node?: ContainerAppItem): Promise<ContainerApp> {
node ??= await pickContainerApp(context, {
title: localize('deployContainerApp', 'Choose a Container App'),
});

return node.containerApp;
}
2 changes: 2 additions & 0 deletions src/commands/registerCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { createContainerApp } from './createContainerApp/createContainerApp';
import { createManagedEnvironment } from './createManagedEnvironment/createManagedEnvironment';
import { deleteContainerApp } from './deleteContainerApp/deleteContainerApp';
import { deleteManagedEnvironment } from './deleteManagedEnvironment/deleteManagedEnvironment';
import { deployContainerApp } from './deployImage/deploy';
import { deployImage } from './deployImage/deployImage';
import { deployImageApi } from './deployImage/deployImageApi';
import { disableIngress } from './ingress/disableIngress';
Expand All @@ -31,6 +32,7 @@ export function registerCommands(): void {
// container apps
registerCommandWithTreeNodeUnwrapping('containerApps.createContainerApp', createContainerApp);
registerCommandWithTreeNodeUnwrapping('containerApps.deleteContainerApp', deleteContainerApp);
registerCommandWithTreeNodeUnwrapping('containerApps.deploy', deployContainerApp);
registerCommandWithTreeNodeUnwrapping('containerApps.deployImage', deployImage);
registerCommandWithTreeNodeUnwrapping('containerApps.deployImageApi', deployImageApi);
registerCommandWithTreeNodeUnwrapping('containerApps.openConsoleInPortal', openConsoleInPortal);
Expand Down