Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ linters:
- linters:
- goconst
path: (.+)_test\.go
# Deprecated fields on v1alpha1.PluginOptionValue / PluginValueFromSource are intentionally
# still referenced during the deprecation window (see api/v1alpha1/plugin_types.go).
- linters: [staticcheck]
text: 'SA1019: .*\.(Expression|Ref) is deprecated'
paths:
- third_party$
- builtin$
Expand Down
6 changes: 6 additions & 0 deletions api/v1alpha1/plugin_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ type PluginOptionValue struct {
// ValueFrom references value in another source.
ValueFrom *PluginValueFromSource `json:"valueFrom,omitempty"`
// 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.
Expression *string `json:"expression,omitempty"`
}

Expand All @@ -77,6 +80,9 @@ type PluginValueFromSource struct {
// Secret references the v1.Secret containing the value that needs to be extracted
Secret *SecretKeyReference `json:"secret,omitempty"`
// 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.
Ref *ExternalValueSource `json:"ref,omitempty"`
}

Expand Down
63 changes: 62 additions & 1 deletion api/v1alpha1/pluginpreset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package v1alpha1
import (
"slices"

apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

greenhousemetav1alpha1 "github.com/cloudoperators/greenhouse/api/meta/v1alpha1"
Expand All @@ -30,7 +31,7 @@ const (
type PluginPresetSpec struct {

// PluginSpec is the spec of the plugin to be deployed by the PluginPreset.
Plugin PluginSpec `json:"plugin"`
Plugin PluginPresetPluginSpec `json:"plugin"`

// ClusterSelector is a label selector to select the clusters the plugin bundle should be deployed to.
ClusterSelector metav1.LabelSelector `json:"clusterSelector"`
Expand All @@ -50,6 +51,66 @@ type PluginPresetSpec struct {
DeletionPolicy string `json:"deletionPolicy,omitempty"`
}

// PluginPresetPluginSpec defines the desired state of Plugin
type PluginPresetPluginSpec struct {
// PluginDefinitionRef is the reference to the (Cluster-)PluginDefinition.
PluginDefinitionRef PluginDefinitionReference `json:"pluginDefinitionRef"`

// DisplayName is an optional name for the Plugin to be displayed in the Greenhouse UI.
// This is especially helpful to distinguish multiple instances of a PluginDefinition in the same context.
// Defaults to a normalized version of metadata.name.
DisplayName string `json:"displayName,omitempty"`

// Values are the values for a PluginDefinition instance.
OptionValues []PluginOptionValue `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.
ReleaseNamespace string `json:"releaseNamespace,omitempty"`

// ReleaseName is the name of the helm release in the remote cluster to which the backend is deployed.
// If the Plugin was already deployed, the Plugin's name is used as the release name.
// If this Plugin is newly created, the releaseName is defaulted to the PluginDefinitions HelmChart name.
// +Optional
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ReleaseName is immutable"
// +kubebuilder:validation:MaxLength=53
ReleaseName string `json:"releaseName,omitempty"`

// DeletionPolicy defines how Helm Releases created by a Plugin are handled upon deletion of the Plugin.
// Supported values are "Delete" and "Retain". If not set, defaults to "Delete".
// +Optional
// +kubebuilder:default=Delete
// +kubebuilder:validation:Enum=Delete;Retain
DeletionPolicy string `json:"deletionPolicy,omitempty"`

// IgnoreDifferences defines paths to ignore when detecting drift between desired and actual state.
// +Optional
IgnoreDifferences []IgnoreDifference `json:"ignoreDifferences,omitempty"`
}

// PluginPresetPluginOptionValue is the value for a PluginOption.
type PluginPresetPluginOptionValue struct {
// Name of the values.
Name string `json:"name"`
// Value is the actual value in plain text.
Value *apiextensionsv1.JSON `json:"value,omitempty"`
// ValueFrom references value in another source.
ValueFrom *PluginPresetPluginValueFromSource `json:"valueFrom,omitempty"`
// Expression is a YAML string with ${...} placeholders that will be evaluated as CEL expressions.
Expression *string `json:"expression,omitempty"`
}

// PluginPresetPluginValueFromSource defines how to extract dynamic values
// only one of secret or ref can be set
// +kubebuilder:validation:XValidation:rule="!(has(self.secret) && has(self.ref))",message="both secret and ref cannot be set"
// +kubebuilder:validation:XValidation:rule="has(self.secret) || has(self.ref)",message="one of secret or ref must be set"
type PluginPresetPluginValueFromSource struct {
// Secret references the v1.Secret containing the value that needs to be extracted
Secret *SecretKeyReference `json:"secret,omitempty"`
// Ref references values defined in another resource (Plugin, PluginPreset)
Ref *ExternalValueSource `json:"ref,omitempty"`
}
Comment thread
IvoGoman marked this conversation as resolved.

// ClusterOptionOverride defines which plugin option should be override in which cluster
// +Optional
type ClusterOptionOverride struct {
Expand Down
85 changes: 85 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 20 additions & 35 deletions charts/manager/crds/greenhouse.sap_pluginpresets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,11 @@ spec:
description: PluginOptionValue is the value for a PluginOption.
properties:
expression:
description: Expression is a YAML string with ${...} placeholders
that will be evaluated as CEL expressions.
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.
type: string
name:
description: Name of the values.
Expand All @@ -84,8 +87,11 @@ spec:
description: ValueFrom references value in another source.
properties:
ref:
description: Ref references values defined in another
resource (Plugin, PluginPreset)
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.
properties:
expression:
description: Expression is a CEL expression to
Expand Down Expand Up @@ -252,11 +258,6 @@ spec:
description: PluginSpec is the spec of the plugin to be deployed by
the PluginPreset.
properties:
clusterName:
description: ClusterName is the name of the cluster the plugin
is deployed to. If not set, the plugin is deployed to the greenhouse
cluster.
type: string
deletionPolicy:
default: Delete
description: |-
Expand Down Expand Up @@ -309,8 +310,11 @@ spec:
description: PluginOptionValue is the value for a PluginOption.
properties:
expression:
description: Expression is a YAML string with ${...} placeholders
that will be evaluated as CEL expressions.
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.
type: string
name:
description: Name of the values.
Expand All @@ -322,8 +326,11 @@ spec:
description: ValueFrom references value in another source.
properties:
ref:
description: Ref references values defined in another
resource (Plugin, PluginPreset)
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.
properties:
expression:
description: Expression is a CEL expression to extract
Expand Down Expand Up @@ -455,28 +462,6 @@ spec:
ReleaseNamespace is the namespace in the remote cluster to which the backend is deployed.
Defaults to the Greenhouse managed namespace if not set.
type: string
waitFor:
description: WaitFor defines other Plugins to wait for before
installing this Plugin.
items:
description: WaitForItem is a wrapper around PluginRef to add
context for every WaitFor list item.
properties:
pluginRef:
description: PluginRef defines a reference to the Plugin.
properties:
name:
description: Name of the Plugin.
type: string
pluginPreset:
description: PluginPreset is the name of the PluginPreset
which creates the Plugin.
type: string
type: object
required:
- pluginRef
type: object
type: array
required:
- pluginDefinitionRef
type: object
Expand Down
14 changes: 10 additions & 4 deletions charts/manager/crds/greenhouse.sap_plugins.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,11 @@ spec:
description: PluginOptionValue is the value for a PluginOption.
properties:
expression:
description: Expression is a YAML string with ${...} placeholders
that will be evaluated as CEL expressions.
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.
type: string
name:
description: Name of the values.
Expand All @@ -137,8 +140,11 @@ spec:
description: ValueFrom references value in another source.
properties:
ref:
description: Ref references values defined in another resource
(Plugin, PluginPreset)
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.
properties:
expression:
description: Expression is a CEL expression to extract
Expand Down
Loading
Loading