Skip to content

Organize terraform attributes when serializing#10145

Draft
inlined wants to merge 9 commits intomainfrom
inlined.iac.2.5-pretty-print
Draft

Organize terraform attributes when serializing#10145
inlined wants to merge 9 commits intomainfrom
inlined.iac.2.5-pretty-print

Conversation

@inlined
Copy link
Member

@inlined inlined commented Mar 21, 2026

Makes output look more natural and creates a deterministic result for tests.

inlined added 8 commits March 17, 2026 11:56
### 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
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 functions:export command: Introduced a new command to export Cloud Functions code and configuration, initially supporting an internal YAML format.
  • Terraform HCL Serialization Utilities: Added a comprehensive set of utilities for generating and serializing Terraform HCL, focusing on organizing attributes for natural-looking and deterministic output.
  • Experiment Flag for IaC Features: Implemented a new experiment flag, functionsiac, to control the availability of the new Infrastructure as Code (IaC) export capabilities.
  • Attribute Organization in Terraform Output: Enhanced Terraform HCL serialization to sort attributes within resource blocks into logical categories (meta-arguments, non-block parameters, and other blocks) and add spacing for improved readability and deterministic results.

🧠 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 Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

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)

medium

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
  1. The style guide states to 'Never use any or unknown as an escape hatch. Define proper interfaces/types or use type guards.' (link)

src/functions/iac/export.ts (12)

medium

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
  1. The style guide states to 'Never use any or unknown as an escape hatch. Define proper interfaces/types or use type guards.' (link)

src/functions/iac/export.ts (20)

medium

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
  1. The style guide states to 'Never use any or unknown as an escape hatch. Define proper interfaces/types or use type guards.' (link)

@inlined inlined marked this pull request as draft March 21, 2026 00:11
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