-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Support Self Service Maintenance feature #6131
Merged
Merged
Changes from 3 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
2f21578
Changes for SSM terraform
2tricpony cb08b34
Change description of some fields.
2tricpony 6e0a876
Merge branch 'GoogleCloudPlatform:main' into main
2tricpony f890112
Add a test case for maintenance version suppress diff functionality
2tricpony a036a42
Add test case for suppress diff functionality
2tricpony d15bed2
Make availableMaintenanceVersions optional=false
2tricpony d126eb5
Update mmv1/third_party/terraform/website/docs/r/sql_database_instanc…
2tricpony b5f5b45
Update mmv1/third_party/terraform/website/docs/r/sql_database_instanc…
2tricpony 036fd77
Modifying test cases
2tricpony 37ea61d
Acceptance test for maintenance version.
2tricpony d97c2eb
Fix spacing
2tricpony 9badea9
Update mmv1/third_party/terraform/website/docs/r/sql_database_instanc…
2tricpony 7f32388
Address comments from review.
2tricpony fe2954c
Fix Indentation
2tricpony 2612558
Update mmv1/third_party/terraform/tests/resource_sql_database_instanc…
2tricpony fa2b40f
Update mmv1/third_party/terraform/tests/resource_sql_database_instanc…
2tricpony 7d19060
Merge branch 'main' into main
2tricpony 58996f1
Resolve merge issue.
2tricpony ae1b30b
Make separate patch call for maintenance version updates.
2tricpony 85b7801
Merge branch 'GoogleCloudPlatform:main' into main
2tricpony 19cf115
Fix error
2tricpony c0dd9d5
Update mmv1/third_party/terraform/website/docs/r/sql_database_instanc…
2tricpony a956cf4
Addressing comments.
2tricpony 909bd35
Addressing review comments
2tricpony 3c52e8b
Add a comment.
2tricpony 6f0eac2
Fix provider crash issue.
2tricpony bc42349
Fix case where patch request was not properly sent.
2tricpony 04cfe58
Remove suppressDiff functionality for maintenance version
2tricpony 2e8918b
Merge branch 'GoogleCloudPlatform:main' into main
2tricpony f6a879a
Fix an accidental commit.
2tricpony 4b30e36
Fix test issue.
2tricpony d77cb6f
Rollforward changes for suppressDiffFunc
2tricpony 81ca557
Fix to suppress diff for equal maintenance version.
2tricpony 3e313ed
Doc changes
2tricpony 294bad0
Merge branch 'GoogleCloudPlatform:main' into main
2tricpony 767fef9
Update mmv1/third_party/terraform/website/docs/r/sql_database_instanc…
2tricpony File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -443,7 +443,22 @@ is set to true.`, | |
Computed: true, | ||
Description: `The connection name of the instance to be used in connection strings. For example, when connecting with Cloud SQL Proxy.`, | ||
}, | ||
|
||
"maintenance_version": { | ||
2tricpony marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Type: schema.TypeString, | ||
Computed: true, | ||
Optional: true, | ||
DiffSuppressFunc: maintenanceVersionDiffSuppress, | ||
Description: `Maintenance version.`, | ||
}, | ||
"available_maintenance_versions": { | ||
Type: schema.TypeList, | ||
Computed: true, | ||
Optional: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this is an output-only field, we probably want to remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
Elem: &schema.Schema{ | ||
Type: schema.TypeString, | ||
}, | ||
Description: `Available Maintenance versions.`, | ||
}, | ||
"database_version": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
|
@@ -468,7 +483,6 @@ is set to true.`, | |
Sensitive: true, | ||
Description: `Initial root password. Required for MS SQL Server, ignored by MySQL and PostgreSQL.`, | ||
}, | ||
|
||
"ip_address": { | ||
Type: schema.TypeList, | ||
Computed: true, | ||
|
@@ -1183,6 +1197,12 @@ func resourceSqlDatabaseInstanceRead(d *schema.ResourceData, meta interface{}) e | |
if err := d.Set("connection_name", instance.ConnectionName); err != nil { | ||
return fmt.Errorf("Error setting connection_name: %s", err) | ||
} | ||
if err := d.Set("maintenance_version", instance.MaintenanceVersion); err != nil { | ||
return fmt.Errorf("Error setting maintenance_version: %s", err) | ||
} | ||
if err := d.Set("available_maintenance_versions", instance.AvailableMaintenanceVersions); err != nil { | ||
return fmt.Errorf("Error setting available_maintenance_version: %s", err) | ||
} | ||
2tricpony marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if err := d.Set("service_account_email_address", instance.ServiceAccountEmailAddress); err != nil { | ||
return fmt.Errorf("Error setting service_account_email_address: %s", err) | ||
} | ||
|
@@ -1261,8 +1281,14 @@ func resourceSqlDatabaseInstanceUpdate(d *schema.ResourceData, meta interface{}) | |
return err | ||
} | ||
|
||
var maintenance_version string | ||
2tricpony marked this conversation as resolved.
Show resolved
Hide resolved
2tricpony marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if v, ok := d.GetOk("maintenance_version"); ok { | ||
2tricpony marked this conversation as resolved.
Show resolved
Hide resolved
|
||
maintenance_version = v.(string) | ||
} | ||
|
||
// Update only updates the settings, so they are all we need to set. | ||
instance := &sqladmin.DatabaseInstance{ | ||
MaintenanceVersion: maintenance_version, | ||
2tricpony marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Settings: expandSqlDatabaseInstanceSettings(d.Get("settings").([]interface{})), | ||
} | ||
|
||
|
@@ -1300,6 +1326,15 @@ func resourceSqlDatabaseInstanceUpdate(d *schema.ResourceData, meta interface{}) | |
return resourceSqlDatabaseInstanceRead(d, meta) | ||
} | ||
|
||
func maintenanceVersionDiffSuppress(_, old, new string, _ *schema.ResourceData) bool { | ||
if old > new { | ||
log.Printf("[DEBUG] Maintenance version in configuration [%s] is older than current maintenance version [%s] on instance. Suppressing diff", new, old) | ||
return true | ||
} else { | ||
return false | ||
} | ||
} | ||
2tricpony marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
func resourceSqlDatabaseInstanceDelete(d *schema.ResourceData, meta interface{}) error { | ||
config := meta.(*Config) | ||
userAgent, err := generateUserAgentString(d, config.userAgent) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Sounds like
maintenanceVersion
is not an output-only field.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.
That's right. It can be updated after instance creation.