Skip to content

Commit

Permalink
adapt to common.Field -> mapping.Field move
Browse files Browse the repository at this point in the history
  • Loading branch information
graphaelli committed Mar 22, 2019
1 parent a59a43b commit 4f4e9e6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
15 changes: 8 additions & 7 deletions tests/fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (

"github.com/elastic/apm-server/tests/loader"
"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/mapping"
)

// This test checks
Expand Down Expand Up @@ -191,7 +192,7 @@ func fetchFlattenedFieldNames(paths []string, filters ...filter) (*Set, error) {
return fields, nil
}

func flattenFieldNames(fields []common.Field, prefix string, flattened *Set, filters ...filter) {
func flattenFieldNames(fields []mapping.Field, prefix string, flattened *Set, filters ...filter) {
for _, f := range fields {
key := strConcat(prefix, f.Name, ".")
add := true
Expand All @@ -205,8 +206,8 @@ func flattenFieldNames(fields []common.Field, prefix string, flattened *Set, fil
}
}

func loadFields(yamlPath string) ([]common.Field, error) {
fields := []common.Field{}
func loadFields(yamlPath string) ([]mapping.Field, error) {
fields := []mapping.Field{}

yaml, err := ioutil.ReadFile(yamlPath)
if err != nil {
Expand All @@ -224,16 +225,16 @@ func loadFields(yamlPath string) ([]common.Field, error) {
}

// false to exclude field
type filter func(common.Field) bool
type filter func(mapping.Field) bool

func hasName(f common.Field) bool {
func hasName(f mapping.Field) bool {
return f.Name != ""
}

func isEnabled(f common.Field) bool {
func isEnabled(f mapping.Field) bool {
return f.Enabled == nil || *f.Enabled
}

func isDisabled(f common.Field) bool {
func isDisabled(f mapping.Field) bool {
return f.Enabled != nil && !*f.Enabled
}
4 changes: 2 additions & 2 deletions tests/json_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/stretchr/testify/require"

"github.com/elastic/beats/libbeat/beat"
"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/mapping"
)

type TestProcessor interface {
Expand Down Expand Up @@ -187,7 +187,7 @@ func (ps *ProcessorSetup) KeywordLimitation(t *testing.T, keywordExceptionKeys *

// fetch keyword restricted field names from ES template
keywordFields, err := fetchFlattenedFieldNames(ps.TemplatePaths, hasName,
func(f common.Field) bool { return f.Type == "keyword" })
func(f mapping.Field) bool { return f.Type == "keyword" })
require.NoError(t, err)

// fetch length restricted field names from json schema
Expand Down

0 comments on commit 4f4e9e6

Please sign in to comment.