Organize terraform attributes when serializing#10145
Conversation
### Description Update the Terraform serializer to sort attributes into meta-arguments, non-block parameters, and block parameters, with spaces between categories. ### Scenarios Tested None (node/npm not available in agent path) ### Sample Commands npx mocha src/functions/iac/terraform.spec.ts
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request lays the groundwork for exporting Firebase Cloud Functions configurations as Infrastructure as Code (IaC). It introduces a new command to facilitate this export, alongside robust utilities for generating Terraform HCL. The primary goal is to produce structured, readable, and consistent IaC output, which is crucial for automated testing and maintaining configuration clarity. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new functions:export command and the underlying machinery to generate Infrastructure as Code (IaC), including an internal YAML format and helpers for Terraform. The logic for serializing Terraform attributes in an organized, deterministic manner in src/functions/iac/terraform.ts is well-implemented and tested. The main area for improvement is strengthening the TypeScript types by avoiding the any type for options objects in the new command and exporter functions, which goes against the repository's style guide.
I am having trouble creating individual review comments. Click here to see my feedback.
src/commands/functions-export.ts (19)
The options parameter is typed as any, which violates the repository's style guide rule against using any. Please provide a more specific type for the command's options to improve type safety and code clarity. While the suggested change still uses any for some properties, it's a step towards better typing by specifying the known properties.
.action(async (options: { format: string; codebase?: string; config: any; [key: string]: any }) => {
References
- The style guide states to 'Never use
anyorunknownas an escape hatch. Define proper interfaces/types or use type guards.' (link)
src/functions/iac/export.ts (12)
The options parameter in the Exporter type is any. This violates the repository's style guide. Please use a more specific type that covers the properties used in getInternalIac. The suggested change is a step towards better typing, but ideally the index signature could be replaced with a more specific type (e.g. by extending the global Options type).
options: { config: { path: (s: string) => string; projectDir: string }; [key: string]: any },
References
- The style guide states to 'Never use
anyorunknownas an escape hatch. Define proper interfaces/types or use type guards.' (link)
src/functions/iac/export.ts (20)
The options parameter is typed as any, which violates the repository's style guide. Please use a more specific type. You can likely reuse the type defined for the Exporter.
options: { config: { path: (s: string) => string; projectDir: string }; [key: string]: any },
References
- The style guide states to 'Never use
anyorunknownas an escape hatch. Define proper interfaces/types or use type guards.' (link)
Makes output look more natural and creates a deterministic result for tests.