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.
accesscontextmanager - Fix permadiff for perimeter ingress / egress r…
…ule resources (GoogleCloudPlatform#12119) Co-authored-by: Charlesleonius <[email protected]>
- Loading branch information
1 parent
7a6b526
commit 551f480
Showing
7 changed files
with
104 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
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
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
41 changes: 41 additions & 0 deletions
41
mmv1/templates/terraform/constants/access_context_manager.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,41 @@ | ||
func {{$.ResourceName}}EgressToResourcesDiffSupressFunc(_, _, _ string, d *schema.ResourceData) bool { | ||
old, new := d.GetChange("egress_to.0.resources") | ||
|
||
oldResources, err := tpgresource.InterfaceSliceToStringSlice(old) | ||
if err != nil { | ||
log.Printf("[ERROR] Failed to convert config value: %s", err) | ||
return false | ||
} | ||
|
||
newResources, err := tpgresource.InterfaceSliceToStringSlice(new) | ||
if err != nil { | ||
log.Printf("[ERROR] Failed to convert config value: %s", err) | ||
return false | ||
} | ||
|
||
sort.Strings(oldResources) | ||
sort.Strings(newResources) | ||
|
||
return slices.Equal(oldResources, newResources) | ||
} | ||
|
||
func {{$.ResourceName}}IngressToResourcesDiffSupressFunc(_, _, _ string, d *schema.ResourceData) bool { | ||
old, new := d.GetChange("ingress_to.0.resources") | ||
|
||
oldResources, err := tpgresource.InterfaceSliceToStringSlice(old) | ||
if err != nil { | ||
log.Printf("[ERROR] Failed to convert config value: %s", err) | ||
return false | ||
} | ||
|
||
newResources, err := tpgresource.InterfaceSliceToStringSlice(new) | ||
if err != nil { | ||
log.Printf("[ERROR] Failed to convert config value: %s", err) | ||
return false | ||
} | ||
|
||
sort.Strings(oldResources) | ||
sort.Strings(newResources) | ||
|
||
return slices.Equal(oldResources, newResources) | ||
} |
25 changes: 25 additions & 0 deletions
25
...raform/custom_flatten/accesscontextmanager_egress_policy_resources_custom_flatten.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("egress_to.0.resources") | ||
|
||
// 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/accesscontextmanager_ingress_policy_resources_custom_flatten.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("ingress_to.0.resources") | ||
|
||
// 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 | ||
} |