-
Notifications
You must be signed in to change notification settings - Fork 476
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(lambda): template parameter prompter not available from all entry…
…points #6240 ## Problem SAM CLI guided deploy support template parameter override for both sync and deploy command. However, the AppBuilder wizard UI only support this feature for SAM deploy trigger from SAM template context menu or AppBuilder project node menu button. ## Solution - Implement nested wizard for template parameter for both sync and deploy action for all entry points. - Refactor DeployWizard class for consistency with SyncWizard class - Add unit test for validating correct backward flow and state restoration for both wizard.
- Loading branch information
Showing
9 changed files
with
987 additions
and
395 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
packages/core/src/awsService/appBuilder/wizards/templateParametersWizard.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/*! | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import * as vscode from 'vscode' | ||
import { Wizard } from '../../../shared/wizards/wizard' | ||
import { createExitPrompter } from '../../../shared/ui/common/exitPrompter' | ||
import * as CloudFormation from '../../../shared/cloudformation/cloudformation' | ||
import { createInputBox } from '../../../shared/ui/inputPrompter' | ||
import { createCommonButtons } from '../../../shared/ui/buttons' | ||
import { getRecentResponse, updateRecentResponse } from '../../../shared/sam/utils' | ||
import { getParameters } from '../../../lambda/config/parameterUtils' | ||
|
||
export interface TemplateParametersForm { | ||
[key: string]: any | ||
} | ||
|
||
export class TemplateParametersWizard extends Wizard<TemplateParametersForm> { | ||
template: vscode.Uri | ||
preloadedTemplate: CloudFormation.Template | undefined | ||
samTemplateParameters: Map<string, { required: boolean }> | undefined | ||
samCommandUrl: vscode.Uri | ||
commandMementoRootKey: string | ||
|
||
public constructor(template: vscode.Uri, samCommandUrl: vscode.Uri, commandMementoRootKey: string) { | ||
super({ exitPrompterProvider: createExitPrompter }) | ||
this.template = template | ||
this.samCommandUrl = samCommandUrl | ||
this.commandMementoRootKey = commandMementoRootKey | ||
} | ||
|
||
public override async init(): Promise<this> { | ||
this.samTemplateParameters = await getParameters(this.template) | ||
this.preloadedTemplate = await CloudFormation.load(this.template.fsPath) | ||
const samTemplateNames = new Set<string>(this.samTemplateParameters?.keys() ?? []) | ||
|
||
samTemplateNames.forEach((name) => { | ||
if (this.preloadedTemplate) { | ||
const defaultValue = this.preloadedTemplate.Parameters | ||
? (this.preloadedTemplate.Parameters[name]?.Default as string) | ||
: undefined | ||
this.form[name].bindPrompter(() => | ||
this.createParamPromptProvider(name, defaultValue).transform(async (item) => { | ||
await updateRecentResponse(this.commandMementoRootKey, this.template.fsPath, name, item) | ||
return item | ||
}) | ||
) | ||
} | ||
}) | ||
|
||
return this | ||
} | ||
|
||
createParamPromptProvider(name: string, defaultValue: string | undefined) { | ||
return createInputBox({ | ||
title: `Specify SAM Template parameter value for ${name}`, | ||
buttons: createCommonButtons(this.samCommandUrl), | ||
value: getRecentResponse(this.commandMementoRootKey, this.template.fsPath, name) ?? defaultValue, | ||
}) | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.