Skip to content

catalog: replace hardcoded suffix list with deterministic deployment-file matching - #6530

Merged
saara-tyagi27 merged 2 commits into
GoogleCloudPlatform:developfrom
saara-tyagi27:catalog-deployment-pairing
Oct 22, 2026
Merged

saara-tyagi27 merged 2 commits into
GoogleCloudPlatform:developfrom
saara-tyagi27:catalog-deployment-pairing

Conversation

@saara-tyagi27

Copy link
Copy Markdown
Contributor

Follow-up to #6481.

What

Replaces the hardcoded suffix list (-blueprint, -advanced, -infra, -experiment) in
findCompanionDeployment with a 3-step matcher over git-tracked *-deployment.yaml /
deployment.yaml files in the blueprint's directory:

  1. Exact — <stem>-deployment.yaml or <blueprint_name>-deployment.yaml
  2. Longest prefix — <prefix>-deployment.yaml where <stem> starts with <prefix>- (or vice versa)
  3. Single-file fallback — the only deployment file in the dir, when the dir is an examples subfolder

Why

New blueprint naming patterns no longer need a code change to be paired, and multi-blueprint
folders (e.g. a3-ultragpu-8g/ with two blueprints and two deployment files) resolve
deterministically via longest prefix instead of a fixed suffix list.

Behaviour preserved

  • Untracked (user/agent-created) deployment files are still ignored via git ls-files.
  • Var-merge semantics unchanged: deployment vars only fill blueprint vars that are missing or null.
  • go run ./tools/catalog-gen produces a byte-identical catalog.yaml and examples/README.md —
    all 38 existing pairings resolve the same way.

Tests

  • TestMatchDeploymentFile: 14 table-driven cases (exact beats prefix, longest prefix wins,
    no partial-word prefix, ambiguous dirs stay unpaired, no fallback at examples root, etc.)
  • verifyDeploymentPairings: pins one blueprint of every pairing shape in the repo.
  • go test ./pkg/catalog/..., gocyclo -over=13, and pre-commit all pass.

…file matching

Pair blueprints via exact, longest-prefix, or single-file-in-subfolder match on git-tracked files
@saara-tyagi27 saara-tyagi27 added the release-chore To not include into release notes label Oct 20, 2026
@gemini-code-assist

Copy link
Copy Markdown
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 refactors the blueprint-to-deployment file pairing logic in the catalog generator. By moving away from a fixed list of suffixes to a deterministic matching algorithm, the system becomes more flexible and capable of handling complex directory structures without manual configuration updates. The changes maintain backward compatibility with existing catalog outputs while providing a more predictable resolution strategy.

Highlights

  • Deterministic Deployment Matching: Replaced the hardcoded suffix list for deployment file matching with a robust 3-step logic: exact match, longest prefix match, and a single-file fallback for subfolders.
  • Improved Scalability: The new matching logic eliminates the need for code changes when introducing new blueprint naming patterns and correctly handles multi-blueprint directories.
  • Enhanced Testing: Added comprehensive table-driven tests in TestMatchDeploymentFile and a new verification helper to ensure existing pairings remain stable.
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 the 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 counterproductive. 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. ↩

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

Copy link
Copy Markdown
Contributor

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 refactors the companion deployment file matching logic in pkg/catalog/catalog.go to be more deterministic and robust, introducing helpers like trackedDeploymentFiles, matchDeploymentFile, and isExampleSubfolder. It also adds comprehensive unit tests in pkg/catalog/catalog_test.go to verify these pairings. Feedback on the changes suggests refining isExampleSubfolder using strings.HasPrefix to ensure it strictly matches directories within the examples/ or community/examples/ hierarchies, preventing incorrect single-file fallback matching in other repository directories.

Comment thread pkg/catalog/catalog.go
@saara-tyagi27
saara-tyagi27 marked this pull request as ready for review October 21, 2026 20:16
@saara-tyagi27
saara-tyagi27 requested a review from a team as a code owner October 21, 2026 20:16
Comment thread pkg/catalog/catalog.go
@saara-tyagi27
saara-tyagi27 merged commit d58aa11 into GoogleCloudPlatform:develop Oct 22, 2026
32 of 97 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-chore To not include into release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants