-
Notifications
You must be signed in to change notification settings - Fork 149
Add support for creating functions projects with dockerfiles #3929
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 from 1 commit
150711e
5f887e8
d546af2
e5ef6e0
00b9f09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. See License.md in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| import { ext } from "@microsoft/vscode-azext-serviceconnector"; | ||
| import { AzureWizardExecuteStep, UserCancelledError, nonNullValueAndProp } from "@microsoft/vscode-azext-utils"; | ||
| import { validateFuncCoreToolsInstalled } from "../../../funcCoreTools/validateFuncCoreToolsInstalled"; | ||
| import { localize } from "../../../localize"; | ||
| import { cpUtils } from "../../../utils/cpUtils"; | ||
| import { type IDockerfileProjectContext } from "./IDockerfileProjectContext"; | ||
|
|
||
| export class CreateDockerfileProjectStep extends AzureWizardExecuteStep<IDockerfileProjectContext>{ | ||
| public priority: number = 100; | ||
|
|
||
| public async execute(context: IDockerfileProjectContext): Promise<void> { | ||
| const message: string = localize('installFuncTools', 'You must have the Azure Functions Core Tools installed to run this command.'); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mentioned this in another PR, but you should front-load this error. Nothing more annoying than going through a project wizard and then having it fail right at the end. |
||
| if (!await validateFuncCoreToolsInstalled(context, message, context.workspacePath)) { | ||
| throw new UserCancelledError('validateFuncCoreToolsInstalled'); | ||
| } | ||
|
|
||
| await cpUtils.executeCommand(ext.outputChannel, nonNullValueAndProp(context, 'projectPath'), "func", "init", "--worker-runtime", nonNullValueAndProp(context, 'projectLanguage'), "--docker"); | ||
| } | ||
|
|
||
| public shouldExecute(): boolean { | ||
| return true; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. See License.md in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| import { AzureWizardPromptStep, type IAzureQuickPickItem } from "@microsoft/vscode-azext-utils"; | ||
| import { ProjectLanguage } from "../../../constants"; | ||
| import { type IDockerfileProjectContext } from "./IDockerfileProjectContext"; | ||
|
|
||
| export class DockerfileProjectLanguageStep extends AzureWizardPromptStep<IDockerfileProjectContext> { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could probably just use the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did think about that but the data property in the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually update since I am not using the NewProjectLanguageStep I don't think I can use the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah but you should be able to just change the type instead of using a string.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at this more, I think we should just speak offline about this. |
||
| public async prompt(context: IDockerfileProjectContext): Promise<void> { | ||
| const language: IAzureQuickPickItem<string>[] = [ | ||
| { label: ProjectLanguage.JavaScript, data: 'node' }, | ||
|
MicroFish91 marked this conversation as resolved.
Outdated
|
||
| { label: ProjectLanguage.TypeScript, data: 'typescript' }, | ||
| { label: ProjectLanguage.Python, data: 'python' }, | ||
| { label: ProjectLanguage.CSharp, data: 'csharp' }, | ||
| { label: ProjectLanguage.PowerShell, data: 'powershell' }, | ||
| ]; | ||
|
|
||
| context.projectLanguage = (await context.ui.showQuickPick(language, { placeHolder: 'Select a language' })).data; | ||
| } | ||
|
|
||
| public shouldPrompt(context: IDockerfileProjectContext): boolean { | ||
| return !context.projectLanguage; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. See License.md in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| import { type ExecuteActivityContext, type IActionContext } from "@microsoft/vscode-azext-utils"; | ||
| import { type IProjectWizardContext } from "../IProjectWizardContext"; | ||
|
|
||
| export interface IDockerfileProjectContext extends IActionContext, ExecuteActivityContext, IProjectWizardContext { | ||
| projectLanguage?: string; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 { AzureWizard, type IActionContext } from "@microsoft/vscode-azext-utils"; | ||
| import { localize } from "../../../localize"; | ||
| import { createActivityContext } from "../../../utils/activityUtils"; | ||
| import { FolderListStep } from "../FolderListStep"; | ||
| import { type IProjectWizardContext } from "../IProjectWizardContext"; | ||
| import { OpenBehaviorStep } from "../OpenBehaviorStep"; | ||
| import { OpenFolderStep } from "../OpenFolderStep"; | ||
| import { CreateDockerfileProjectStep } from "./CreateDockerfileProjectStep"; | ||
| import { DockerfileProjectLanguageStep } from "./DockefileProjectLanguageStep"; | ||
| import { type IDockerfileProjectContext } from "./IDockerfileProjectContext"; | ||
|
|
||
| export async function createNewProjectWithDockerfile(context: IActionContext): Promise<void> { | ||
| const wizardContext: Partial<IDockerfileProjectContext> & Partial<IProjectWizardContext> & IActionContext = { | ||
| ...context, | ||
| ...(await createActivityContext()) | ||
| } | ||
|
|
||
| const wizard: AzureWizard<IDockerfileProjectContext> = new AzureWizard(wizardContext, { | ||
| title: localize('createNewProject', 'Create new project with dockerfile'), | ||
| promptSteps: [new FolderListStep(), new DockerfileProjectLanguageStep(), new OpenBehaviorStep()], | ||
| executeSteps: [new CreateDockerfileProjectStep(), new OpenFolderStep()] | ||
| }); | ||
|
|
||
| wizardContext.activityTitle = localize('createNewDockerfileProject', 'Create new project with dockerfile'); | ||
|
|
||
| await wizard.prompt(); | ||
| await wizard.execute(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should call it
Create New Containerized Project...?I don't have a strong preference, but the learn document does refer to it as a containerized function app.
https://learn.microsoft.com/en-us/azure/azure-functions/functions-deploy-container?tabs=acr%2Cbash%2Cazure-cli&pivots=programming-language-javascript