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

Allow to define expected values in fields definitions #616

Merged
merged 2 commits into from
Sep 27, 2023

Conversation

jsoriano
Copy link
Member

@jsoriano jsoriano commented Sep 27, 2023

What does this PR do?

Add expected_values to fields definitions.

Why is it important?

This setting would be used in some packages to override values in ECS definitions (see elastic/elastic-package#1472).
It can be used in general to define expected values.

Checklist

Related issues

mrodm
mrodm previously approved these changes Sep 27, 2023
@elasticmachine
Copy link

💚 Build Succeeded

History

cc @jsoriano

@jsoriano jsoriano merged commit 4253eff into elastic:main Sep 27, 2023
1 check passed
@jsoriano jsoriano deleted the fields-expected-values branch September 27, 2023 17:32
@chrisberkhout
Copy link

Thanks for the quick action on this!

I rebuilt elastic-package with this and it did let me define my own expected_values, as in the test. I also tried expected_values: [] (expecting it to allow any values) and that failed with:

file "...fields.yml" is invalid: field 0.expected_values: Invalid type. Expected: array, given: null

I'm not familiar with the steps between the spec and the validation, but I think an array of strings specified in JSON Schema can be empty if it doesn't also have a minItems constraint.

As mentioned elsewhere, I found a different workaround for my immediate issue.

@jsoriano
Copy link
Member Author

jsoriano commented Oct 2, 2023

Thanks for reporting your finding, I have created an specific issue for that, it may be a general problem with arrays #630

Apart of the validation issue we may need to review how elastic-package combines these settings, as this is currently based on length checks: https://github.com/elastic/elastic-package/blob/9d8ce35eb3051b832057b37e75ad454e28069ee6/internal/fields/dependency_manager.go#L349

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tests fail due to ECS expected values
4 participants