Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require object_type for object fields #628

Merged
merged 3 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
19 changes: 18 additions & 1 deletion spec/integration/data_stream/fields/fields.spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,14 @@ spec:
description: >
Name of field. Names containing dots are automatically split into
sub-fields.
Names with wildcards generate dynamic mappings.
type: string
pattern: '^[\-*_\/@A-Za-z0-9]+(\.[\-*_\/@A-Za-z0-9]+)*$'

type:
description: Datatype of field
description: >
Datatype of field. If the type is set to object, a dynamic mapping is created. In this case, if the name doesn't
contain any wildcard, the wildcard is added as the last segment of the path.
type: string
enum:
- aggregate_metric_double
Expand Down Expand Up @@ -521,11 +524,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
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