Skip to content

Commit 9b2fea9

Browse files
committed
Use utils.ListValueFrom for empty slice
1 parent 713a4a6 commit 9b2fea9

File tree

1 file changed

+4
-7
lines changed
  • internal/kibana/security_detection_rule

1 file changed

+4
-7
lines changed

internal/kibana/security_detection_rule/models.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2362,7 +2362,7 @@ func (d *SecurityDetectionRuleData) updateInvestigationFieldsFromApi(ctx context
23622362
investigationFieldsValue, investigationFieldsDiags := convertInvestigationFieldsToModel(ctx, investigationFields)
23632363
diags.Append(investigationFieldsDiags...)
23642364
if diags.HasError() {
2365-
return diags
2365+
return diags
23662366
}
23672367
d.InvestigationFields = investigationFieldsValue
23682368

@@ -2622,7 +2622,8 @@ func (d *SecurityDetectionRuleData) updateFiltersFromApi(ctx context.Context, ap
26222622
// Create a NormalizedValue from the JSON string
26232623
d.Filters = jsontypes.NewNormalizedValue(string(jsonBytes))
26242624
return diags
2625-
}
2625+
}
2626+
26262627
// convertSeverityMappingToModel converts kbapi.SecurityDetectionsAPISeverityMapping to Terraform model
26272628
func convertSeverityMappingToModel(ctx context.Context, apiSeverityMapping *kbapi.SecurityDetectionsAPISeverityMapping) (types.List, diag.Diagnostics) {
26282629
var diags diag.Diagnostics
@@ -2709,11 +2710,7 @@ func (d *SecurityDetectionRuleData) updateTagsFromApi(ctx context.Context, tags
27092710
func (d *SecurityDetectionRuleData) updateFalsePositivesFromApi(ctx context.Context, falsePositives []string) diag.Diagnostics {
27102711
var diags diag.Diagnostics
27112712

2712-
if len(falsePositives) > 0 {
2713-
d.FalsePositives = utils.ListValueFrom(ctx, falsePositives, types.StringType, path.Root("false_positives"), &diags)
2714-
} else {
2715-
d.FalsePositives = types.ListValueMust(types.StringType, []attr.Value{})
2716-
}
2713+
d.FalsePositives = utils.ListValueFrom(ctx, falsePositives, types.StringType, path.Root("false_positives"), &diags)
27172714

27182715
return diags
27192716
}

0 commit comments

Comments
 (0)