Skip to content

Commit 55e9b2a

Browse files
committed
only allow name/values in exceptions
1 parent c9c5e69 commit 55e9b2a

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

sysdig/resource_sysdig_secure_rule_stateful.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,24 @@ func resourceSysdigRuleStatefulRead(ctx context.Context, d *schema.ResourceData,
159159
if rule.Details.Append != nil {
160160
_ = d.Set("append", *rule.Details.Append)
161161
}
162-
if err := updateResourceDataExceptions(d, rule.Details.Exceptions); err != nil {
162+
163+
exceptions := make([]any, 0, len(rule.Details.Exceptions))
164+
for _, exception := range rule.Details.Exceptions {
165+
if exception == nil {
166+
return diag.Errorf("exception is nil")
167+
}
168+
valuesData, err := json.Marshal(exception.Values)
169+
if err != nil {
170+
return diag.Errorf("error marshalling exception values '%+v': %s", exception.Values, err)
171+
}
172+
173+
exceptions = append(exceptions, map[string]any{
174+
"name": exception.Name,
175+
"values": string(valuesData),
176+
})
177+
}
178+
179+
if err := d.Set("exceptions", exceptions); err != nil {
163180
return diag.FromErr(err)
164181
}
165182

0 commit comments

Comments
 (0)