Skip to content

Commit 0b18790

Browse files
Merge master into feature/emr
2 parents 770c3a3 + c1b76df commit 0b18790

File tree

7 files changed

+37
-21
lines changed

7 files changed

+37
-21
lines changed

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,6 @@ export async function runDeploy(arg: any, wizardParams?: DeployParams): Promise<
377377
throw ToolkitError.chain(error, 'Failed to build SAM template', { details: { ...buildFlags } })
378378
}
379379

380-
// Pass built template to deployFlags
381-
const templatePath = vscode.Uri.joinPath(params.projectRoot, '.aws-sam', 'build', 'template.yaml').fsPath
382-
deployFlags.push('--template-file', `${templatePath}`)
383-
384380
// Create a child process to run the SAM deploy command
385381
const deployProcess = new ChildProcess(samCliPath, ['deploy', ...deployFlags], {
386382
spawnOptions: await addTelemetryEnvVar({

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/deploy.test.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -709,8 +709,6 @@ describe('SAM Deploy', () => {
709709
'--parameter-overrides',
710710
`ParameterKey=SourceBucketName,ParameterValue=${mockDeployParams.SourceBucketName} ` +
711711
`ParameterKey=DestinationBucketName,ParameterValue=${mockDeployParams.DestinationBucketName}`,
712-
'--template-file',
713-
vscode.Uri.joinPath(projectRoot, '.aws-sam', 'build', 'template.yaml').fsPath,
714712
],
715713
{
716714
spawnOptions: {
@@ -787,8 +785,6 @@ describe('SAM Deploy', () => {
787785
'--parameter-overrides',
788786
`ParameterKey=SourceBucketName,ParameterValue=${mockDeployParams.SourceBucketName} ` +
789787
`ParameterKey=DestinationBucketName,ParameterValue=${mockDeployParams.DestinationBucketName}`,
790-
'--template-file',
791-
vscode.Uri.joinPath(projectRoot, '.aws-sam', 'build', 'template.yaml').fsPath,
792788
],
793789
{
794790
spawnOptions: {
@@ -867,8 +863,6 @@ describe('SAM Deploy', () => {
867863
'--parameter-overrides',
868864
`ParameterKey=SourceBucketName,ParameterValue=${mockDeployParams.SourceBucketName} ` +
869865
`ParameterKey=DestinationBucketName,ParameterValue=${mockDeployParams.DestinationBucketName}`,
870-
'--template-file',
871-
vscode.Uri.joinPath(projectRoot, '.aws-sam', 'build', 'template.yaml').fsPath,
872866
],
873867
{
874868
spawnOptions: {

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)

packages/core/src/testInteg/sam.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -883,8 +883,6 @@ describe('SAM Integration Tests', async function () {
883883
'--capabilities',
884884
'CAPABILITY_IAM',
885885
'CAPABILITY_NAMED_IAM',
886-
'--template-file',
887-
vscode.Uri.joinPath(mockDeployParams.projectRoot, '.aws-sam', 'build', 'template.yaml').fsPath,
888886
])
889887

890888
// Check that runInTerminal is called with the correct arguments for deploy
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: Save SAM deploy parameters to correct samconfig.toml in project folder"
4+
}
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)