Skip to content

Commit ac95602

Browse files
committed
address review comments part 1
1 parent 55e9b2a commit ac95602

File tree

3 files changed

+20
-24
lines changed

3 files changed

+20
-24
lines changed

sysdig/internal/client/v2/model.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,8 +527,8 @@ const (
527527
RuleTypeProcess = "PROCESS"
528528
RuleTypeSyscall = "SYSCALL"
529529
RuleTypeStatefulSequence = "STATEFUL_SEQUENCE"
530-
StatefulUniqPercentRuleType = "STATEFUL_UNIQ_PERCENT"
531-
StatefulCountRuleType = "STATEFUL_COUNT"
530+
RuleTypeStatefulUniqPercent = "STATEFUL_UNIQ_PERCENT"
531+
RuleTypeStatefulCount = "STATEFUL_COUNT"
532532
)
533533

534534
type Details struct {

sysdig/internal/client/v2/rules.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ func (client *Client) UpdateStatefulRule(ctx context.Context, rule Rule) (Rule,
189189
}
190190

191191
func (client *Client) DeleteStatefulRule(ctx context.Context, ruleID int) error {
192-
fmt.Println("deleting stateful rule")
193192
response, err := client.requester.Request(ctx, http.MethodDelete, client.DeleteStatefulRuleURL(ruleID), nil)
194193
if err != nil {
195194
return err

sysdig/resource_sysdig_secure_rule_stateful.go

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,14 @@ import (
1717

1818
var validateStatefulRuleSource = validation.StringInSlice([]string{"awscloudtrail_stateful"}, false)
1919

20+
var validateStatefulRuleType = validation.StringInSlice([]string{
21+
v2.RuleTypeStatefulSequence,
22+
v2.RuleTypeStatefulCount,
23+
v2.RuleTypeStatefulUniqPercent,
24+
}, false)
25+
2026
func resourceSysdigSecureStatefulRule() *schema.Resource {
21-
timeout := 5 * time.Minute
27+
timeout := 1 * time.Minute
2228

2329
return &schema.Resource{
2430
CreateContext: resourceSysdigRuleStatefulCreate,
@@ -36,22 +42,23 @@ func resourceSysdigSecureStatefulRule() *schema.Resource {
3642
Delete: schema.DefaultTimeout(timeout),
3743
},
3844

39-
Schema: createRuleSchema(map[string]*schema.Schema{
45+
Schema: map[string]*schema.Schema{
46+
"name": {
47+
Type: schema.TypeString,
48+
Required: true,
49+
ForceNew: true,
50+
},
4051
"source": {
4152
Type: schema.TypeString,
4253
Optional: false,
4354
Required: true,
4455
ValidateDiagFunc: validateDiagFunc(validateStatefulRuleSource),
4556
},
4657
"ruletype": {
47-
Type: schema.TypeString,
48-
Optional: false,
49-
Required: true,
50-
ValidateDiagFunc: validateDiagFunc(validation.StringInSlice([]string{
51-
v2.RuleTypeStatefulSequence,
52-
v2.StatefulCountRuleType,
53-
v2.StatefulUniqPercentRuleType,
54-
}, false)),
58+
Type: schema.TypeString,
59+
Optional: false,
60+
Required: true,
61+
ValidateDiagFunc: validateDiagFunc(validateStatefulRuleType),
5562
},
5663
"append": {
5764
Type: schema.TypeBool,
@@ -75,7 +82,7 @@ func resourceSysdigSecureStatefulRule() *schema.Resource {
7582
},
7683
},
7784
},
78-
}),
85+
},
7986
}
8087
}
8188

@@ -95,8 +102,6 @@ func resourceSysdigRuleStatefulCreate(ctx context.Context, d *schema.ResourceDat
95102
if err != nil {
96103
return diag.FromErr(err)
97104
}
98-
sysdigClients.AddCleanupHook(sendPoliciesToAgents)
99-
100105
d.SetId(strconv.Itoa(rule.ID))
101106
_ = d.Set("version", rule.Version)
102107

@@ -147,12 +152,6 @@ func resourceSysdigRuleStatefulRead(ctx context.Context, d *schema.ResourceData,
147152
}
148153
}
149154

150-
if rule.Details.Append != nil && !(*(rule.Details.Append)) {
151-
if rule.Details.Condition == nil {
152-
return diag.Errorf("no condition data for a Stateful rule")
153-
}
154-
}
155-
156155
_ = d.Set("name", rule.Name)
157156
_ = d.Set("source", rule.Details.Source)
158157

@@ -202,7 +201,6 @@ func resourceSysdigRuleStatefulUpdate(ctx context.Context, d *schema.ResourceDat
202201
if err != nil {
203202
return diag.FromErr(err)
204203
}
205-
sysdigClients.AddCleanupHook(sendPoliciesToAgents)
206204

207205
return nil
208206
}
@@ -223,7 +221,6 @@ func resourceSysdigRuleStatefulDelete(ctx context.Context, d *schema.ResourceDat
223221
if err != nil {
224222
return diag.FromErr(err)
225223
}
226-
sysdigClients.AddCleanupHook(sendPoliciesToAgents)
227224

228225
return nil
229226
}

0 commit comments

Comments
 (0)