-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix permadiff when Access Context Manager returns a different order f…
…or ingress / egress rule identities (#12572) Co-authored-by: Charlesleonius <[email protected]>
- Loading branch information
1 parent
6cde904
commit d630fcf
Showing
7 changed files
with
102 additions
and
0 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
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
26 changes: 26 additions & 0 deletions
26
.../custom_flatten/accesscontextmanager_egress_policy_from_identities_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,26 @@ | ||
func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { | ||
rawConfigValue := d.Get("egress_from.0.identities") | ||
// Convert config value to []string | ||
configValue, err := tpgresource.InterfaceSliceToStringSlice(rawConfigValue) | ||
if err != nil { | ||
log.Printf("[ERROR] Failed to convert egress from identities config value: %s", err) | ||
return v | ||
} | ||
sortedConfigValue := append([]string{}, configValue...) | ||
sort.Strings(sortedConfigValue) | ||
|
||
// Convert v to []string | ||
apiValue, err := tpgresource.InterfaceSliceToStringSlice(v) | ||
if err != nil { | ||
log.Printf("[ERROR] Failed to convert egress from identities API value: %s", err) | ||
return v | ||
} | ||
sortedApiValue := append([]string{}, apiValue...) | ||
sort.Strings(sortedApiValue) | ||
|
||
if (slices.Equal(sortedApiValue, sortedConfigValue)) { | ||
return configValue | ||
} | ||
|
||
return apiValue | ||
} |
26 changes: 26 additions & 0 deletions
26
...custom_flatten/accesscontextmanager_ingress_policy_from_identities_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,26 @@ | ||
func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { | ||
rawConfigValue := d.Get("ingress_from.0.identities") | ||
// Convert config value to []string | ||
configValue, err := tpgresource.InterfaceSliceToStringSlice(rawConfigValue) | ||
if err != nil { | ||
log.Printf("[ERROR] Failed to convert ingress from identities config value: %s", err) | ||
return v | ||
} | ||
sortedConfigValue := append([]string{}, configValue...) | ||
sort.Strings(sortedConfigValue) | ||
|
||
// Convert v to []string | ||
apiValue, err := tpgresource.InterfaceSliceToStringSlice(v) | ||
if err != nil { | ||
log.Printf("[ERROR] Failed to convert ingress from identities API value: %s", err) | ||
return v | ||
} | ||
sortedApiValue := append([]string{}, apiValue...) | ||
sort.Strings(sortedApiValue) | ||
|
||
if (slices.Equal(sortedApiValue, sortedConfigValue)) { | ||
return configValue | ||
} | ||
|
||
return apiValue | ||
} |