feat: Add support for verifying Cloud SQL instances#1681
feat: Add support for verifying Cloud SQL instances#1681Amit2465 wants to merge 1 commit intogruntwork-io:mainfrom
Conversation
|
One suggestion: the error message in getCloudSQLInstanceE (line 60) wraps the API error with "does not exist", but the underlying error could also be an auth or network issue. Consider rewording to something like "failed to get Cloud SQL instance %s in project %s: %v" so it doesn't mask the real cause. The strings.ToLower on random.UniqueId() is a no-op and can be dropped. Otherwise this looks good to merge. |
00dd4d4 to
098f6a5
Compare
|
Fixed both: updated error message to not mask the real cause, and dropped the no-op strings.ToLower |
|
Thanks for the contribution! The code is clean, tests are thorough, and the overall structure follows existing module conventions well. A few things to address before merging: Context variants (main ask): The GCP module has been migrating to context-aware function signatures (see func AssertCloudSQLInstanceExistsContext(t testing.TestingT, ctx context.Context, projectID, instanceName string)
func AssertCloudSQLInstanceExistsContextE(t testing.TestingT, ctx context.Context, projectID, instanceName string) errorSame for Minor: In return nil, fmt.Errorf("failed to get Cloud SQL instance %s in project %s: %w", instanceName, projectID, err)Housekeeping: Please rebase/update your branch against Everything else — naming, error handling, logging, test structure, Terraform example — looks great. |
098f6a5 to
66fb80b
Compare
This commit adds helper functions to the `gcp` module to enable automated testing of Cloud SQL instances using the Cloud SQL Admin API. As part of this: * Add new `AssertCloudSQLInstanceExists` and `AssertCloudSQLInstanceExistsE` functions * Add new `GetCloudSQLInstanceDatabaseVersion` and `GetCloudSQLInstanceDatabaseVersionE` functions * Add Terraform example fixture in `examples/terraform-gcp-cloudsql-example` * Add integration tests covering MySQL and PostgreSQL engines
66fb80b to
a3e1dac
Compare
|
Thanks for the detailed review! Here's what was addressed:
Also added |
|
Thanks for addressing all the feedback! This is nearly ready. A few final items:
Everything else looks great — clean code, good test coverage, follows module conventions well. |
|
Hi @Amit2465, closing this PR as there were no response for the past week. Feel free to reopen this when you have the capacity to continue making changes on this PR! |
Description
This PR adds support for Google Cloud SQL to the GCP module. It introduces helper functions to verify the existence of Cloud SQL instances and retrieve their database version, along with a complete Terraform example and automated integration tests covering both MySQL and PostgreSQL engines.
This is a new feature addition and does not introduce any backward-incompatible changes.
TODOs
Read the Gruntwork contribution guidelines.
Release Notes (draft)
Added support for verifying Google Cloud SQL instances in the GCP module, including database engine version validation for MySQL and PostgreSQL.
Migration Guide
No backward incompatible changes were introduced.
Verification Results
I have verified this PR locally against a real GCP project:
golangci-lint run.go fmtandterraform fmt.TestTerraformGcpCloudSQLExamplecovering both MySQL and PostgreSQL engines in parallel.Test Output Snippet: