feat(plugins): remove immutability of pluginDefinitionRef.Name#1941
Merged
feat(plugins): remove immutability of pluginDefinitionRef.Name#1941
Conversation
with this change both Plugins & PluginPresets may allow to change the name of the referenced PluginDefintion
10f4c6b to
dfeb6d8
Compare
mikolajkucinski
approved these changes
Apr 23, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR changes the admission behavior for Plugin and PluginPreset resources so that the referenced pluginDefinitionRef.name is no longer treated as immutable, enabling users to switch the referenced (Cluster-)PluginDefinition after creation.
Changes:
- Removed webhook immutability validation for
spec.pluginDefinitionRef.nameonPluginupdates. - Removed webhook immutability validation for
spec.plugin.pluginDefinitionRef.nameonPluginPresetupdates. - Updated webhook tests to expect pluginDefinition reference name changes to be accepted.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
internal/webhook/v1alpha1/plugin_webhook.go |
Removes immutability enforcement for Plugin’s pluginDefinitionRef.name on update. |
internal/webhook/v1alpha1/plugin_webhook_test.go |
Updates tests to ensure Plugin updates can change pluginDefinitionRef.name (including changing back). |
internal/webhook/v1alpha1/pluginpreset_webhook.go |
Removes immutability enforcement for PluginPreset’s pluginDefinitionRef.name on update. |
internal/webhook/v1alpha1/pluginpreset_webhook_test.go |
Updates tests to expect PluginPreset updates can change pluginDefinitionRef.name. |
Comments suppressed due to low confidence (1)
internal/webhook/v1alpha1/pluginpreset_webhook.go:178
- ValidateUpdatePluginPreset no longer enforces immutability of pluginDefinitionRef.name, but it also doesn't validate that the updated pluginDefinitionRef (name/kind) is set and refers to an existing (Cluster-)PluginDefinition, nor does it re-validate optionValues / clusterOptionOverrides against the new definition. This allows updating a PluginPreset to an invalid/non-existent PluginDefinition (or clearing the name entirely), which will likely break reconciliation. Consider reusing the same validation as ValidateCreatePluginPreset (or extracting shared validation) inside ValidateUpdatePluginPreset so updates still require a valid definition reference and valid option values.
func ValidateUpdatePluginPreset(ctx context.Context, c client.Client, oldPluginPreset, pluginPreset *greenhousev1alpha1.PluginPreset) (admission.Warnings, error) {
var allErrs field.ErrorList
var allWarns admission.Warnings
if warn := webhook.ValidateLabelOwnedBy(ctx, c, pluginPreset); warn != "" {
allWarns = append(allWarns, "PluginPreset should have a support-group Team set as its owner", warn)
}
if err := webhook.ValidateImmutableField(oldPluginPreset.Spec.Plugin.ClusterName, pluginPreset.Spec.Plugin.ClusterName, field.NewPath("spec", "plugin", "clusterName")); err != nil {
allErrs = append(allErrs, err)
}
// validate WaitFor items are unique and that PluginRef's fields are mutually exclusive
if errList := validateWaitForPluginRefs(pluginPreset.Spec.WaitFor, false); len(errList) > 0 {
allErrs = append(allErrs, errList...)
}
if len(allErrs) > 0 {
return allWarns, apierrors.NewInvalid(pluginPreset.GroupVersionKind().GroupKind(), pluginPreset.Name, allErrs)
}
return allWarns, nil
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
uwe-mayer
approved these changes
Apr 23, 2026
Contributor
uwe-mayer
left a comment
There was a problem hiding this comment.
🚀
Fastest from discussion to PR ever?
TY!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
with this change both Plugins & PluginPresets may allow to change
the name of the referenced PluginDefintion
Description
What type of PR is this? (check all applicable)
Related Tickets & Documents
Added tests?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Added to documentation?
Checklist