-
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
KEP-35 Impl Part1: New parameter types and attributes #1705
Conversation
Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
Extended integration test operator Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
Fixed bug in required parameter validation Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
Signed-off-by: Andreas Neumann <aneumann@mesosphere.com> # Conflicts: # go.mod # go.sum # pkg/kudoctl/kudoinit/crd/bindata.go
Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
Signed-off-by: Andreas Neumann <aneumann@mesosphere.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.
Did a first pass, I don't think there's blocker. I would still like to see replies to some of my questions before I am ready to approve :)
Nice work!
@@ -30,4 +30,7 @@ type Parameter struct { | |||
|
|||
// Specifies if the parameter can be changed after the initial installation of the operator | |||
Immutable *bool `json:"immutable,omitempty"` | |||
|
|||
// Defines a list of allowed values. If Default is set and Enum is not nil, the value must be in this list as well | |||
Enum *[]string `json:"enum,omitempty"` |
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 is this pointer to slice? 🤔
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 intention was to make it clear if any value is set or not - but as an "enum" with no entries would be invalid anyway, it could be an unpointered slice as well.
I kind of like it as a pointer, but i'm not really married to it - if it bothers you, i'll change 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.
ah you mean you want to validate for user providing
enum:
default: xxx
? Well ... okay :)
pkg/kudoctl/packages/types.go
Outdated
@@ -37,6 +37,12 @@ type Parameter struct { | |||
Trigger string `json:"trigger,omitempty"` | |||
Type kudoapi.ParameterType `json:"type,omitempty"` | |||
Immutable *bool `json:"immutable,omitempty"` | |||
Enum *[]string `json:"enum,omitempty"` | |||
|
|||
// The following fields are descriptive only and are not used in the OperatorVersion |
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 did not really understand what does the descriptive mean here, maybe it's just my problem buuut ... could we maybe say something like that these are prperties that live only on the package level and are used for additional data during the installation and are not necessary server-side? Something along those lines... I actually had to go back to KEP to understand this better
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.
👍 Added a few more lines
|
||
type Group struct { | ||
Name string `json:"name,omitempty"` | ||
DisplayName string `json:"displayName,omitempty"` |
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 do we need displayName? 🤔
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.
To allow a nice human readable title for the group, i.e.
Name: "readiness"
DisplayName: "Readiness Parameters"
for _, p := range pf.Params.Parameters { | ||
if p.Group != "" { | ||
if _, ok := groups[p.Group]; !ok { | ||
res.AddParamWarning(p.Name, "has a group that is not defined in the group section") |
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 is this just warn and not 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.
Because I think it's ok to not define the groups - in this case they'd have to be displayed without a description and displayName, simply with the group name.
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.
hmm I thought that a potential UI will read all the groups and then render params in those groups. But then most of the params are not expected to be in any group or be in group but that group not defined? That sounds like a lot of edge cases a potential UI have to handle 🤔
Just a thought...
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.
Yeah... Valid point. I guess it'd be acceptable if people want to use a group that they have to define the group first. I'll make it mandatory.
Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
Signed-off-by: Andreas Neumann <aneumann@mesosphere.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.
LGTM!
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.
Looks much better now, thank you!
I have one more idea around moving around the validate methods to make the encapsulation a bit better but otherwise 👍
@@ -30,4 +30,7 @@ type Parameter struct { | |||
|
|||
// Specifies if the parameter can be changed after the initial installation of the operator | |||
Immutable *bool `json:"immutable,omitempty"` | |||
|
|||
// Defines a list of allowed values. If Default is set and Enum is not nil, the value must be in this list as well | |||
Enum *[]string `json:"enum,omitempty"` |
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.
ah you mean you want to validate for user providing
enum:
default: xxx
? Well ... okay :)
} | ||
for _, enumVal := range p.EnumValues() { | ||
|
||
if err := kudoapi.ValidateParameterValueForType(p.Type, enumVal); err != 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.
why is this enum validation not part of some kind of p.Validate
as well? 🤔 then ValidateParameterValueForType
could have been made private
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.
Well, one reason is that here in this function we have a package.Parameter
and not a kudoapi.Parameter
- This caused quite a bit of headache while organising this - both types are distinct but share quite a bit of common functionality.
This is one of the cases where I'd really like to have generics ;)
What this PR does / why we need it:
Part 1 of KEP 35:
New Types:
New Attributes:
Only in the package format: