Skip to content

Commit

Permalink
Custom Diff User Tags
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkad committed Nov 13, 2024
1 parent c3cab41 commit f4395bf
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
18 changes: 18 additions & 0 deletions ibm/flex/structures.go
Original file line number Diff line number Diff line change
Expand Up @@ -2902,7 +2902,25 @@ func ResourceTagsCustomizeDiff(diff *schema.ResourceDiff) error {
}
return nil
}
func ResourcePowerUserTagsCustomizeDiff(diff *schema.ResourceDiff) error {

if diff.Id() != "" && diff.HasChange("pi_user_tags") {
// power tags
o, n := diff.GetChange("pi_user_tags")
oldSet := o.(*schema.Set)
newSet := n.(*schema.Set)
removeInt := oldSet.Difference(newSet).List()
addInt := newSet.Difference(oldSet).List()
if v := os.Getenv("IC_ENV_TAGS"); v != "" {
s := strings.Split(v, ",")
if len(removeInt) == len(s) && len(addInt) == 0 {
fmt.Println("Suppresing the TAG diff ")
return diff.Clear("pi_user_tags")
}
}
}
return nil
}
func ResourceValidateAccessTags(diff *schema.ResourceDiff, meta interface{}) error {

if value, ok := diff.GetOkExists("access_tags"); ok {
Expand Down
2 changes: 1 addition & 1 deletion ibm/service/power/resource_ibm_pi_network_address_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func ResourceIBMPINetworkAddressGroup() *schema.Resource {
},
CustomizeDiff: customdiff.Sequence(
func(_ context.Context, diff *schema.ResourceDiff, v interface{}) error {
return flex.ResourceTagsCustomizeDiff(diff)
return flex.ResourcePowerUserTagsCustomizeDiff(diff)
},
),
Schema: map[string]*schema.Schema{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func ResourceIBMPINetworkSecurityGroup() *schema.Resource {
},
CustomizeDiff: customdiff.Sequence(
func(_ context.Context, diff *schema.ResourceDiff, v interface{}) error {
return flex.ResourceTagsCustomizeDiff(diff)
return flex.ResourcePowerUserTagsCustomizeDiff(diff)
},
),
Schema: map[string]*schema.Schema{
Expand Down

0 comments on commit f4395bf

Please sign in to comment.