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.
Fix address group ordering for network firewall policy rule (GoogleCl…
- Loading branch information
1 parent
36ad20b
commit 12d25e7
Showing
4 changed files
with
158 additions
and
1 deletion.
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
25 changes: 25 additions & 0 deletions
25
...form/custom_flatten/compute_network_firewall_policy_rule_dest_address_group_order.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,25 @@ | ||
func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { | ||
rawConfigValue := d.Get("match.0.dest_address_groups") | ||
|
||
// 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 | ||
} |
25 changes: 25 additions & 0 deletions
25
...aform/custom_flatten/compute_network_firewall_policy_rule_src_address_group_order.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,25 @@ | ||
func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { | ||
rawConfigValue := d.Get("match.0.src_address_groups") | ||
|
||
// 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