Skip to content

Commit 6aff8ac

Browse files
authored
feat: add name param to the capture action (#205)
1 parent b85c3a9 commit 6aff8ac

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

sysdig/internal/client/secure/models.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type Policy struct {
2525
type Action struct {
2626
AfterEventNs int `json:"afterEventNs,omitempty"`
2727
BeforeEventNs int `json:"beforeEventNs,omitempty"`
28+
Name string `json:"name,omitempty"`
2829
IsLimitedToContainer bool `json:"isLimitedToContainer"`
2930
Type string `json:"type"`
3031
}

sysdig/resource_sysdig_secure_policy.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ func resourceSysdigSecurePolicy() *schema.Resource {
107107
Required: true,
108108
ValidateDiagFunc: validateDiagFunc(validation.IntAtLeast(0)),
109109
},
110+
"name": {
111+
Type: schema.TypeString,
112+
Optional: true,
113+
Computed: true,
114+
},
110115
},
111116
},
112117
},
@@ -163,6 +168,7 @@ func policyToResourceData(policy *secure.Policy, d *schema.ResourceData) {
163168
actions[0]["capture"] = []map[string]interface{}{{
164169
"seconds_after_event": action.AfterEventNs / 1000000000,
165170
"seconds_before_event": action.BeforeEventNs / 1000000000,
171+
"name": action.Name,
166172
}}
167173
_ = d.Set("actions", actions)
168174
}
@@ -225,11 +231,13 @@ func addActionsToPolicy(d *schema.ResourceData, policy *secure.Policy) {
225231
if captureAction := d.Get("actions.0.capture").([]interface{}); len(captureAction) > 0 {
226232
afterEventNs := d.Get("actions.0.capture.0.seconds_after_event").(int) * 1000000000
227233
beforeEventNs := d.Get("actions.0.capture.0.seconds_before_event").(int) * 1000000000
234+
name := d.Get("actions.0.capture.0.name").(string)
228235
policy.Actions = append(policy.Actions, secure.Action{
229236
Type: "POLICY_ACTION_CAPTURE",
230237
IsLimitedToContainer: false,
231238
AfterEventNs: afterEventNs,
232239
BeforeEventNs: beforeEventNs,
240+
Name: name,
233241
})
234242
}
235243
}

sysdig/resource_sysdig_secure_policy_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ resource "sysdig_secure_policy" "sample" {
8080
capture {
8181
seconds_before_event = 5
8282
seconds_after_event = 10
83+
name = "testcapture"
8384
}
8485
}
8586

website/docs/r/secure_policy.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ The actions block is optional and supports:
7676
amount of seconds before the policy was triggered.
7777
* `seconds_after_event` - (Required) Captures the system calls for the amount
7878
of seconds after the policy was triggered.
79+
* `name` - (Optional) The name of the capture file
7980

8081
- - -
8182

@@ -100,4 +101,4 @@ Secure runtime policies can be imported using the ID, e.g.
100101

101102
```
102103
$ terraform import sysdig_secure_policy.example 12345
103-
```
104+
```

0 commit comments

Comments
 (0)