@@ -21,55 +21,59 @@ import type * as api from "./vscode-azurecontainerapps.api";
2121export async function deployWorkspaceProjectApi ( deployWorkspaceProjectOptions : api . DeployWorkspaceProjectOptionsContract ) : Promise < DeployWorkspaceProjectResults > {
2222 return await callWithTelemetryAndErrorHandling ( 'containerApps.api.deployWorkspaceProject' , async ( context : IActionContext ) : Promise < DeployWorkspaceProjectResults > => {
2323 context . errorHandling . rethrow = true ;
24+ return await deployWorkspaceProjectApiInternal ( context , deployWorkspaceProjectOptions ) ;
25+ } ) ?? { } ;
26+ }
2427
25- const {
26- resourceGroupId,
27- location,
28- rootPath,
29- dockerfilePath,
30- srcPath,
31- suppressConfirmation,
32- suppressContainerAppCreation,
33- shouldSaveDeploySettings
34- } = deployWorkspaceProjectOptions ;
28+ // Separated from `deployWorkspaceProjectApi` so tests can inject their own test action context
29+ export async function deployWorkspaceProjectApiInternal ( context : IActionContext , deployWorkspaceProjectOptions : api . DeployWorkspaceProjectOptionsContract ) : Promise < DeployWorkspaceProjectResults > {
30+ const {
31+ resourceGroupId,
32+ location,
33+ rootPath,
34+ dockerfilePath,
35+ srcPath,
36+ suppressConfirmation,
37+ suppressContainerAppCreation,
38+ shouldSaveDeploySettings
39+ } = deployWorkspaceProjectOptions ;
3540
36- const subscription : AzureSubscription = await subscriptionExperience ( context , ext . rgApiV2 . resources . azureResourceTreeDataProvider , {
37- selectBySubscriptionId : getSubscriptionIdFromOptions ( deployWorkspaceProjectOptions ) ,
38- showLoadingPrompt : false
39- } ) ;
40- const subscriptionContext : ISubscriptionContext = createSubscriptionContext ( subscription ) ;
41+ const subscription : AzureSubscription = await subscriptionExperience ( context , ext . rgApiV2 . resources . azureResourceTreeDataProvider , {
42+ selectBySubscriptionId : getSubscriptionIdFromOptions ( deployWorkspaceProjectOptions ) ,
43+ showLoadingPrompt : false
44+ } ) ;
45+ const subscriptionContext : ISubscriptionContext = createSubscriptionContext ( subscription ) ;
4146
42- const rootFolder : WorkspaceFolder | undefined = rootPath ? getWorkspaceFolderFromPath ( rootPath ) : undefined ;
43- const resourceGroup : ResourceGroup | undefined = resourceGroupId ? await getResourceGroupFromId ( { ...context , ...subscriptionContext } , resourceGroupId ) : undefined ;
47+ const rootFolder : WorkspaceFolder | undefined = rootPath ? getWorkspaceFolderFromPath ( rootPath ) : undefined ;
48+ const resourceGroup : ResourceGroup | undefined = resourceGroupId ? await getResourceGroupFromId ( { ...context , ...subscriptionContext } , resourceGroupId ) : undefined ;
4449
45- const deployWorkspaceProjectInternalContext : DeployWorkspaceProjectInternalContext = Object . assign ( context , {
46- ...subscriptionContext ,
47- subscription,
48- resourceGroup,
49- newManagedEnvironmentName : await tryGetNewManagedEnvironmentName ( { ...context , ...subscriptionContext } , resourceGroup ?. name , resourceGroup ?. name ) ,
50- rootFolder,
51- srcPath : srcPath ? Uri . file ( srcPath ) . fsPath : undefined ,
52- dockerfilePath : dockerfilePath ? Uri . file ( dockerfilePath ) . fsPath : undefined ,
53- newRegistryCredentialType : RegistryCredentialType . DockerLogin ,
54- shouldSaveDeploySettings : ! ! shouldSaveDeploySettings ,
55- } ) ;
50+ const deployWorkspaceProjectInternalContext : DeployWorkspaceProjectInternalContext = Object . assign ( context , {
51+ ...subscriptionContext ,
52+ subscription,
53+ resourceGroup,
54+ newManagedEnvironmentName : await tryGetNewManagedEnvironmentName ( { ...context , ...subscriptionContext } , resourceGroup ?. name , resourceGroup ?. name ) ,
55+ rootFolder,
56+ srcPath : srcPath ? Uri . file ( srcPath ) . fsPath : undefined ,
57+ dockerfilePath : dockerfilePath ? Uri . file ( dockerfilePath ) . fsPath : undefined ,
58+ newRegistryCredentialType : RegistryCredentialType . DockerLogin ,
59+ shouldSaveDeploySettings : ! ! shouldSaveDeploySettings ,
60+ } ) ;
5661
57- if ( location || deployWorkspaceProjectInternalContext . resourceGroup ) {
58- const autoSelectLocation = location ?? nonNullValueAndProp ( deployWorkspaceProjectInternalContext . resourceGroup , 'location' ) ;
59- await LocationListStep . setAutoSelectLocation ( deployWorkspaceProjectInternalContext , autoSelectLocation ) ;
60- }
62+ if ( location || deployWorkspaceProjectInternalContext . resourceGroup ) {
63+ const autoSelectLocation = location ?? nonNullValueAndProp ( deployWorkspaceProjectInternalContext . resourceGroup , 'location' ) ;
64+ await LocationListStep . setAutoSelectLocation ( deployWorkspaceProjectInternalContext , autoSelectLocation ) ;
65+ }
6166
62- const deployWorkspaceProjectContext : DeployWorkspaceProjectContext = await deployWorkspaceProjectInternal ( deployWorkspaceProjectInternalContext , {
63- advancedCreate : false ,
64- suppressActivity : true ,
65- suppressConfirmation,
66- suppressContainerAppCreation,
67- suppressProgress : true ,
68- suppressWizardTitle : true ,
69- } ) ;
67+ const deployWorkspaceProjectContext : DeployWorkspaceProjectContext = await deployWorkspaceProjectInternal ( deployWorkspaceProjectInternalContext , {
68+ advancedCreate : false ,
69+ suppressActivity : true ,
70+ suppressConfirmation,
71+ suppressContainerAppCreation,
72+ suppressProgress : true ,
73+ suppressWizardTitle : true ,
74+ } ) ;
7075
71- return await getDeployWorkspaceProjectResults ( deployWorkspaceProjectContext ) ;
72- } ) ?? { } ;
76+ return await getDeployWorkspaceProjectResults ( deployWorkspaceProjectContext ) ;
7377}
7478
7579async function tryGetNewManagedEnvironmentName ( context : ISubscriptionActionContext , resourceGroupName ?: string , newEnvironmentName ?: string ) : Promise < string | undefined > {
0 commit comments