|
3 | 3 | * Licensed under the MIT License. See License.txt in the project root for license information. |
4 | 4 | *--------------------------------------------------------------------------------------------*/ |
5 | 5 |
|
6 | | -import { GitHubBranchListStep, GitHubOrgListStep, GitHubRepositoryListStep } from "@microsoft/vscode-azext-github"; |
7 | | -import { AzureWizard, AzureWizardExecuteStep, AzureWizardPromptStep, ITreeItemPickerContext, createSubscriptionContext } from "@microsoft/vscode-azext-utils"; |
8 | | -import type { ContainerAppItem } from "../../../tree/ContainerAppItem"; |
9 | | -import { createActivityContext } from "../../../utils/activityUtils"; |
| 6 | +import { ITreeItemPickerContext, createSubscriptionContext, openUrl } from "@microsoft/vscode-azext-utils"; |
| 7 | +import type { ContainerAppItem, ContainerAppModel } from "../../../tree/ContainerAppItem"; |
| 8 | +import { createPortalUrl } from "../../../utils/createPortalUrl"; |
10 | 9 | import { localize } from "../../../utils/localize"; |
11 | 10 | import { pickContainerApp } from "../../../utils/pickContainerApp"; |
12 | | -import { AcrListStep } from "../../deployImage/imageSource/containerRegistry/acr/AcrListStep"; |
13 | | -import { AcrRepositoriesListStep } from "../../deployImage/imageSource/containerRegistry/acr/AcrRepositoriesListStep"; |
14 | | -import { DockerfileLocationInputStep } from "./DockerfileLocationInputStep"; |
15 | | -import { GitHubRepositoryConnectStep } from "./GitHubRepositoryConnectStep"; |
16 | | -import type { IConnectToGitHubContext } from "./IConnectToGitHubContext"; |
17 | | -import { ServicePrincipalIdInputStep } from "./ServicePrincipalIdInputStep"; |
18 | | -import { ServicePrincipalSecretInputStep } from "./ServicePrincipalSecretInputStep"; |
| 11 | +import { IContainerAppContext } from "../../IContainerAppContext"; |
19 | 12 | import { isGitHubConnected } from "./isGitHubConnected"; |
20 | 13 |
|
21 | | -export async function connectToGitHub(context: ITreeItemPickerContext & Partial<IConnectToGitHubContext>, item?: Pick<ContainerAppItem, 'containerApp' | 'subscription'>): Promise<void> { |
| 14 | +export async function connectToGitHub(context: ITreeItemPickerContext, item?: Pick<ContainerAppItem, 'containerApp' | 'subscription'>): Promise<void> { |
22 | 15 | if (!item) { |
23 | 16 | context.suppressCreatePick = true; |
24 | 17 | item = await pickContainerApp(context); |
25 | 18 | } |
26 | 19 |
|
27 | 20 | const { subscription, containerApp } = item; |
28 | 21 |
|
29 | | - const wizardContext: IConnectToGitHubContext = { |
| 22 | + // Make containerApp _required_ |
| 23 | + const containerAppContext: IContainerAppContext & { containerApp: ContainerAppModel } = { |
30 | 24 | ...context, |
31 | 25 | ...createSubscriptionContext(subscription), |
32 | | - ...await createActivityContext(), |
33 | 26 | subscription, |
34 | | - containerApp, |
| 27 | + containerApp |
35 | 28 | }; |
36 | 29 |
|
37 | | - if (await isGitHubConnected(wizardContext)) { |
| 30 | + if (await isGitHubConnected(containerAppContext)) { |
38 | 31 | throw new Error(localize('gitHubAlreadyConnected', '"{0}" is already connected to a GitHub repository.', containerApp.name)); |
39 | 32 | } |
40 | 33 |
|
41 | | - const title: string = localize('connectGitHubRepository', 'Connect a GitHub repository to "{0}"', containerApp.name); |
42 | | - |
43 | | - const promptSteps: AzureWizardPromptStep<IConnectToGitHubContext>[] = [ |
44 | | - new GitHubOrgListStep(), |
45 | | - new GitHubRepositoryListStep(), |
46 | | - new GitHubBranchListStep(), |
47 | | - new DockerfileLocationInputStep(), |
48 | | - new AcrListStep(), |
49 | | - new AcrRepositoriesListStep(), |
50 | | - new ServicePrincipalIdInputStep(), |
51 | | - new ServicePrincipalSecretInputStep() |
52 | | - ]; |
53 | | - |
54 | | - const executeSteps: AzureWizardExecuteStep<IConnectToGitHubContext>[] = [ |
55 | | - new GitHubRepositoryConnectStep() |
56 | | - ]; |
57 | | - |
58 | | - const wizard: AzureWizard<IConnectToGitHubContext> = new AzureWizard(wizardContext, { |
59 | | - title, |
60 | | - promptSteps, |
61 | | - executeSteps, |
62 | | - showLoadingPrompt: true |
63 | | - }); |
64 | | - |
65 | | - await wizard.prompt(); |
66 | | - await wizard.execute(); |
| 34 | + /** |
| 35 | + * VS Code does not have sufficient scopes to handle CRUD on service principals & federated credentials. |
| 36 | + * Bump users to the portal to avoid providing an incomplete/partial connection experience. |
| 37 | + */ |
| 38 | + const portalUrl: string = createPortalUrl(subscription, `${containerApp.id}/continuousDeployment`).toString(true /** skipEncoding */); |
| 39 | + await openUrl(portalUrl); |
67 | 40 | } |
0 commit comments