-
Notifications
You must be signed in to change notification settings - Fork 104
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
Support typed parameter values #1376
Conversation
This introduces the 'string', 'list', and 'dict' types for parameter values. By default, the 'string' type is used. This type is used for a simple value. The types 'list' and 'dict' can be used to describe lists and dictonaries. Their values are input using YAML. Signed-off-by: Jan Schlicht <jan@d2iq.com>
Signed-off-by: Jan Schlicht <jan@d2iq.com>
Signed-off-by: Jan Schlicht <jan@d2iq.com>
I don't really know what |
Signed-off-by: Jan Schlicht <jan@d2iq.com>
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.
nice work so far... some nits
I strongly encourage that we move functions that are not "kudo" features out of kudo package. (I realize there is some examples that deviate)
Also... I'm assuming that maps and lists (our new types) are restricted to values which are strings. It should be great to have the documented... but also tests that show incorrect cases failing... such as a map of lists or a map of maps.
|
||
stringVal, ok := val.(string) | ||
if !ok { | ||
return task, fmt.Errorf("value of parameter %s isn't a string", tt.Parameter) |
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.
shouldn't there be an error on the use of a toggle param that is NOT a string... which is technically a bool ?
It seems like we are missing that..
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.
Isn't this what this check does? We try to cast to a string, if it's !ok
we error out?
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.
Isn't that done by the line below? If stringVal
is neither "true" nor "false", strconv.ParseBool
will return an error.
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.
The error message is somewhat confusing, we expect a string/boolean there. Maybe smth. like:
return task, fmt.Errorf("value of parameter %s isn't a string", tt.Parameter) | |
return task, fmt.Errorf("value of parameter %s must be either 'true' or 'false'", tt.Parameter) |
wdyt?
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 disagree, because this is checked in the line below when parsing the string to bool. This line is checking that typeof(interface) == string
, not the content of the string.
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.
If it's not a string it can't be true
or false
which is what we expect.
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.
Booleans can also be represented by a boolean or integer type. Also strconv.ParseBool
accepts 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False.
At this point it's only clear whether the input is a string or not, the content of the input isn't known yet.
* Moves type conversion functions to `convert` package * Renames parameter types * Different value type switch Signed-off-by: Jan Schlicht <jan@d2iq.com>
Signed-off-by: Jan Schlicht <jan@d2iq.com>
Signed-off-by: Jan Schlicht <jan@d2iq.com>
Signed-off-by: Jan Schlicht <jan@d2iq.com>
Signed-off-by: Jan Schlicht <jan@d2iq.com>
Signed-off-by: Jan Schlicht <jan@d2iq.com>
Signed-off-by: Jan Schlicht <jan@d2iq.com>
Signed-off-by: Jan Schlicht <jan@d2iq.com>
Signed-off-by: Jan Schlicht <jan@d2iq.com>
Signed-off-by: Jan Schlicht <jan@d2iq.com>
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.
Nice work! Some naming requests, and the integration test could be improved, but this is getting close!
Signed-off-by: Jan Schlicht <jan@d2iq.com>
Signed-off-by: Jan Schlicht <jan@d2iq.com>
Signed-off-by: Jan Schlicht <jan@d2iq.com>
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.
man I love the single document params approach so much better!
A few minor nits... the only real blocker for me is around ToYAMLMap
and ToYAMLArray
nice work!
Signed-off-by: Jan Schlicht <jan@d2iq.com>
Signed-off-by: Jan Schlicht <jan@d2iq.com>
Signed-off-by: Jan Schlicht <jan@d2iq.com>
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.
a couple of comments or nits... nothing blocking. nice work 👏
Signed-off-by: Jan Schlicht <jan@d2iq.com> Co-Authored-By: Ken Sipe <kensipe@gmail.com>
Signed-off-by: Jan Schlicht <jan@d2iq.com>
The change request has been handled... feel free to reject again if appropriate
test/integration/parameter-types-operator/operator/templates/deployment.yaml
Show resolved
Hide resolved
Signed-off-by: Jan Schlicht <jan@d2iq.com>
Signed-off-by: Jan Schlicht <jan@d2iq.com>
This introduces the 'string', 'array', and 'masp' types for parameter values. By default, the 'string' type is used. This type is used for a simple value. The types 'array' and 'map' can be used to describe lists and dictionaries. Their values are input using YAML. Co-Authored-By: Ken Sipe <kensipe@gmail.com> Signed-off-by: Jan Schlicht <jan@d2iq.com> Signed-off-by: Thomas Runyon <runyontr@gmail.com>
What this PR does / why we need it:
This introduces the 'string', 'array', and 'map' types for parameter values. By default, the 'string' type is used. This type is used for a simple value. The types 'array' and 'map' can be used to describe lists and dictonaries. Their values are input using YAML.
Fixes #1349