-
Notifications
You must be signed in to change notification settings - Fork 87
template_path validation for streams and template policies #986
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
template_path validation for streams and template policies #986
Conversation
code/go/internal/validator/semantic/validate_data_stream_streams_template_path.go
Outdated
Show resolved
Hide resolved
test-integrations |
Created or updated PR in integrations repository to test this version. Check elastic/integrations#15480 |
code/go/internal/validator/semantic/validate_data_stream_streams_template_path.go
Outdated
Show resolved
Hide resolved
code/go/internal/validator/semantic/validate_data_stream_streams_template_path.go
Outdated
Show resolved
Hide resolved
code/go/internal/validator/semantic/validate_input_policy_template_path.go
Outdated
Show resolved
Hide resolved
code/go/internal/validator/semantic/validate_input_policy_template_path.go
Outdated
Show resolved
Hide resolved
code/go/internal/validator/semantic/validate_input_policy_template_path.go
Outdated
Show resolved
Hide resolved
code/go/internal/validator/semantic/validate_data_stream_streams_template_path.go
Outdated
Show resolved
Hide resolved
code/go/internal/validator/semantic/validate_data_stream_streams_template_path.go
Outdated
Show resolved
Hide resolved
04ef625
to
05904c0
Compare
…orresponding tests
…ding valid and invalid cases
…y removing manifestPath, constructing it internally instead.
…rapping errors in validateDataStreamManifestTemplates and ValidateInputPolicyTemplates functions.
38ba51b
to
526c665
Compare
…th.Join for improved path construction and update error messages in tests for consistency.
0e0ecdb
to
364d708
Compare
…, replacing mock filesystem implementation for better clarity and maintainability.
…fined error variables
…ce, including required fields and template paths for policy templates and stream templates.
This reverts commit bfe466b.
test-integrations |
Created or updated PR in integrations repository to test this version. Check elastic/integrations#15480 |
test-integrations |
Created or updated PR in integrations repository to test this version. Check elastic/integrations#15480 |
test-integrations |
Created or updated PR in integrations repository to test this version. Check elastic/integrations#15480 |
code/go/internal/validator/semantic/validate_data_stream_streams_template_path.go
Outdated
Show resolved
Hide resolved
code/go/internal/validator/semantic/validate_data_stream_streams_template_path.go
Outdated
Show resolved
Hide resolved
if input.TemplatePath == "" { | ||
continue // template_path is optional | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, in this case if there is not template_path defined, does fleet looks for any default input template ?
I was wondering if it should be added some other validation here or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from what i have investigated, when an integration
has inputs
within its policy_template
, the template_paths
that are not explicitly described there, are taken from the data_streams
.
there is some logic i don't fully understand but my guess is that from the assetMap, it takes the data stream name from the package manifest inputs and looks for the data stream associated to it. Perhaps the validation to be done at package spec should be that, this inputs need to have a data_stream associated to be able to "skip" describing the template?
code/go/internal/validator/semantic/validate_data_stream_streams_template_path.go
Outdated
Show resolved
Hide resolved
code/go/internal/validator/semantic/validate_data_stream_streams_template_path.go
Outdated
Show resolved
Hide resolved
…tes and ValidateInputPolicyTemplates into ValidatePolicyTemplates
💔 Build Failed
Failed CI Steps
History
|
@mrodm @nchaulet I've updated the PR taking into account how fleet handled the template_paths for integrations with inputs. After some consideration i've realized the entry point is always the I've added the train of thought on the PR description, and updated the code to validate like so. I've unified the validation, as i was taking into account the streams where separated from the package manifest policy.. but with this change there should be just one validation rule, as the data_streams templates should be a match with the manifest inputs ??? |
closing this in favour of #1000 |
What does this PR do?
Add validation for policy templates template_path.
Depending on the type of package, input or integration, the template_path for the policy_template can be found of different locations.
In the case of input type, the template_path field under policy_template is required, so if this is empty and error is thrown. If the value exist, its looked up under
/agents/input
folder at the root of the package.In the case of integration type, the template_path is under policy_template.inputs. This field is optional at the package manifest.
/agents/input
folder at the root of the package.input.type
as key, validation looks at all the data streams manifest looking for the stream.input name that matches the input.type. Once there is a match, the template_path of the stream is also not required.template_field
is not empty at the stream manifest, validation checks this file exists under/agents/stream
folder at the root of the stream folder (data_stream//).template_field
is empty, the default file namestream.yml.hbs
is checked.Why is it important?
When Fleet compiles the templates of the policies and the data streams, if the file does not exist or has not been declared at the manifest, it fails. This prevents this error by validating the package before it is installed.
Checklist
Added unit tests for the new validation functions.
Added spec tests with new testdata packages.
I have added test packages to
test/packages
that prove my change is effective.I have added an entry in
spec/changelog.yml
.Related issues
Resolves #703