-
Notifications
You must be signed in to change notification settings - Fork 207
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
Added configConverter which converts conf to yaml #584
Added configConverter which converts conf to yaml #584
Conversation
c7c8c66
to
e032adf
Compare
Codecov Report
@@ Coverage Diff @@
## main #584 +/- ##
============================================
+ Coverage 92.12% 92.29% +0.17%
Complexity 569 569
============================================
Files 71 71
Lines 1727 1727
Branches 144 144
============================================
+ Hits 1591 1594 +3
+ Misses 105 102 -3
Partials 31 31
Continue to review full report at Codecov.
|
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
class LogstashConfigConverterTest { |
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.
This test will have some overlap with the integration tests. If we aren't going to mock the internal classes, I think I'd prefer that we remove this test and only have the integration test to cover it.
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.
I think we can only have an integration test for this.
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.
Then let's just remove this test and the input file.
|
||
ObjectMapper mapper = new ObjectMapper(factory); | ||
|
||
String yamlFilePath = outputDirectory + "logstash.yaml"; |
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.
Using string append to create paths can be problematic. Please use File
or Paths
to form this string.
|
||
LogstashMapper logstashMapper = new LogstashMapper(); | ||
PipelineModel pipelineModel = logstashMapper.mapPipeline(logstashConfiguration); | ||
Map<String, Object> pipeline = Collections.singletonMap("log-pipeline", pipelineModel); |
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.
We don't know if the pipeline is a log-pipeline
or not. I'd be interested in using the filename as the pipeline name. For example a file named local-log-ingest.yaml
might be given the name local-log-ingest
.
If we don't take that approach, maybe use a constant value like logstash-converted-pipeline
.
|
||
ObjectMapper mapper = new ObjectMapper(factory); | ||
|
||
String yamlFilePath = outputDirectory + "logstash.yaml"; |
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.
Should we use the name of the original file in the generated file?
e.g. my-configuration-file.conf
-> my-configuration-file.yaml
.
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.
That makes sense because the user knows their file name, so they can just look for .yaml file for their .conf file
@@ -0,0 +1,56 @@ | |||
package org.opensearch.dataprepper.logstash.parser; |
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.
Also, I think this should be in the org.opensearch.dataprepper.logstash
package. You will need to update your usage of LogstashVisitor
with the full package name.
Like this:
org.opensearch.dataprepper.logstash.parser.LogstashVisitor visitor = new org.opensearch.dataprepper.logstash.parser.LogstashVisitor();
Signed-off-by: Asif Sohail Mohammed <[email protected]>
e032adf
to
219a8c1
Compare
LogstashParser parser = new LogstashParser(tokens); | ||
ParseTree tree = parser.config(); | ||
|
||
org.opensearch.dataprepper.logstash.parser.LogstashVisitor visitor = new LogstashVisitor(); |
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.
You need to have the fully qualified name on the right-side of the assignment, along with the new
.
org.opensearch.dataprepper.logstash.parser.LogstashVisitor visitor = new org.opensearch.dataprepper.logstash.parser.LogstashVisitor();
factory.disable(YAMLGenerator.Feature.SPLIT_LINES); | ||
factory.enable(YAMLGenerator.Feature.LITERAL_BLOCK_STYLE); | ||
|
||
ObjectMapper mapper = new ObjectMapper(factory); |
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.
You can simplify this by using the Builder pattern like:
ObjectMapper mapper = new ObjectMapper(YAMLFactory.builder()
.disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER)
.disable(YAMLGenerator.Feature.SPLIT_LINES)
.enable(YAMLGenerator.Feature.INDENT_ARRAYS_WITH_INDICATOR)
.enable(YAMLGenerator.Feature.LITERAL_BLOCK_STYLE)
.build());
219a8c1
to
7cbd613
Compare
.enable(YAMLGenerator.Feature.LITERAL_BLOCK_STYLE) | ||
.build()); | ||
|
||
String confFileName = configurationFilePath.getFileName().toString(); |
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.
Do we have all the fields that should not be changed final
?
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.
No, will update it
Signed-off-by: Asif Sohail Mohammed <[email protected]>
7cbd613
to
4fb2563
Compare
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.
Checked comments from @sshivanii addressed.
Description
Added ConfigConverter which takes .conf file path and returns .yaml file path
Issues Resolved
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.