Skip to content

Commit

Permalink
fix(appbuilder): misleading placeholder message aws#6010
Browse files Browse the repository at this point in the history
## Problem
I was working on a CDK project, and after synthesizing my CDK template,
I noticed that the app-builder is showing a misleading notification to
customers: No IaC templates found in the workspace. This seems
incorrect, as I do have IaC templates in the workspace, including both
raw and synthesized CDK templates.

While I understand the intention behind the message, it needs to be more
precise to avoid confusion. I suggest we roll it back to something more
accurate, like No SAM templates found in the workspace, to clearly
indicate the specific missing template type.

## Solution
Solution is to change all instance where IAC is mentioned to the
customer to SAM, we would roll back to IaC once we start support CDK.

Remove redundant Logic.
  • Loading branch information
jonife authored Nov 14, 2024
1 parent 4d8932e commit 4531668
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 17 deletions.
15 changes: 2 additions & 13 deletions packages/core/src/awsService/appBuilder/explorer/nodes/appNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { getSamCliContext } from '../../../../shared/sam/cli/samCliContext'
import { SamCliListResourcesParameters } from '../../../../shared/sam/cli/samCliListResources'
import { getDeployedResources, StackResource } from '../../../../lambda/commands/listSamResources'
import * as path from 'path'
import fs from '../../../../shared/fs/fs'
import { generateStackNode } from './deployedStack'

export class AppNode implements TreeNode {
Expand Down Expand Up @@ -61,19 +60,9 @@ export class AppNode implements TreeNode {

// indicate that App exists, but it is empty
if (resources.length === 0) {
if (await fs.exists(this.location.samTemplateUri)) {
return [
createPlaceholderItem(
localize(
'AWS.appBuilder.explorerNode.app.noResource',
'[No resource found in IaC template]'
)
),
]
}
return [
createPlaceholderItem(
localize('AWS.appBuilder.explorerNode.app.noTemplate', '[No IaC templates found in Workspaces]')
localize('AWS.appBuilder.explorerNode.app.noResource', '[No resource found in SAM template]')
),
]
}
Expand All @@ -84,7 +73,7 @@ export class AppNode implements TreeNode {
createPlaceholderItem(
localize(
'AWS.appBuilder.explorerNode.app.noResourceTree',
'[Unable to load Resource tree for this App. Update IaC template]'
'[Unable to load Resource tree for this App. Update SAM template]'
)
),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export async function getAppNodes(): Promise<TreeNode[]> {
if (appsFound.length === 0) {
return [
createPlaceholderItem(
localize('AWS.appBuilder.explorerNode.noApps', '[No IaC templates found in Workspaces]')
localize('AWS.appBuilder.explorerNode.noApps', '[No SAM templates found in Workspaces]')
),
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('AppNode', () => {

const resourceNode = resources[0] as TreeNode
assert.strictEqual(resourceNode.id, 'placeholder')
assert.strictEqual(resourceNode.resource, '[No IaC templates found in Workspaces]')
assert.strictEqual(resourceNode.resource, '[No resource found in SAM template]')
assert(getAppStub.calledOnce)
assert(getStackNameStub.calledOnce)
assert(generateStackNodeStub.notCalled)
Expand Down Expand Up @@ -157,7 +157,7 @@ describe('AppNode', () => {
assert.strictEqual(resourceNode.id, 'placeholder')
assert.strictEqual(
resourceNode.resource,
'[Unable to load Resource tree for this App. Update IaC template]'
'[Unable to load Resource tree for this App. Update SAM template]'
)
assert(getAppStub.calledOnce)
assert(getStackNameStub.notCalled)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('getAppNodes', async () => {
const appNodes = await getAppNodes()
assert.strictEqual(appNodes.length, 1)
assert.strictEqual(appNodes[0].id, 'placeholder')
assert.strictEqual(appNodes[0].resource, '[No IaC templates found in Workspaces]')
assert.strictEqual(appNodes[0].resource, '[No SAM templates found in Workspaces]')
})

it('should return all SAM projects as AppNode', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Bug Fix",
"description": "SAM debugging: misleading 'IaC' message/placeholder"
}

0 comments on commit 4531668

Please sign in to comment.