Skip to content

feat: Automatically add ghpc_creator label to expanded blueprint#5468

Merged
cboneti merged 1 commit into
GoogleCloudPlatform:developfrom
cboneti:gcluster-creator
Apr 10, 2026
Merged

feat: Automatically add ghpc_creator label to expanded blueprint#5468
cboneti merged 1 commit into
GoogleCloudPlatform:developfrom
cboneti:gcluster-creator

Conversation

@cboneti

@cboneti cboneti commented Apr 8, 2026

Copy link
Copy Markdown
Member

Adds --add-creator-label flag to gcluster expand/create/deploy.

Detects username via gcloud auth list or shell environment.

Defaults to true for @google.com accounts.

Submission Checklist

NOTE: Community submissions can take up to 2 weeks to be reviewed.

Please take the following actions before submitting this pull request.

  • Fork your PR branch from the Toolkit "develop" branch (not main)
  • Test all changes with pre-commit in a local branch #
  • Confirm that "make tests" passes all tests
  • Add or modify unit tests to cover code changes
  • Ensure that unit test coverage remains above 80%
  • Update all applicable documentation
  • Follow Cluster Toolkit Contribution guidelines #

@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 enhances the gcluster toolkit by automating the addition of a ghpc_creator label to expanded blueprints. This feature helps track the origin of deployments by automatically identifying the user who initiated the blueprint expansion, defaulting to enabled for internal Google users, and providing an explicit flag for others.

Highlights

  • New --add-creator-label flag: Introduced a new flag for gcluster expand/create/deploy commands to explicitly control the addition of the ghpc_creator label.
  • Automatic Creator Detection: Implemented logic to automatically detect the user's identity using gcloud auth list or shell environment variables (USER, USERNAME).
  • Default Labeling for Google Accounts: The ghpc_creator label is now automatically enabled by default for users with @google.com accounts when the --add-creator-label flag is not explicitly set.
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.

@cboneti cboneti added the release-improvements Added to release notes under the "Improvements" heading. label Apr 8, 2026

@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 implements automatic detection of the deployment creator's username and adds a ghpc_creator label to the expanded blueprint. The username is detected by querying gcloud, checking environment variables, or using the current system user. A new CLI flag --add-creator-label is introduced to control this behavior, defaulting to true for @google.com accounts. Review feedback recommends implementing a timeout for the synchronous gcloud command execution and optimizing the code to skip username detection when the creator label is explicitly disabled via the CLI flag.

Comment thread cmd/create.go Outdated
Comment thread cmd/create.go Outdated
@cboneti cboneti force-pushed the gcluster-creator branch 2 times, most recently from 96cab26 to 29f98be Compare April 8, 2026 22:47
@cboneti

cboneti commented Apr 8, 2026

Copy link
Copy Markdown
Member Author

/gemini review

@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 introduces a new feature to automatically add a ghpc_creator label to resources, based on the user who initiated the deployment. Key changes include adding AddCreatorLabel and CreatorUsername fields to the Blueprint struct, implementing a detectUsername function, and introducing a --add-creator-label flag for create and expand commands. The flag defaults to true for @google.com users if not explicitly set. The expandGlobalLabels function now includes the ghpc_creator label with basic sanitization, and new unit tests have been added for this functionality. Feedback from the review indicates that the label sanitization needs to be more robust to meet GCP label requirements (e.g., lowercasing, character limits, and handling more invalid characters) to prevent deployment failures. Additionally, the logic for determining AddCreatorLabel could be refactored for improved readability, and the unit tests should be expanded to cover more edge cases for username sanitization.

Comment thread pkg/config/expand.go
Comment thread cmd/create.go Outdated
Comment thread pkg/config/expand_test.go
@cboneti cboneti force-pushed the gcluster-creator branch from 29f98be to c1d6009 Compare April 9, 2026 08:12
@cboneti

cboneti commented Apr 9, 2026

Copy link
Copy Markdown
Member Author

/gemini review

@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 introduces the ability to tag expanded blueprints with a "ghpc_creator" label, identifying the user responsible for the deployment. It includes logic to detect the username via gcloud, environment variables, or system calls, and automatically enables this label for @google.com users. The label is sanitized to ensure compatibility with cloud provider constraints. Feedback focuses on improving the CLI's responsiveness by using command contexts for sub-processes and optimizing performance by pre-compiling regular expressions.

Comment thread cmd/create.go Outdated
Comment thread cmd/create.go
Comment thread pkg/config/expand.go Outdated
@cboneti cboneti force-pushed the gcluster-creator branch from c1d6009 to 8b6f2ce Compare April 9, 2026 09:00
@cboneti

cboneti commented Apr 9, 2026

Copy link
Copy Markdown
Member Author

/gemini review

@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 introduces a feature to automatically add a "ghpc_creator" label to expanded blueprints, defaulting to true for users with "@google.com" accounts. It includes logic to detect the username via gcloud, environment variables, or system user info, along with sanitization to ensure the label value is valid for GCP. Review feedback highlights potential performance bottlenecks caused by executing external gcloud processes on every command run. Suggestions include checking for the CLOUDSDK_CORE_ACCOUNT environment variable first to avoid unnecessary process execution and optimizing the gcloud command used for detection.

Comment thread cmd/create.go
Comment thread cmd/create.go
Adds --add-creator-label flag to gcluster expand/create/deploy.

Detects username via gcloud auth list or shell environment.

Defaults to true for @google.com accounts.
@cboneti cboneti force-pushed the gcluster-creator branch from 8b6f2ce to 8e7bfbe Compare April 9, 2026 10:40
@cboneti

cboneti commented Apr 9, 2026

Copy link
Copy Markdown
Member Author

/gemini review

@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 introduces functionality to automatically add a ghpc_creator label to expanded blueprints. This involves adding a new --add-creator-label flag to the create and expand commands, implementing a detectUsername function to determine the user's identity with a fallback mechanism, and sanitizing the username to comply with GCP label naming conventions. The Blueprint struct has been updated with AddCreatorLabel and CreatorUsername fields, and new unit tests have been added for the label expansion logic. Feedback suggests adding comments to the detectUsername function to explain the order of precedence for username detection and to the validLabelValueRegex to clarify its purpose and reference GCP label naming conventions, both to improve code readability and maintainability.

Comment thread cmd/create.go
Comment thread pkg/config/expand.go
@cboneti cboneti marked this pull request as ready for review April 9, 2026 11:29
@cboneti cboneti requested review from a team and samskillman as code owners April 9, 2026 11:29
@cboneti cboneti enabled auto-merge April 9, 2026 11:30
@cboneti cboneti merged commit 154149d into GoogleCloudPlatform:develop Apr 10, 2026
19 of 78 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-improvements Added to release notes under the "Improvements" heading.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants