-
Notifications
You must be signed in to change notification settings - Fork 262
Adding validations for naming resources #4788
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
Adding validations for naming resources #4788
Conversation
Summary of ChangesHello @vikramvs-gg, 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 robustness of Terraform configurations by implementing pre-validation for resource names. Specifically targeting GKE node pools and resource policies, the changes ensure that names comply with GCP's strict naming conventions. This proactive approach shifts potential validation errors from the resource provisioning phase to the earlier Terraform plan stage, significantly improving the developer experience by catching issues before deployment attempts. Highlights
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. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this 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 is a good initiative to add input validation for resource names, which helps catch errors early in the terraform plan stage. However, I've found critical issues in both validation blocks. The validations do not account for suffixes that are appended to the names within the modules, which can result in resource names exceeding GCP's maximum length limits and causing deployment failures. This defeats the primary purpose of these changes. My review includes suggestions to correct the length constraints in the regular expressions and to make the error messages more informative. I've also included a minor suggestion to simplify the validation conditions by removing a redundant function call.
b47785a to
150f9e6
Compare
4f4af5c
into
GoogleCloudPlatform:develop
This change includes addition of validation in variables for naming node-pool and resource-policy resources. This is to validate the namings are as per the GCP naming conventions and avoid validation errors towards the end of resource provisioning.
Without these validations, the user would get the GCP validation error towards the end of cluster deployment when node pool is being spun up. Adding these validations enable checks to kick in at the terraform plan stage itself before applying resources on GCP, thereby pre-validating errors before resources are being provisioned.
Tested the scenarios: