-
Notifications
You must be signed in to change notification settings - Fork 8
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
Clusterclass variables #16
Clusterclass variables #16
Conversation
76cccb3
to
2ff9339
Compare
I updated this PR to add (limited) support for machine deployment variable overrides. It's limited because I don't think we can reasonably parse variable names if a patch is using |
const required = this.variable?.required; | ||
|
||
if (required) { | ||
// out.push(formRulesGenerator(this.$store.getters['i18n/t'], { key: this.variable.name }).required as Validator); |
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.
commented out code
default: () => {} | ||
}, | ||
|
||
// <cluster.x-k8s.io>.spec.topology.variables |
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.
is this intentional?
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.
Originally yeah, but I guess it's redundant now that the cluster variables are typed. I've removed it
* remove any variables not defined in the new cluster class | ||
* if a variable is defined in both cluster classes, clear out the old default | ||
* set default values from the new cluster class definitions | ||
* if a variable is defined in both old and new cluster classes, and the user has set its value to something other than the old default, preserve 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.
Are you sure we want to preserve it? I'd reset it to the default
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 mean I guess it depends on why a user would be changing the cluster class after entering in variables. I would definitely find it tiresome to re-enter data if I was swapping between cluster classes to verify that I had the one I wanted.
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.
Fair.
pkg/capi/util/validators.ts
Outdated
import { Validator, ValidationOptions } from '@shell/utils/validators/formRules'; | ||
import { Translation } from '@shell/types/t'; | ||
|
||
// const stringFormats = { |
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.
is this intentional?
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.
No, sorry - I updated the PR to include the validation I had started writing out here & removed this.
} | ||
}, | ||
|
||
newComponentType(variableDef: ClusterClassVariable, i: number) { |
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'm not crazy about this nor the re-render key hack, but I found it absurdly convoluted to create a new row for each new component type using purely scss; this is easy to follow ultimately.
@@ -0,0 +1,115 @@ | |||
<script lang="ts"> |
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 is just a simple way for me to test the CCVariables component - I will remove it before merging.
5d575e5
to
73a1ac5
Compare
74e5d54
to
30c7bec
Compare
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 good with some non-blocking comments
|
||
const patches = this.clusterClass?.spec?.patches || []; | ||
|
||
patches.forEach((p) => { |
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.
type is missing
const neuDef = (neu || []).find(n => n.name === existingVar.name); | ||
|
||
if (!neuDef) { | ||
return acc; |
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.
IMO, if there is no default and currently it is set to the old default, I think it should be an empty value and not the old default
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've updated inline comments to make this function clearer; from my own testing, it does what you're describing, but let me know if I missed something.
const required = this.variable?.required; | ||
|
||
if (required && this.validateRequired) { | ||
out.push(val => !isDefined(val) ? t('validation.required', { key: this.variable.name }) : undefined); |
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.
type is missing
pkg/capi/l10n/en-us.yaml
Outdated
exclusiveMaxValue: '"{key}" must be less than {maximum}.' | ||
exclusiveMinValue: '"{key}" must be greater than {minimum}.' | ||
maxItems: '"{key}" may not contain more than {maxItems} items.' |
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.
Should we handle a case of 1 item separately? otherwise we are getting "Must not contain more than 1 items" which is not correct.
pkg/capi/l10n/en-us.yaml
Outdated
exclusiveMinValue: '"{key}" must be greater than {minimum}.' | ||
maxItems: '"{key}" may not contain more than {maxItems} items.' | ||
minItems: '"{key}" must contain at least {minItems} items.' |
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.
same here
This PR adds components to generate form elements from clusterclass variable definitions. I used this modified docker quickstart clusterclass to test all input and validation options: