Skip to content

Commit ecade3c

Browse files
authored
Added a more generic deploy command (#277)
* Add generic deploy prompt steps * Add choose container app step * Utilize ImageSourceListStep in deploy * Incorporate requested changes * Minor changes * Changes to title
1 parent 7d400fc commit ecade3c

File tree

7 files changed

+75
-10
lines changed

7 files changed

+75
-10
lines changed

package.json

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@
6565
"icon": "$(add)"
6666
},
6767
{
68-
"command": "containerApps.deployImage",
69-
"title": "%containerApps.deployImage%",
70-
"category": "Azure Container Apps"
68+
"command": "containerApps.deploy",
69+
"title": "%containerApps.deploy%",
70+
"category": "Azure Container Apps",
71+
"icon": "$(cloud-upload)"
7172
},
7273
{
7374
"command": "containerApps.deployImageApi",
@@ -151,6 +152,13 @@
151152
}
152153
],
153154
"menus": {
155+
"azureWorkspaceDeploy": [
156+
{
157+
"command": "containerApps.deploy",
158+
"when": "view == azureWorkspace",
159+
"group": "navigation@3"
160+
}
161+
],
154162
"view/item/context": [
155163
{
156164
"command": "containerApps.createManagedEnvironment",
@@ -168,7 +176,7 @@
168176
"group": "3@1"
169177
},
170178
{
171-
"command": "containerApps.deployImage",
179+
"command": "containerApps.deploy",
172180
"when": "view == azureResourceGroups && viewItem =~ /containerApp[^s]/i",
173181
"group": "3@1"
174182
},

package.nls.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"containerApps.enableOutputTimestamps": "Prepends each line displayed in the output channel with a timestamp.",
77
"containerApps.browse": "Browse",
88
"containerApps.createContainerApp": "Create Container App...",
9-
"containerApps.deployImage": "Update Image in Container App...",
9+
"containerApps.deploy": "Deploy to Container App...",
1010
"containerApps.deployImageApi": "Update Image in Container App (API)...",
1111
"containerApps.deleteContainerApp": "Delete Container App...",
1212
"containerApps.disableIngress": "Disable Ingress for Container App",

src/commands/createContainerApp/createContainerApp.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ export async function createContainerApp(context: IActionContext & Partial<ICrea
5555
showLoadingPrompt: true
5656
});
5757

58+
// we want to add the quick start image _only_ for the create scenairo
59+
wizardContext.showQuickStartImage = true;
60+
5861
await wizard.prompt();
5962
const newContainerAppName = nonNullProp(wizardContext, 'newContainerAppName');
6063

src/commands/deploy/IDeployBaseContext.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export interface IDeployBaseContext extends ISubscriptionActionContext {
1414
targetContainer?: ContainerAppModel;
1515

1616
imageSource?: ImageSourceValues;
17+
showQuickStartImage?: boolean;
1718

1819
// Base image attributes used as a precursor for either creating or updating a container app
1920
image?: string;

src/commands/deploy/ImageSourceListStep.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,21 @@ import { DeployFromRegistryConfigureStep } from "./deployFromRegistry/DeployFrom
1515
export class ImageSourceListStep extends AzureWizardPromptStep<IDeployBaseContext> {
1616
public async prompt(context: IDeployBaseContext): Promise<void> {
1717
const imageSourceLabels: string[] = [
18-
localize('quickStartImage', 'Use quickstart image'),
1918
localize('externalRegistry', 'Use existing image'),
19+
localize('quickStartImage', 'Use quickstart image'),
2020
// localize('buildFromProject', 'Build from project'),
2121
];
2222

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

29+
if (context.showQuickStartImage) {
30+
picks.unshift({ label: imageSourceLabels[1], data: ImageSource.QuickStartImage, suppressPersistence: true });
31+
}
32+
3033
context.imageSource = (await context.ui.showQuickPick(picks, { placeHolder })).data;
3134
}
3235

src/commands/deploy/deploy.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.md in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
import { VerifyProvidersStep } from "@microsoft/vscode-azext-azureutils";
6+
import { AzureWizard, AzureWizardExecuteStep, AzureWizardPromptStep, ITreeItemPickerContext, createSubscriptionContext } from "@microsoft/vscode-azext-utils";
7+
import { webProvider } from "../../constants";
8+
import { ContainerAppItem } from "../../tree/ContainerAppItem";
9+
import { localize } from "../../utils/localize";
10+
import { pickContainerApp } from "../../utils/pickContainerApp";
11+
import { ContainerAppOverwriteConfirmStep } from "./ContainerAppOverwriteConfirmStep";
12+
import { ContainerAppUpdateStep } from "./ContainerAppUpdateStep";
13+
import { IDeployBaseContext } from "./IDeployBaseContext";
14+
import { ImageSourceListStep } from "./ImageSourceListStep";
15+
16+
export async function deploy(context: ITreeItemPickerContext & Partial<IDeployBaseContext>, node?: ContainerAppItem): Promise<void> {
17+
if (!node) {
18+
context.suppressCreatePick = true;
19+
node = await pickContainerApp(context);
20+
}
21+
22+
const { subscription, containerApp } = node;
23+
24+
const wizardContext: IDeployBaseContext = {
25+
...context,
26+
...createSubscriptionContext(subscription),
27+
subscription,
28+
targetContainer: containerApp
29+
};
30+
31+
const promptSteps: AzureWizardPromptStep<IDeployBaseContext>[] = [
32+
new ContainerAppOverwriteConfirmStep(),
33+
new ImageSourceListStep()
34+
];
35+
36+
const executeSteps: AzureWizardExecuteStep<IDeployBaseContext>[] = [
37+
new VerifyProvidersStep([webProvider]),
38+
new ContainerAppUpdateStep()
39+
];
40+
41+
const wizard: AzureWizard<IDeployBaseContext> = new AzureWizard(wizardContext, {
42+
title: localize('deploy', 'Deploying to "{0}"', containerApp.name),
43+
promptSteps,
44+
executeSteps,
45+
showLoadingPrompt: true
46+
});
47+
48+
await wizard.prompt();
49+
await wizard.execute();
50+
}

src/commands/registerCommands.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { createContainerApp } from './createContainerApp/createContainerApp';
1010
import { createManagedEnvironment } from './createManagedEnvironment/createManagedEnvironment';
1111
import { deleteContainerApp } from './deleteContainerApp/deleteContainerApp';
1212
import { deleteManagedEnvironment } from './deleteManagedEnvironment/deleteManagedEnvironment';
13-
import { deployFromRegistry } from './deploy/deployFromRegistry/deployFromRegistry';
13+
import { deploy } from './deploy/deploy';
1414
import { deployImageApi } from './deploy/deployFromRegistry/deployImageApi';
1515
import { disableIngress } from './ingress/disableIngress';
1616
import { editTargetPort } from './ingress/editTargetPort';
@@ -31,7 +31,7 @@ export function registerCommands(): void {
3131
// container apps
3232
registerCommandWithTreeNodeUnwrapping('containerApps.createContainerApp', createContainerApp);
3333
registerCommandWithTreeNodeUnwrapping('containerApps.deleteContainerApp', deleteContainerApp);
34-
registerCommandWithTreeNodeUnwrapping('containerApps.deployImage', deployFromRegistry);
34+
registerCommandWithTreeNodeUnwrapping('containerApps.deploy', deploy);
3535
registerCommandWithTreeNodeUnwrapping('containerApps.deployImageApi', deployImageApi);
3636
registerCommandWithTreeNodeUnwrapping('containerApps.openConsoleInPortal', openConsoleInPortal);
3737
registerCommandWithTreeNodeUnwrapping('containerApps.browse', browseContainerAppNode);

0 commit comments

Comments
 (0)