Skip to content

Commit 2c00e6b

Browse files
authored
Import patterns from ECS (#772)
1 parent 58aa8b3 commit 2c00e6b

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

internal/fields/dependency_manager.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,10 @@ func transformImportedField(fd FieldDefinition) common.MapStr {
229229
m["description"] = fd.Description
230230
}
231231

232+
if fd.Pattern != "" {
233+
m["pattern"] = fd.Pattern
234+
}
235+
232236
if fd.Index != nil {
233237
m["index"] = *fd.Index
234238
}

internal/fields/dependency_manager_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,25 @@ func TestDependencyManagerInjectExternalFields(t *testing.T) {
160160
changed: true,
161161
valid: true,
162162
},
163+
{
164+
title: "external with pattern",
165+
defs: []common.MapStr{
166+
{
167+
"name": "source.mac",
168+
"external": "test",
169+
},
170+
},
171+
result: []common.MapStr{
172+
{
173+
"name": "source.mac",
174+
"type": "keyword",
175+
"description": "MAC address of the source.",
176+
"pattern": "^[A-F0-9]{2}(-[A-F0-9]{2}){5,}$",
177+
},
178+
},
179+
changed: true,
180+
valid: true,
181+
},
163182
{
164183
title: "override not indexed external",
165184
defs: []common.MapStr{
@@ -228,6 +247,12 @@ func TestDependencyManagerInjectExternalFields(t *testing.T) {
228247
Index: &indexFalse,
229248
DocValues: &indexFalse,
230249
},
250+
{
251+
Name: "source.mac",
252+
Description: "MAC address of the source.",
253+
Pattern: "^[A-F0-9]{2}(-[A-F0-9]{2}){5,}$",
254+
Type: "keyword",
255+
},
231256
}}
232257
dm := &DependencyManager{schema: schema}
233258

0 commit comments

Comments
 (0)