Skip to content
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

Merged
merged 14 commits into from
Oct 9, 2020

Conversation

ANeumann82
Copy link
Member

What this PR does / why we need it:
Part 1 of KEP 35:

New Types:

  • integer
  • number
  • boolean

New Attributes:

  • enum

Only in the package format:

  • hint
  • advanced
  • group

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>
@ANeumann82 ANeumann82 added release/blocker release/highlight This PR is a highlight for the next release labels Oct 2, 2020
Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
Copy link
Contributor

@alenkacz alenkacz left a 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"`
Copy link
Contributor

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? 🤔

Copy link
Member Author

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 :)

Copy link
Contributor

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/apis/kudo/v1beta1/parameter_types_helpers.go Outdated Show resolved Hide resolved
@@ -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
Copy link
Contributor

@alenkacz alenkacz Oct 8, 2020

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

Copy link
Member Author

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"`
Copy link
Contributor

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? 🤔

Copy link
Member Author

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")
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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...

Copy link
Member Author

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>
Copy link
Member

@nfnt nfnt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@alenkacz alenkacz left a 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"`
Copy link
Contributor

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 {
Copy link
Contributor

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

Copy link
Member Author

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 ;)

@ANeumann82 ANeumann82 merged commit 040d5ed into main Oct 9, 2020
@ANeumann82 ANeumann82 deleted the an/new-param-types-and-attributes branch October 9, 2020 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release/blocker release/highlight This PR is a highlight for the next release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants