Skip to content

chore(plugins): remove unused code#2102

Open
k-fabryczny wants to merge 16 commits into
mainfrom
chore/plugin-cleanup
Open

chore(plugins): remove unused code#2102
k-fabryczny wants to merge 16 commits into
mainfrom
chore/plugin-cleanup

Conversation

@k-fabryczny

Copy link
Copy Markdown
Contributor

Description

Cleanup after moving CEL evaluation from plugin to PluginPreset

What type of PR is this? (check all applicable)

  • 🍕 Feature
  • 🐛 Bug Fix
  • 📝 Documentation Update
  • 🎨 Style
  • 🧑‍💻 Code Refactor
  • 🔥 Performance Improvements
  • ✅ Test
  • 🤖 Build
  • 🔁 CI
  • 📦 Chore (Release)
  • ⏩ Revert
  • 🧹 Cleanup

Related Tickets & Documents

Added tests?

  • 👍 yes
  • 🙅 no, because they aren't needed
  • 🙋 no, because I need help
  • Separate ticket for tests # (issue/pr)

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?

  • 📜 README.md
  • 🤝 Documentation pages updated
  • 🙅 no documentation needed
  • (if applicable) generated OpenAPI docs for CRD changes

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes

Signed-off-by: Klaudiusz Fabryczny <klaudiusz.fabryczny@sap.com>
@k-fabryczny k-fabryczny requested a review from a team as a code owner June 29, 2026 13:05
Copilot AI review requested due to automatic review settings June 29, 2026 13:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Cleanup PR intended to remove now-unused plugin-side CEL/external reference resolution after moving evaluation responsibilities to PluginPreset.

Changes:

  • Removed ValueFrom.Ref resolution helpers (including CEL evaluation and tracking annotation updates) from plugin_values_resolver.go.
  • Deleted unit/integration tests that covered the removed helper behavior.
  • Simplified computeReleaseValues in the Flux plugin controller path by removing expression/ref resolution logic.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
internal/controller/plugin/plugin_values_resolver.go Removes external reference/CEL resolution and related tracking-annotation helpers, leaving only untracking cleanup logic.
internal/controller/plugin/plugin_values_resolver_test.go Removes unit tests that covered the deleted helper functions.
internal/controller/plugin/plugin_integration/plugin_integration_test.go Removes integration specs covering external ref resolution + tracking behavior (file now effectively has only setup/cleanup).
internal/controller/plugin/plugin_controller_flux.go Drops expression/ref handling from computeReleaseValues and keeps integration tracking cleanup flow.
Comments suppressed due to low confidence (1)

internal/controller/plugin/plugin_controller_flux.go:482

  • computeReleaseValues no longer handles option values that use Expression or ValueFrom.Ref: the loop now returns option value %s has no value or valueFrom set for those cases, even though these fields are still part of PluginOptionValue (and are used elsewhere, e.g. option checksum calculation and e2e plugin integration scenarios). This will break reconciliation for Plugins that rely on expression evaluation or external references, and the error message is misleading.

Either restore expression/ref resolution here (or earlier in helm.GetPluginOptionValuesForPlugin), or explicitly reject these fields with a clear error and update validation/webhooks + tests accordingly.

	for _, v := range optionValues {
		switch {
		case v.Value != nil:
			// noop, direct values are already set
			continue

		case v.ValueFrom != nil && v.ValueFrom.Secret != nil:
			// noop, secret refs are not resolved here
			continue
		default:
			return nil, fmt.Errorf("option value %s has no value or valueFrom set", v.Name)
		}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/controller/plugin/plugin_controller_flux.go Outdated
Comment thread internal/controller/plugin/plugin_integration/plugin_integration_test.go Outdated
Signed-off-by: Klaudiusz Fabryczny <klaudiusz.fabryczny@sap.com>
Signed-off-by: Klaudiusz Fabryczny <klaudiusz.fabryczny@sap.com>
@github-actions github-actions Bot added size/XXL and removed size/XL labels Jun 30, 2026
Signed-off-by: Klaudiusz Fabryczny <klaudiusz.fabryczny@sap.com>
// computeReleaseValues resolves Expressions and ValueFromRefs in the Plugin's option values
// and inserts the Greenhouse values
func computeReleaseValues(ctx context.Context, c client.Client, plugin *greenhousev1alpha1.Plugin, expressionEvaluation, integrationEnabled bool) ([]greenhousev1alpha1.PluginOptionValue, error) {
func computeReleaseValues(ctx context.Context, c client.Client, plugin *greenhousev1alpha1.Plugin, _expressionEvaluation, _integrationEnabled bool) ([]greenhousev1alpha1.PluginOptionValue, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please remove the unused parameters along with the ExpressionEvaluationEnabled and IntegrationEnabled flags from PluginReconciler, Plugin configuration and other places.

Signed-off-by: Klaudiusz Fabryczny <klaudiusz.fabryczny@sap.com>
Signed-off-by: Klaudiusz Fabryczny <klaudiusz.fabryczny@sap.com>
Signed-off-by: Klaudiusz Fabryczny <klaudiusz.fabryczny@sap.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 5 comments.

Comment thread internal/controller/plugin/plugin_controller_flux.go
Comment thread cmd/greenhouse/controllers.go
Comment thread internal/features/features_test.go Outdated
Comment thread internal/features/features_test.go Outdated
Comment thread e2e/plugin/e2e_test.go
Signed-off-by: Klaudiusz Fabryczny <klaudiusz.fabryczny@sap.com>
Signed-off-by: Klaudiusz Fabryczny <klaudiusz.fabryczny@sap.com>
Signed-off-by: Klaudiusz Fabryczny <klaudiusz.fabryczny@sap.com>
Signed-off-by: Klaudiusz Fabryczny <klaudiusz.fabryczny@sap.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

internal/features/features_test.go:216

  • Test_PluginPresetFeatures no longer covers the common cases where expressionEvaluationEnabled is explicitly false or where the pluginPreset key exists but does not include expressionEvaluationEnabled. Keeping these cases helps ensure the default/disabled behavior remains stable (and distinct from the ConfigMap-not-found path).
	testCases := []testCase{
		{
			name:                         "it should return true when expressionEvaluationEnabled is true",
			configMapData:                map[string]string{PluginPresetFeatureKey: "expressionEvaluationEnabled: true\n"},
			expectedExpressionEvaluation: true,
		},
		{
			name:                         "it should return false when feature-flags cm is not found",
			getError:                     apierrors.NewNotFound(schema.GroupResource{}, "configmap not found"),
			expectedExpressionEvaluation: false,
		},
		{
			name:                         "it should return false when flag is malformed in feature-flags cm",
			configMapData:                map[string]string{PluginPresetFeatureKey: "expressionEvaluationEnabled:: invalid_yaml"},
			expectedExpressionEvaluation: false,
		},
	}

Comment thread internal/features/features_test.go
Signed-off-by: Klaudiusz Fabryczny <klaudiusz.fabryczny@sap.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.

Comment thread internal/controller/plugin/plugin_controller_flux.go Outdated
Signed-off-by: Klaudiusz Fabryczny <klaudiusz.fabryczny@sap.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.

Comment on lines 84 to +88
func startPluginReconciler(name string, mgr ctrl.Manager) error {
return (&plugincontrollers.PluginReconciler{
KubeRuntimeOpts: kubeClientOpts,
ExpressionEvaluationEnabled: featureFlags.IsExpressionEvaluationEnabled(),
IntegrationEnabled: featureFlags.IsIntegrationEnabled(),
OCIMirroringEnabled: featureFlags.IsOCIMirroringEnabled(),
StoragePath: artifactStoragePath,
HTTPRetry: artifactRetries,
KubeRuntimeOpts: kubeClientOpts,
OCIMirroringEnabled: featureFlags.IsOCIMirroringEnabled(),
StoragePath: artifactStoragePath,
Comment on lines 476 to +480
case v.ValueFrom != nil && v.ValueFrom.Secret != nil:
// noop, secret refs are not resolved here
continue
default:
return nil, fmt.Errorf("option value %s has no value or valueFrom set", v.Name)
}
}

// update tracking information for plugin integrations
if integrationEnabled {
// remove tracking annotations from resources that are no longer being tracked
if err := removeUntrackedObjectAnnotations(ctx, c, plugin, trackedObjects); err != nil {
// log err, will retry on next reconciliation
log.FromContext(ctx).Error(err, "failed to remove untracked object annotations", "namespace", plugin.Namespace, "plugin", plugin.Name)
}
if len(trackedObjects) > 0 {
plugin.Status.TrackedObjects = trackedObjects
} else {
// clear tracked objects if there are none
plugin.Status.TrackedObjects = nil
return nil, fmt.Errorf("plugin %s/%s: option value %s must have a direct value or secret reference",
Signed-off-by: Klaudiusz Fabryczny <klaudiusz.fabryczny@sap.com>
@k-fabryczny k-fabryczny requested a review from a team as a code owner July 3, 2026 12:29
@github-actions github-actions Bot added documentation Improvements or additions to documentation core-apis labels Jul 3, 2026
cloud-operator-bot Bot and others added 2 commits July 3, 2026 12:32
Signed-off-by: Klaudiusz Fabryczny <klaudiusz.fabryczny@sap.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 32 out of 34 changed files in this pull request and generated 6 comments.

Files not reviewed (1)
  • api/v1alpha1/zz_generated.deepcopy.go: Generated file

Comment on lines +307 to 312
// TODO restore
//nolint:dupword
// Entry("Expression only (valid)", nil, nil, utils.StringP(`"test-${global.greenhouse.clusterName}"`), false),
// Entry("Expression and Value both set (invalid)", test.MustReturnJSONFor("test"), nil, utils.StringP(`"test-expression"`), true),
Entry("Expression and ValueFrom both set (invalid)", nil, &greenhousev1alpha1.PluginPresetPluginValueFromSource{Secret: &greenhousev1alpha1.SecretKeyReference{Name: "my-secret"}}, utils.StringP(`"test-expression"`), true),
Entry("All three set (invalid)", test.MustReturnJSONFor("test"), &greenhousev1alpha1.PluginPresetPluginValueFromSource{Secret: &greenhousev1alpha1.SecretKeyReference{Name: "my-secret"}}, utils.StringP(`"test-expression"`), true),
Comment on lines +391 to 396
// TODO restore
//nolint:dupword
// Entry("Expression only (valid)", nil, nil, utils.StringP(`"test-${global.greenhouse.clusterName}"`), false),
// Entry("Expression and Value both set (invalid)", test.MustReturnJSONFor("test"), nil, utils.StringP(`"test-expression"`), true),
Entry("Expression and ValueFrom both set (invalid)", nil, &greenhousev1alpha1.PluginPresetPluginValueFromSource{Secret: &greenhousev1alpha1.SecretKeyReference{Name: "my-secret"}}, utils.StringP(`"test-expression"`), true),
Entry("All three set (invalid)", test.MustReturnJSONFor("test"), &greenhousev1alpha1.PluginPresetPluginValueFromSource{Secret: &greenhousev1alpha1.SecretKeyReference{Name: "my-secret"}}, utils.StringP(`"test-expression"`), true),
Comment on lines 389 to 394
// hasExactlyOneValueSource checks if exactly one of Value, ValueFrom, or Expression is set.
func hasExactlyOneValueSource(val greenhousev1alpha1.PluginOptionValue) bool {
sources := []bool{
val.Value != nil,
val.ValueFrom != nil,
val.Expression != nil,
}
Comment on lines 136 to 140
ov := greenhousev1alpha1.PluginOptionValue{
Name: pv.Name,
Value: pv.Value,
Expression: pv.Expression,
Name: pv.Name,
Value: pv.Value,
}
if pv.ValueFrom != nil {
Comment on lines +26 to +30
DescribeTable("Validate PluginType contains either Value or ValueFrom", func(value *apiextensionsv1.JSON, valueFrom *greenhousev1alpha1.PluginValueFromSource, expression *string, expErr bool) {
optionValues := []greenhousev1alpha1.PluginOptionValue{
{
Name: "test",
Value: value,
ValueFrom: valueFrom,
Expression: expression,
Name: "test",
Value: value,
Comment on lines 71 to 76
Entry("Value and ValueFrom and Expression nil", nil, nil, nil, true),
Entry("Value and ValueFrom not nil, Expression is nil", test.MustReturnJSONFor("test"), &greenhousev1alpha1.PluginValueFromSource{Secret: &greenhousev1alpha1.SecretKeyReference{Name: "my-secret"}}, nil, true),
Entry("Value not nil", test.MustReturnJSONFor("test"), nil, nil, false),
Entry("ValueFrom not nil", nil, &greenhousev1alpha1.PluginValueFromSource{Secret: &greenhousev1alpha1.SecretKeyReference{Name: "my-secret", Key: "secret-key"}}, nil, false),
Entry("Expression not nil", nil, nil, new("${global.greenhouse.clusterName}"), false),
Entry("Value and Expression not nil, ValueFrom nil", test.MustReturnJSONFor("test"), nil, new("${global.greenhouse.clusterName}"), true),
Entry("ValueFrom and Expression not nil, Value nil", nil, &greenhousev1alpha1.PluginValueFromSource{Secret: &greenhousev1alpha1.SecretKeyReference{Name: "my-secret", Key: "secret-key"}}, new("${global.greenhouse.clusterName}"), true),
Entry("Value, ValueFrom, and Expression all not nil", test.MustReturnJSONFor("test"), &greenhousev1alpha1.PluginValueFromSource{Secret: &greenhousev1alpha1.SecretKeyReference{Name: "my-secret", Key: "secret-key"}}, new("${global.greenhouse.clusterName}"), true),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core-apis documentation Improvements or additions to documentation helm-charts size/XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants