Skip to content

Commit ef048bb

Browse files
committed
skip ecrRepoUri and syncFlags prompters when samconfig file used for sync
1 parent d660430 commit ef048bb

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-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)

0 commit comments

Comments
 (0)