diff --git a/api/v1alpha1/pluginpreset_types.go b/api/v1alpha1/pluginpreset_types.go index 579072700..0615f1ff0 100644 --- a/api/v1alpha1/pluginpreset_types.go +++ b/api/v1alpha1/pluginpreset_types.go @@ -62,7 +62,7 @@ type PluginPresetPluginSpec struct { DisplayName string `json:"displayName,omitempty"` // Values are the values for a PluginDefinition instance. - OptionValues []PluginOptionValue `json:"optionValues,omitempty"` + OptionValues []PluginPresetPluginOptionValue `json:"optionValues,omitempty"` // ReleaseNamespace is the namespace in the remote cluster to which the backend is deployed. // Defaults to the Greenhouse managed namespace if not set. @@ -114,8 +114,8 @@ type PluginPresetPluginValueFromSource struct { // ClusterOptionOverride defines which plugin option should be override in which cluster // +Optional type ClusterOptionOverride struct { - ClusterName string `json:"clusterName"` - Overrides []PluginOptionValue `json:"overrides"` + ClusterName string `json:"clusterName"` + Overrides []PluginPresetPluginOptionValue `json:"overrides"` } const ( diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index f7b889c7a..2bca20dff 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -545,7 +545,7 @@ func (in *ClusterOptionOverride) DeepCopyInto(out *ClusterOptionOverride) { *out = *in if in.Overrides != nil { in, out := &in.Overrides, &out.Overrides - *out = make([]PluginOptionValue, len(*in)) + *out = make([]PluginPresetPluginOptionValue, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -1324,7 +1324,7 @@ func (in *PluginPresetPluginSpec) DeepCopyInto(out *PluginPresetPluginSpec) { out.PluginDefinitionRef = in.PluginDefinitionRef if in.OptionValues != nil { in, out := &in.OptionValues, &out.OptionValues - *out = make([]PluginOptionValue, len(*in)) + *out = make([]PluginPresetPluginOptionValue, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } diff --git a/charts/greenhouse/ci/test-values.yaml b/charts/greenhouse/ci/test-values.yaml index c665f2b93..27fe37c41 100644 --- a/charts/greenhouse/ci/test-values.yaml +++ b/charts/greenhouse/ci/test-values.yaml @@ -15,6 +15,9 @@ global: expressionEvaluationEnabled: false integrationEnabled: false ociMirroringEnabled: false + # PluginPreset configuration for Greenhouse. + pluginPreset: + expressionEvaluationEnabled: true linkerd_enabled: false region: greenhouse registry: ghcr.io/cloudoperators/greenhouse diff --git a/charts/greenhouse/values.yaml b/charts/greenhouse/values.yaml index 1ea34bd10..3404507bd 100644 --- a/charts/greenhouse/values.yaml +++ b/charts/greenhouse/values.yaml @@ -23,6 +23,9 @@ global: expressionEvaluationEnabled: false integrationEnabled: false ociMirroringEnabled: false + # PluginPreset configuration for Greenhouse. + pluginPreset: + expressionEvaluationEnabled: false postgresqlng: enabled: true diff --git a/charts/manager/ci/test-values.yaml b/charts/manager/ci/test-values.yaml index 897d90f33..57cb691bd 100644 --- a/charts/manager/ci/test-values.yaml +++ b/charts/manager/ci/test-values.yaml @@ -13,6 +13,8 @@ global: expressionEvaluationEnabled: false integrationEnabled: false ociMirroringEnabled: false + pluginPreset: + expressionEvaluationEnabled: true controllerManager: args: diff --git a/charts/manager/crds/greenhouse.sap_pluginpresets.yaml b/charts/manager/crds/greenhouse.sap_pluginpresets.yaml index bc9445a14..628600c5a 100644 --- a/charts/manager/crds/greenhouse.sap_pluginpresets.yaml +++ b/charts/manager/crds/greenhouse.sap_pluginpresets.yaml @@ -68,14 +68,12 @@ spec: type: string overrides: items: - description: PluginOptionValue is the value for a PluginOption. + description: PluginPresetPluginOptionValue is the value for + a PluginOption. properties: expression: - description: |- - Expression is a YAML string with ${...} placeholders that will be evaluated as CEL expressions. - - Deprecated: Expression is deprecated on standalone Plugins and will be removed in a future release. - Consider using a PluginPreset to deploy Plugins utilizing the Expression field. + description: Expression is a YAML string with ${...} placeholders + that will be evaluated as CEL expressions. type: string name: description: Name of the values. @@ -87,11 +85,8 @@ spec: description: ValueFrom references value in another source. properties: ref: - description: |- - Ref references values defined in another resource (Plugin, PluginPreset) - - Deprecated: Ref is deprecated on standalone Plugins and will be removed in a future release. - Consider using a PluginPreset to deploy Plugins utilizing the Ref field. + description: Ref references values defined in another + resource (Plugin, PluginPreset) properties: expression: description: Expression is a CEL expression to @@ -307,14 +302,12 @@ spec: optionValues: description: Values are the values for a PluginDefinition instance. items: - description: PluginOptionValue is the value for a PluginOption. + description: PluginPresetPluginOptionValue is the value for + a PluginOption. properties: expression: - description: |- - Expression is a YAML string with ${...} placeholders that will be evaluated as CEL expressions. - - Deprecated: Expression is deprecated on standalone Plugins and will be removed in a future release. - Consider using a PluginPreset to deploy Plugins utilizing the Expression field. + description: Expression is a YAML string with ${...} placeholders + that will be evaluated as CEL expressions. type: string name: description: Name of the values. @@ -326,11 +319,8 @@ spec: description: ValueFrom references value in another source. properties: ref: - description: |- - Ref references values defined in another resource (Plugin, PluginPreset) - - Deprecated: Ref is deprecated on standalone Plugins and will be removed in a future release. - Consider using a PluginPreset to deploy Plugins utilizing the Ref field. + description: Ref references values defined in another + resource (Plugin, PluginPreset) properties: expression: description: Expression is a CEL expression to extract diff --git a/charts/manager/templates/_helpers.tpl b/charts/manager/templates/_helpers.tpl index de495a13b..338e96f37 100644 --- a/charts/manager/templates/_helpers.tpl +++ b/charts/manager/templates/_helpers.tpl @@ -117,3 +117,7 @@ Define postgresql helpers {{- define "plugin.ociMirroringEnabled" -}} {{- printf "%t" (required "global.plugin.ociMirroringEnabled missing" .Values.global.plugin.ociMirroringEnabled) }} {{- end }} +{{/* Render the pluginPreset expression evaluation flag */}} +{{- define "pluginPreset.expressionEvaluationEnabled" -}} + {{- printf "%t" (required "global.pluginPreset.expressionEvaluationEnabled missing" .Values.global.pluginPreset.expressionEvaluationEnabled) }} +{{- end }} \ No newline at end of file diff --git a/charts/manager/templates/manager/feature-flag.yaml b/charts/manager/templates/manager/feature-flag.yaml index 6bfb1ac94..87043f10d 100644 --- a/charts/manager/templates/manager/feature-flag.yaml +++ b/charts/manager/templates/manager/feature-flag.yaml @@ -26,9 +26,16 @@ data: expressionEvaluationEnabled: false / true integrationEnabled: false / true ociMirroringEnabled: false / true + # enable pluginPreset features + # expressionEvaluationEnabled allows you to enable or disable CEL expression evaluation in PluginPreset + # when enabled, expressions in PluginPreset.spec.plugin.optionValues are evaluated before creating the Plugin + pluginPreset: | + expressionEvaluationEnabled: false / true dex: | storage: {{ include "dex.backend" $ }} plugin: | expressionEvaluationEnabled: {{ include "plugin.expressionEvaluationEnabled" $ }} integrationEnabled: {{ include "plugin.integrationEnabled" $ }} ociMirroringEnabled: {{ include "plugin.ociMirroringEnabled" $ }} + pluginPreset: | + expressionEvaluationEnabled: {{ include "pluginPreset.expressionEvaluationEnabled" $ }} diff --git a/cmd/greenhouse/controllers.go b/cmd/greenhouse/controllers.go index 98992f02b..0ed5b6725 100644 --- a/cmd/greenhouse/controllers.go +++ b/cmd/greenhouse/controllers.go @@ -35,7 +35,7 @@ var knownControllers = map[string]func(controllerName string, mgr ctrl.Manager) // Plugin controllers. "plugin": startPluginReconciler, - "pluginPreset": (&plugincontrollers.PluginPresetReconciler{}).SetupWithManager, + "pluginPreset": startPluginPresetReconciler, "catalog": startCatalogReconciler, "pluginDefinition": startPluginDefinitionReconciler, @@ -93,6 +93,12 @@ func startPluginReconciler(name string, mgr ctrl.Manager) error { }).SetupWithManager(name, mgr) } +func startPluginPresetReconciler(name string, mgr ctrl.Manager) error { + return (&plugincontrollers.PluginPresetReconciler{ + ExpressionEvaluationEnabled: featureFlags.IsPresetExpressionEvaluationEnabled(), + }).SetupWithManager(name, mgr) +} + func startPluginDefinitionReconciler(name string, mgr ctrl.Manager) error { return (&plugindefinitioncontroller.PluginDefinitionReconciler{ OCIMirroringEnabled: featureFlags.IsOCIMirroringEnabled(), diff --git a/dev-env/dev.values.yaml b/dev-env/dev.values.yaml index e0a190fac..d32d1770a 100644 --- a/dev-env/dev.values.yaml +++ b/dev-env/dev.values.yaml @@ -9,6 +9,8 @@ global: expressionEvaluationEnabled: true integrationEnabled: true ociMirroringEnabled: true + pluginPreset: + expressionEvaluationEnabled: true alerts: enabled: false certManager: diff --git a/docs/reference/api/index.html b/docs/reference/api/index.html index 67f0c179c..958efd535 100644 --- a/docs/reference/api/index.html +++ b/docs/reference/api/index.html @@ -1082,8 +1082,8 @@
overrides(Appears on: -ClusterOptionOverride, -PluginPresetPluginSpec, PluginSpec)
PluginOptionValue is the value for a PluginOption.
@@ -3260,6 +3258,11 @@+(Appears on: +ClusterOptionOverride, +PluginPresetPluginSpec) +
PluginPresetPluginOptionValue is the value for a PluginOption.
optionValues