-
Notifications
You must be signed in to change notification settings - Fork 266
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
Extensions: Add hooks to support virtual clusters #11064
base: master
Are you sure you want to change the base?
Conversation
3225ac2
to
82fc100
Compare
@mantis-toboggan-md finally got this to pass gates - refactored as we discussed. |
82fc100
to
37c7477
Compare
71c0394
to
29ec9b5
Compare
29ec9b5
to
06756d1
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.
Reviewing this, changes seem pretty self self-contained as it's targeting the provisioning.cattle.io.cluster
. I assume that since this is experimental, we don't want to document it right now, but in the future, if we open it, we need to add it to the documentation.
One last remark would be around using modelExtensions
instead of extending/reusing uiConfig
🤔
nevertheless, I would say that it 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.
Haven't given this a functional test, just looked at code.
Only minor comments. We are limiting model extensions to be singular though. Not sure we'll ever be in a scenario where different extensions might want to update things like deployment actions?
* @param cluster The cluster model (`provisioning.cattle.io.cluster`) | ||
* @returns Whether to use this provisioner for the given cluster. | ||
*/ | ||
useForModel(cluster: any): boolean; |
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 isn't wired in anywhere
* @param type Model type | ||
* @param clz Class for the model extension (constructor) | ||
*/ | ||
addModelExtension(type: string, clz: Function): void; |
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.
given clz
is a known function .. here (and shell/core/plugin.ts) should be typed
@@ -88,6 +88,11 @@ export default { | |||
}, | |||
|
|||
computed: { | |||
groupable() { |
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 going to break with Cody's SSP PR. We won't have access to all provisioning clusters (filteredRows) just a single pages worth.
*/ | ||
get customProvisionerHelper() { | ||
// Find the first model extension that says it can be used for this model | ||
return this.modelExtensions.find((modelExt) => modelExt.useFor ? modelExt.useFor(this) : false); |
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 there be a type / interface for modelExtension instances? missing this fn will trip up developers
return this.customProvisionerHelper?.parentCluster?.(this); | ||
} | ||
|
||
get groupByLabel() { |
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.
Think this is fine now, so just a comment, but in the future the plan is to group clusters by cluster class as well
} | ||
|
||
get groupByParent() { | ||
// Customer helper can report if the cluster has a parent cluster |
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.
typo Customer
Summary
Fixes #11065
This PR adds several hooks for virtual cluster support.
The main change is a new extension API
addModelExtension
- this is marked experimental for now - once we establish if we need any changes, we can remove that label.You can register model extensions and they are stored against a model type, e.g.
provisioning.cattle.io.cluster
. There is a method on the Steve base class to retrieve all of the model extensions for a given model type. You can register multiple model extensions for a given model.Beyond that, it is up to a given model to decide how to use these model extensions - i.e. a model needs to define an API for them and explicitly wire that into itself. This ensures we have a defined API for extensibility, rather than allowing a model extension to do anything it wants.
In this PR, we write a model extension into the provisioning cluster model to support the needs of virtual clusters.
Risk wise, this PR is designed to minimise impact to existing code, so the risk is small.
Areas or cases that should be tested
These hooks will be tested by extensions.
Current e2e test should validate that the hooks do not break existing functionality.
Checklist