Skip to content

Commit

Permalink
fix: back port for version 5, add check for external rules while upda…
Browse files Browse the repository at this point in the history
…ting roleTemplate (rancher#1395)

Co-authored-by: Pratik Jagrut <[email protected]>
  • Loading branch information
matttrach and pratikjagrut authored Sep 5, 2024
1 parent a41ef9c commit 725a19f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions rancher2/resource_rancher2_role_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package rancher2

import (
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"log"
"time"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

Expand Down Expand Up @@ -110,7 +111,14 @@ func resourceRancher2RoleTemplateUpdate(d *schema.ResourceData, meta interface{}
"rules": expandPolicyRules(d.Get("rules").([]interface{})),
"annotations": toMapString(d.Get("annotations").(map[string]interface{})),
"labels": toMapString(d.Get("labels").(map[string]interface{})),
"externalRules": expandPolicyRules(d.Get("external_rules").([]interface{})),
}

if update["external"].(bool) {
if v, ok := d.Get("external_rules").([]interface{}); ok && len(v) > 0 {
update["externalRules"] = expandPolicyRules(v)
}
} else {
update["externalRules"] = nil
}

switch update["context"] {
Expand Down

0 comments on commit 725a19f

Please sign in to comment.