forked from GoogleCloudPlatform/magic-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Spanner MR CMEK Integration (GoogleCloudPlatform#11319)
Co-authored-by: Scott Suarez <[email protected]> Co-authored-by: Stephen Lewis (Burrows) <[email protected]>
- Loading branch information
1 parent
76e5a0f
commit b0450ba
Showing
5 changed files
with
170 additions
and
8 deletions.
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
31 changes: 31 additions & 0 deletions
31
mmv1/templates/terraform/custom_flatten/spanner_database_kms_key_names.go.tmpl
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { | ||
// Ignore `kms_key_names` if `kms_key_name` is set, because that field takes precedence. | ||
_, kmsNameSet := d.GetOk("encryption_config.0.kms_key_name") | ||
if kmsNameSet { | ||
return nil | ||
} | ||
|
||
rawConfigValue := d.Get("encryption_config.0.kms_key_names") | ||
|
||
// Convert config value to []string | ||
configValue, err := tpgresource.InterfaceSliceToStringSlice(rawConfigValue) | ||
if err != nil { | ||
log.Printf("[ERROR] Failed to convert config value: %s", err) | ||
return v | ||
} | ||
|
||
// Convert v to []string | ||
apiStringValue, err := tpgresource.InterfaceSliceToStringSlice(v) | ||
if err != nil { | ||
log.Printf("[ERROR] Failed to convert API value: %s", err) | ||
return v | ||
} | ||
|
||
sortedStrings, err := tpgresource.SortStringsByConfigOrder(configValue, apiStringValue) | ||
if err != nil { | ||
log.Printf("[ERROR] Could not sort API response value: %s", err) | ||
return v | ||
} | ||
|
||
return sortedStrings | ||
} |
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