Skip to content

Commit d370aa3

Browse files
refactor(entity): eliminate duplicate map in ItemObjectType by delegating to ItemAttrTypes (#3746)
* refactor(entity): eliminate duplicate map in ItemObjectType by delegating to ItemAttrTypes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * ci: trigger checks --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent da49277 commit d370aa3

1 file changed

Lines changed: 3 additions & 16 deletions

File tree

  • internal/kibana/security_entity_store/entity

internal/kibana/security_entity_store/entity/helpers.go

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,20 +1175,7 @@ func mapToAssetBlockModel(ctx context.Context, m map[string]any, _ *diag.Diagnos
11751175
// ItemObjectType returns the object type for items in the list data source.
11761176
// It covers the fields that apiBodyToModel populates from an API response.
11771177
func ItemObjectType() attr.Type {
1178-
return types.ObjectType{AttrTypes: map[string]attr.Type{
1179-
attrTimestamp: types.StringType,
1180-
attrEntity: types.ObjectType{AttrTypes: BlockAttrTypes()},
1181-
attrHost: types.ObjectType{AttrTypes: HostBlockAttrTypes()},
1182-
attrUser: types.ObjectType{AttrTypes: UserBlockAttrTypes()},
1183-
attrService: types.ObjectType{AttrTypes: ServiceBlockAttrTypes()},
1184-
attrCloud: types.ObjectType{AttrTypes: CloudBlockAttrTypes()},
1185-
attrAsset: types.ObjectType{AttrTypes: AssetBlockAttrTypes()},
1186-
attrOrchestrator: types.ObjectType{AttrTypes: OrchestratorBlockAttrTypes()},
1187-
attrEvent: types.ObjectType{AttrTypes: EventBlockAttrTypes()},
1188-
attrLabels: types.MapType{ElemType: types.StringType},
1189-
attrTags: types.SetType{ElemType: types.StringType},
1190-
attrDocumentJSON: jsontypes.NormalizedType{},
1191-
}}
1178+
return types.ObjectType{AttrTypes: ItemAttrTypes()}
11921179
}
11931180

11941181
// APIBodyToItem converts a raw entity document from the API list response
@@ -1198,9 +1185,9 @@ func APIBodyToItem(ctx context.Context, body map[string]any, diags *diag.Diagnos
11981185
var item tfModel
11991186
apiBodyToModel(ctx, body, &item, diags)
12001187
if diags.HasError() {
1201-
return types.ObjectNull(ItemObjectType().(types.ObjectType).AttrTypes)
1188+
return types.ObjectNull(ItemAttrTypes())
12021189
}
1203-
obj, d := types.ObjectValue(ItemObjectType().(types.ObjectType).AttrTypes, map[string]attr.Value{
1190+
obj, d := types.ObjectValue(ItemAttrTypes(), map[string]attr.Value{
12041191
"@timestamp": item.Timestamp,
12051192
attrEntity: item.Entity,
12061193
attrHost: item.Host,

0 commit comments

Comments
 (0)