Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(lambda): download serverless land patterns in IDE #6612

Open
wants to merge 5 commits into
base: feature/serverlessland
Choose a base branch
from

Conversation

Vandita2020
Copy link
Contributor

@Vandita2020 Vandita2020 commented Feb 18, 2025

Problem

This pull request introduces the functionality to allow users to download the selected pattern from the Serverless Land QuickPick flow into a directory of their choice.

Solution

The key changes made are as follows:

  1. The metadata.json file was updated to accommodate the addition of an asset_name field for each IaC and Runtime pair.
  2. Consequently, the way the metadata is extracted in the metadataManager.ts file had to be modified to account for these changes in the metadata.json file.
  3. To enable users to navigate back to the previous QuickPick options, a switch functionality was implemented in the wizard.ts file. This helps maintain the state of the current QuickPick and directs the user to the previous QuickPick.

  • Treat all work as PUBLIC. Private feature/x branches will not be squash-merged at release time.
  • Your code changes must meet the guidelines in CONTRIBUTING.md.
  • License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link

  • This pull request modifies code in src/* but no tests were added/updated.
    • Confirm whether tests should be added or ensure the PR description explains why tests are not required.

@Vandita2020 Vandita2020 force-pushed the download_code branch 5 times, most recently from a20965f to 1e35324 Compare February 20, 2025 20:52
@Vandita2020 Vandita2020 changed the title Download code feat(lambda): download serverless patterns in IDE Feb 20, 2025
@Vandita2020 Vandita2020 marked this pull request as ready for review February 20, 2025 21:43
@Vandita2020 Vandita2020 requested a review from a team as a code owner February 20, 2025 21:43
Copy link
Member

@roger-zhangg roger-zhangg left a comment

Choose a reason for hiding this comment

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

Questions in Wizard part, also please add test

}).run()
}

async function downloadPatternCode(config: CreateServerlessLandWizardForm): Promise<void> {
Copy link
Member

Choose a reason for hiding this comment

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

Seems you are providing a Official Serverless Land experience here, could you help to update the Download SL logic I have in walkthrough to use your logic here?

Copy link
Contributor

Choose a reason for hiding this comment

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

If this is going to be used in other places as well, I suggest bringing these function outside of main.py and into another file in this folder for readability.

if (patterns.length === 0) {
throw new ToolkitError('No patterns found in metadata')
}
let step = 'pattern'
Copy link
Member

@roger-zhangg roger-zhangg Feb 20, 2025

Choose a reason for hiding this comment

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

for line 40, IMO we should avoid public override async run(): when possible. Just put all the async prework out of the wizard. the override async run() has cause difficulties in testing as my experience.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The code has been simplified, and the logic that was previously executed within the public override async run() method has been moved to the public constructor. No longer need to override the run() function.

@Vandita2020 Vandita2020 changed the title feat(lambda): download serverless patterns in IDE feat(lambda): download serverless land patterns in IDE Feb 20, 2025
Copy link

  • This pull request modifies code in src/* but no tests were added/updated.
    • Confirm whether tests should be added or ensure the PR description explains why tests are not required.
  • This pull request implements a feat or fix, so it must include a changelog entry (unless the fix is for an unreleased feature). Review the changelog guidelines.
    • Note: beta or "experiment" features that have active users should announce fixes in the changelog.
    • If this is not a feature or fix, use an appropriate type from the title guidelines. For example, telemetry-only changes should use the telemetry type.

credentials,
defaultRegion,
}).run()
const config = await launchProjectCreationWizard(extContext)
if (!config) {
createResult = 'Cancelled'
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the the purpose behind setting value to these two local variables right before returning?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The two values will be emitted in the telemetry, within the finally block of the try-catch statement.

}).run()
}

async function downloadPatternCode(config: CreateServerlessLandWizardForm): Promise<void> {
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is going to be used in other places as well, I suggest bringing these function outside of main.py and into another file in this folder for readability.

})
const iacOptions = this.metadataManager.getIacOptions(pattern)
if (iacOptions.length === 0) {
throw new Error('No IAC options found for the selected pattern')
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a blocker but we should utilize localize() function instead of hard coding.Example:

localize('AWS.command.launchConfigForm.title', 'Local Invoke and Debug Configuration')

AWS.command.launchConfigForm.title

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants