Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions packages/core/src/shared/sam/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,16 +354,24 @@ export class SyncWizard extends Wizard<SyncParams> {
})

this.form.ecrRepoUri.bindPrompter(({ region }) => createEcrPrompter(new DefaultEcrClient(region!)), {
showWhen: ({ template }) => !!template && hasImageBasedResources(template.data),
showWhen: ({ template, paramsSource }) =>
!!template &&
hasImageBasedResources(template.data) &&
(paramsSource === ParamsSource.Flags || paramsSource === ParamsSource.SpecifyAndSave),
})

// todo wrap with localize
this.form.syncFlags.bindPrompter(() =>
createMultiPick(syncFlagItems, {
title: 'Specify parameters for sync',
placeholder: 'Press enter to proceed with highlighted option',
buttons: createCommonButtons(samSyncParamUrl),
})
this.form.syncFlags.bindPrompter(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be syncFlags if we skipped here? Will it be empty?

Copy link
Contributor Author

@vicheey vicheey Nov 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that what we discussed last time.
When the customer use samconfig file, we use all the flag values from the file; this mean, we would use --config-file as mention here. The based on the value, the boundArgs is loaded here. We do not need the sync flags for merging with boundArgs here because again, --config-file is used.

Please let me know if there is issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I mean is, are the sync flags actually empty if they are skipped. Could you help to confirm?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, confirm that it is an empty array

() =>
createMultiPick(syncFlagItems, {
title: 'Specify parameters for sync',
placeholder: 'Press enter to proceed with highlighted option',
buttons: createCommonButtons(samSyncParamUrl),
}),
{
showWhen: ({ paramsSource }) =>
paramsSource === ParamsSource.Flags || paramsSource === ParamsSource.SpecifyAndSave,
}
)
}
}
Expand Down
16 changes: 14 additions & 2 deletions packages/core/src/test/shared/sam/sync.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,14 @@ describe('SyncWizard', async function () {
})

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

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

it('skips prompt for ECR repo if param source is to use samconfig', async function () {
const template = { uri: vscode.Uri.file('/'), data: createBaseTemplate() }
const tester = await createTester({ template, paramsSource: ParamsSource.SamConfig })
tester.ecrRepoUri.assertDoesNotShow()
})

it("uses the template's workspace subfolder as the project root is not set", async function () {
const workspaceUri = vscode.workspace.workspaceFolders?.[0]?.uri
assert.ok(workspaceUri)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Bug Fix",
"description": "SAM: Skip unnecessary prompters for sync operation when using flag from samconfig.toml file"
}
Loading