-
Notifications
You must be signed in to change notification settings - Fork 68
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
Add validation for dataset type #501
Conversation
The valid dataset types at the moment are logs, metrics and events. events will be removed in the future but at the moment it is still used in the endpoint package. As soon as this is removed, the code here will be cleaned up. With recent changes to the code, the datasets were not validated anymore during build or running the registry. This is now changed by adding validate for datasets every time a package is created.
dc2d3bd
to
59b81eb
Compare
@jonathan-buttner Would be great to get your feedback on this one as the endpoint package will need an update. |
util/dataset.go
Outdated
@@ -24,6 +24,13 @@ const ( | |||
DirIngestPipeline = "ingest-pipeline" | |||
) | |||
|
|||
var ValidTypes = map[string]interface{}{ | |||
"logs": nil, |
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 might cause problems in the future if someone would like to check if the value logs
exists. They would get a nil
value :) Maybe bool instead?
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 went an other approach and made the second part a String which is something we could also show in a UI if needed. Thinking of the case that someday we might have a /types
endpoint if someone wants to know all the available dataset types.
@@ -24,6 +24,13 @@ const ( | |||
DirIngestPipeline = "ingest-pipeline" | |||
) | |||
|
|||
var validTypes = map[string]string{ | |||
"logs": "Logs", |
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.
For string-to-string enums there is a different approach recommended: stringer (see: https://godoc.org/golang.org/x/tools/cmd/stringer).
We can leave it as, it's not a full blown enum
The valid dataset types at the moment are logs, metrics and events. events will be removed in the future but at the moment it is still used in the endpoint package. As soon as this is removed, the code here will be cleaned up.
With recent changes to the code, the datasets were not validated anymore during build or running the registry. This is now changed by adding validate for datasets every time a package is created.
Part of #478