-
Notifications
You must be signed in to change notification settings - Fork 67
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
Validate ingest pipelines while packaging #426
Conversation
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.
Could you add a line to the changelog?
_, errYAML := os.Stat(yamlPipelinePath) | ||
|
||
var validFound bool | ||
if !os.IsNotExist(errJSON) { |
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.
Nit: Why not put the checks for each error directly after where the error happened?
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.
Fixed
util/dataset.go
Outdated
if err != nil { | ||
return errors.Wrapf(err, "reading ingest pipeline file failed") | ||
} | ||
ext := pipelinePath[strings.LastIndex(pipelinePath, ".")+1:] |
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.
filepath.Ext
?
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.
Thanks, fixed
util/dataset.go
Outdated
func validateIngestPipelineFile(pipelinePath string) error { | ||
f, err := ioutil.ReadFile(pipelinePath) | ||
if err != nil { | ||
return errors.Wrapf(err, "reading ingest pipeline file failed") |
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.
It would be nice to have the path reported as part of the error which makes it much easier to find which file did not parse.
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.
Fixed
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.
Approving as code is correct. Changelog still missing ;-)
util/dataset.go
Outdated
_, errJSON := os.Stat(jsonPipelinePath) | ||
if errJSON != nil && !os.IsNotExist(errJSON) { | ||
return errors.Wrapf(errJSON, "stat ingest pipeline JSON file failed (path: %s)", jsonPipelinePath) | ||
} else if !os.IsNotExist(errJSON) { |
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 don't think you need an else here as if it matches before, it will return.
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.
Fixed
util/dataset.go
Outdated
err = validateIngestPipelineFile(jsonPipelinePath) | ||
if err != nil { | ||
return errors.Wrapf(err, "validating ingest pipeline JSON file failed (path: %s)", jsonPipelinePath) | ||
} else { |
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 else needed as it returns on 167
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.
Fixed
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.
is it? :-D Perhaps I'm commenting too early ;-)
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 was looking on the other if-else struct. Now, it's truly fixed :D
My bad, forgot about it. Sorry! |
Changes:
Issue: #404