-
Notifications
You must be signed in to change notification settings - Fork 1
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
Handle default arguments and argument number to avoid errors #121
Conversation
This commit adds the files that are specific to Grafana's fork that are not intended to be included in the upstream. This files are already present in the commit history (they were deleted), but this is an attempt of a fresh start on top of the upstream's `main`. At the moment, this should the only commit we expect to skip when sending our changes.
* Fix exponentialMovingAverage panic The panic was happening when the window size was greater than the length of the values. Now if that happens no panics occur and the average is returned. This matches graphiteweb. * Add support for Graphite web toLowerCase function * Add tests for toLowerCase function * Update glue.go * Update COMPATIBILITY.md to show support of toLowerCase * Add support for Graphite web toUpperCase function * Add tests for toUpperCase function * Update glue.go * Update COMPATIBILITY.md to include toUpperCase function * Add support for Graphite web sumSeriesLists function * Add tests for sumSeriesLists * Update glue.go * Update COMPATIBILITY.md to include sumSeriesLists * Fix problems that I accidentally introduced while trying to resolve merge conflict * Another attempt to fix previous problem Apparantly there is a directory that gen.go wasn't expecting and `go generate` in expr/functions produced `glue.go` file that didn't compile fix both generator and glue * Adds Drone and Github workflow for Grafana's fork This commit adds the files that are specific to Grafana's fork that are not intended to be included in the upstream. This files are already present in the commit history (they were deleted), but this is an attempt of a fresh start on top of the upstream's `main`. At the moment, this should the only commit we expect to skip when sending our changes. Co-authored-by: Nicolás Pazos <npazosmendez@gmail.com> Co-authored-by: Vladimir Smirnov <civiloid@google.com>
This comment has been minimized.
This comment has been minimized.
if err != nil { | ||
return nil, err | ||
} | ||
callback, err := e.GetStringArgDefault(1, "average") |
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.
what is the story behind this part of the change?
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 just replaced the switch statement with functions that will set the default argument, but I can see that there could be a bug here, so I'll revert that change
n = 1 | ||
consolidation, err = e.GetStringArg(1) | ||
if err != nil { | ||
return nil, err | ||
} |
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.
Why was this deleted?
@@ -28,7 +28,7 @@ func New(configFile string) []interfaces.FunctionMetadata { | |||
return res | |||
} | |||
|
|||
// squareRoot(seriesList) | |||
// randomWalk(seriesList, step=60) |
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: this hould be randomWalk(name, step=60)
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
e110194
to
efbb16c
Compare
Go coverage report: Click to expand.
Go lint report: No issues found. 😎 |
Closing in favor of go-graphite#712 |
This PR adds error handling to function arguments. If fewer arguments than the minimum required by that function are passed in, then a missing argument error is now returned. Additionally, some functions with default values for arguments were missing the default, so those have been updated. This will prevented unexpected out-of-index panics and other errors from occurring.