Skip to content

Commit c33af44

Browse files
committed
update support for enVar in the webview
1 parent 2837d80 commit c33af44

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

packages/core/src/awsService/appBuilder/explorer/samProject.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ export interface ResourceTreeEntity {
3030
Events?: ResourceTreeEntity[]
3131
Path?: string
3232
Method?: string
33+
Environment?: {
34+
Variables: Record<string, any>
35+
}
3336
}
3437

3538
export async function getStackName(projectRoot: vscode.Uri): Promise<any> {
@@ -81,10 +84,12 @@ function getResourceEntity(template: any): ResourceTreeEntity[] {
8184
Handler: resource.Properties?.Handler ?? template?.Globals?.Function?.Handler,
8285
Events: resource.Properties?.Events ? getEvents(resource.Properties.Events) : undefined,
8386
CodeUri: resource.Properties?.CodeUri ?? template?.Globals?.Function?.CodeUri,
87+
Environment: resource.Properties?.Environment
88+
? resource.Properties?.Environment
89+
: template?.Globals?.Function?.Environment,
8490
}
8591
resourceTree.push(resourceEntity)
8692
}
87-
8893
return resourceTree
8994
}
9095

packages/core/src/lambda/vue/configEditor/samInvokeBackend.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ export interface ResourceData {
4646
runtime: string
4747
stackName: string
4848
source: string
49+
environment?: {
50+
Variables: Record<string, any>
51+
}
4952
}
5053

5154
export type AwsSamDebuggerConfigurationLoose = AwsSamDebuggerConfiguration & {
@@ -441,6 +444,7 @@ export async function registerSamDebugInvokeVueCommand(
441444
runtime: resource.resource.Runtime!,
442445
arn: resource.functionArn ?? '',
443446
stackName: resource.stackName ?? '',
447+
environment: resource.resource.Environment ?? undefined,
444448
source: source,
445449
})
446450
await telemetry.sam_openConfigUi.run(async (span) => {

packages/core/src/lambda/vue/configEditor/samInvokeFrontend.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,11 @@ export default defineComponent({
345345
this.launchConfig.invokeTarget.lambdaHandler = this.resourceData.handler
346346
if (this.launchConfig.lambda) {
347347
this.launchConfig.lambda.runtime = this.resourceData.runtime
348+
if (this.resourceData.environment?.Variables !== undefined) {
349+
this.environmentVariables.value = JSON.stringify(
350+
this.resourceData.environment?.Variables
351+
)
352+
}
348353
}
349354
}
350355
},

packages/core/src/test/lambda/vue/samInvokeBackend.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,9 @@ describe('SamInvokeWebview', () => {
728728
},
729729
lambda: {
730730
runtime: 'python3.9',
731+
environmentVariables: {
732+
PARAM1: 'VALUE',
733+
},
731734
},
732735
sam: {
733736
containerBuild: false,

0 commit comments

Comments
 (0)