Skip to content

Commit

Permalink
Require object_type for object fields
Browse files Browse the repository at this point in the history
  • Loading branch information
jsoriano committed Oct 2, 2023
1 parent f022063 commit d4b4280
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 4 deletions.
1 change: 1 addition & 0 deletions code/go/pkg/validator/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ func TestValidateFile(t *testing.T) {
[]string{
`field 0.type: 0.type must be one of the following: "aggregate_metric_double", "alias", "histogram", "constant_keyword", "text", "match_only_text", "keyword", "long", "integer", "short", "byte", "double", "float", "half_float", "scaled_float", "date", "date_nanos", "boolean", "binary", "integer_range", "float_range", "long_range", "double_range", "date_range", "ip_range", "group", "geo_point", "object", "ip", "nested", "flattened", "wildcard", "version", "unsigned_long"`,
`field "my_custom_date" of type keyword can't set date_format. date_format is allowed for date field type only`,
`field 2: object_type is required`,
},
},
"deploy_custom_agent_invalid_property": {
Expand Down
3 changes: 3 additions & 0 deletions spec/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
- description: Make exception for legacy input controls
type: enhancement
link: https://github.com/elastic/package-spec/pull/619
- description: `object_type` is mandatory when `object: type` is used.
type: bugfix
link: https://github.com/elastic/package-spec/pull/628
- version: 2.13.1-next
changes:
- description: Prepare for next version
Expand Down
14 changes: 14 additions & 0 deletions spec/integration/data_stream/fields/fields.spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -521,11 +521,25 @@ spec:
required:
- type
- object_type
- if:
properties:
type:
const: object
required:
- type
then:
required:
- object_type

required:
- name

# JSON patches for newer versions should be placed on top
versions:
- before: 3.0.0
patch:
- op: remove
path: "/items/allOf/6" # removing requirement of object_type when type is object
- before: 2.10.0
patch:
- op: remove
Expand Down
4 changes: 3 additions & 1 deletion test/packages/bad_fields/data_stream/foo/fields/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
type: array
- name: my_custom_date
type: keyword
date_format: yyyy-MM-dd
date_format: yyyy-MM-dd
- name: object_without_object_type.*
type: object
9 changes: 6 additions & 3 deletions test/packages/bad_fields/manifest.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
format_version: 2.7.0
format_version: 3.0.0
name: bad_fields
title: "Bad Fields"
version: 0.0.1
Expand All @@ -9,8 +9,10 @@ type: integration
categories:
- custom
conditions:
kibana.version: "^8.4.1"
elastic.subscription: "basic"
kibana:
version: "^8.4.1"
elastic:
subscription: "basic"
screenshots:
- src: /img/sample-screenshot.png
title: Sample screenshot
Expand All @@ -30,4 +32,5 @@ policy_templates:
title: Collect sample logs from instances
description: Collecting sample logs
owner:
type: elastic
github: elastic/ecosystem
Original file line number Diff line number Diff line change
Expand Up @@ -356,4 +356,5 @@
type: date
- name: user_provided_metadata
type: object
object_type: keyword
enabled: false

0 comments on commit d4b4280

Please sign in to comment.