Skip to content

Commit 65d0e93

Browse files
authored
fix(lambda): skip ecrRepoUri, syncFlags prompts if provided by samconfig.toml #5913
## Problem When customer choose use flag information from `samconfig.toml` for sync and deploy operations, we assume that all the needed parameters will be available in the `samconfig.toml`. Only `--config-file <samconfig file path>` is passed to SAM CLI. We skip many prompters in such scenario reduce clicking. Yet, we also need to skip prompter for `ecrRepoUri` and `syncFlag` in sync wizard. ## Solution Add condition to skip these prompter when flag information from `samconfig.toml` is used.
1 parent 0d7d7e3 commit 65d0e93

File tree

3 files changed

+33
-9
lines changed

3 files changed

+33
-9
lines changed

packages/core/src/shared/sam/sync.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -354,16 +354,24 @@ export class SyncWizard extends Wizard<SyncParams> {
354354
})
355355

356356
this.form.ecrRepoUri.bindPrompter(({ region }) => createEcrPrompter(new DefaultEcrClient(region!)), {
357-
showWhen: ({ template }) => !!template && hasImageBasedResources(template.data),
357+
showWhen: ({ template, paramsSource }) =>
358+
!!template &&
359+
hasImageBasedResources(template.data) &&
360+
(paramsSource === ParamsSource.Flags || paramsSource === ParamsSource.SpecifyAndSave),
358361
})
359362

360363
// todo wrap with localize
361-
this.form.syncFlags.bindPrompter(() =>
362-
createMultiPick(syncFlagItems, {
363-
title: 'Specify parameters for sync',
364-
placeholder: 'Press enter to proceed with highlighted option',
365-
buttons: createCommonButtons(samSyncParamUrl),
366-
})
364+
this.form.syncFlags.bindPrompter(
365+
() =>
366+
createMultiPick(syncFlagItems, {
367+
title: 'Specify parameters for sync',
368+
placeholder: 'Press enter to proceed with highlighted option',
369+
buttons: createCommonButtons(samSyncParamUrl),
370+
}),
371+
{
372+
showWhen: ({ paramsSource }) =>
373+
paramsSource === ParamsSource.Flags || paramsSource === ParamsSource.SpecifyAndSave,
374+
}
367375
)
368376
}
369377
}

packages/core/src/test/shared/sam/sync.test.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,14 @@ describe('SyncWizard', async function () {
105105
})
106106

107107
it('prompts for ECR repo if template has image-based resource', async function () {
108-
const template = { uri: vscode.Uri.file('/'), data: createBaseImageTemplate() }
109-
const tester = await createTester({ template })
108+
const workspaceUri = vscode.workspace.workspaceFolders?.[0]?.uri || vscode.Uri.file('/')
109+
const rootFolderUri = vscode.Uri.joinPath(workspaceUri, 'my')
110+
const templateUri = vscode.Uri.joinPath(rootFolderUri, 'template.yaml')
111+
const template = { uri: templateUri, data: createBaseImageTemplate() }
112+
const tester = await createTester({
113+
template,
114+
paramsSource: ParamsSource.Flags,
115+
})
110116
tester.ecrRepoUri.assertShow()
111117
})
112118

@@ -116,6 +122,12 @@ describe('SyncWizard', async function () {
116122
tester.ecrRepoUri.assertDoesNotShow()
117123
})
118124

125+
it('skips prompt for ECR repo if param source is to use samconfig', async function () {
126+
const template = { uri: vscode.Uri.file('/'), data: createBaseTemplate() }
127+
const tester = await createTester({ template, paramsSource: ParamsSource.SamConfig })
128+
tester.ecrRepoUri.assertDoesNotShow()
129+
})
130+
119131
it("uses the template's workspace subfolder as the project root is not set", async function () {
120132
const workspaceUri = vscode.workspace.workspaceFolders?.[0]?.uri
121133
assert.ok(workspaceUri)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "SAM: Skip unnecessary prompters for sync operation when using flag from samconfig.toml file"
4+
}

0 commit comments

Comments
 (0)