diff --git a/cmd/main.go b/cmd/main.go index 20dda7e94..d1643b8f7 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -302,25 +302,28 @@ func main() { } pgFleetMetricsCollector := pgprometheus.NewFleetCollector() - if err := (&controller.PostgresDatabaseReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - Recorder: mgr.GetEventRecorderFor("postgresdatabase-controller"), - Metrics: pgMetricsRecorder, - FleetCollector: pgFleetMetricsCollector, - }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "PostgresDatabase") - os.Exit(1) - } - if err := (&controller.PostgresClusterReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - Recorder: mgr.GetEventRecorderFor("postgrescluster-controller"), - Metrics: pgMetricsRecorder, - FleetCollector: pgFleetMetricsCollector, - }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "PostgresCluster") - os.Exit(1) + if config.DefaultMutableFeatureGate.Enabled(config.PostgresController) { + if err := (&controller.PostgresDatabaseReconciler{ + Client: mgr.GetClient(), + Scheme: mgr.GetScheme(), + Recorder: mgr.GetEventRecorderFor("postgresdatabase-controller"), + Metrics: pgMetricsRecorder, + FleetCollector: pgFleetMetricsCollector, + }).SetupWithManager(mgr); err != nil { + setupLog.Error(err, "unable to create controller", "controller", "PostgresDatabase") + os.Exit(1) + } + + if err := (&controller.PostgresClusterReconciler{ + Client: mgr.GetClient(), + Scheme: mgr.GetScheme(), + Recorder: mgr.GetEventRecorderFor("postgrescluster-controller"), + Metrics: pgMetricsRecorder, + FleetCollector: pgFleetMetricsCollector, + }).SetupWithManager(mgr); err != nil { + setupLog.Error(err, "unable to create controller", "controller", "PostgresCluster") + os.Exit(1) + } } if _, ok := os.LookupEnv("ENABLE_VALIDATION_WEBHOOK"); ok { diff --git a/config/samples/enterprise_v4_postgrescluster_dev.yaml b/config/samples/enterprise_v4_postgrescluster_dev.yaml index b5c6b8700..fb2137c30 100644 --- a/config/samples/enterprise_v4_postgrescluster_dev.yaml +++ b/config/samples/enterprise_v4_postgrescluster_dev.yaml @@ -14,8 +14,8 @@ spec: clusterDeletionPolicy: Retain instances: 3 # Storage and PostgreSQL version are overridden from the ClusterClass defaults. Validation rules on the PostgresCluster resource will prevent removing these fields or setting them to lower values than the original overrides. - storage: 1Gi - postgresVersion: "15.10" + storage: 20Gi + postgresVersion: "18.10" resources: requests: cpu: "250m" diff --git a/config/webhook/manifests.yaml b/config/webhook/manifests.yaml index 8d6ea21fa..a93b82475 100644 --- a/config/webhook/manifests.yaml +++ b/config/webhook/manifests.yaml @@ -30,4 +30,5 @@ webhooks: - monitoringconsoles - postgresclusters - postgresclusterclasses + - postgresdatabases sideEffects: None diff --git a/docs/FeatureGates.md b/docs/FeatureGates.md index f64b83b5f..10a8879e8 100644 --- a/docs/FeatureGates.md +++ b/docs/FeatureGates.md @@ -49,7 +49,8 @@ When running the operator binary directly, pass feature gates at startup: | Gate | Default | Stage | Since | Description | |-----------------------|---------|-------|---------|----------------------------------------------------------| -| `ValidationWebhook` | `false` | Alpha | v3.2.0 | Centralized validation webhook server for CR admission | +| `ValidationWebhook` | `false` | Alpha | v3.2.0 | Centralized validation webhook server for CR admission | +| `PostgresController` | `false` | Alpha | ? | PostgresCluster, PostgresClusterClass, and PostgresDatabase controllers and CRDs | ## Adding a New Feature Gate @@ -130,6 +131,20 @@ metadata: splunk.com/feature-stage: alpha ``` +### d. Enable the gate in tests + +Validators and controllers gated behind a feature flag will reject all operations in tests unless the gate is explicitly enabled. Enable it via `SetFromMap` before your tests run: + +```go +func init() { + if err := config.DefaultMutableFeatureGate.SetFromMap(map[string]bool{ + string(config.MyNewFeature): true, + }); err != nil { + panic(err) + } +} +``` + ## Promoting a Gate - **Alpha → Beta**: Change `Default: false` to `Default: true` in `featuregates.go`; update the CRD label to `beta` diff --git a/pkg/config/featuregates.go b/pkg/config/featuregates.go index 934807511..5b32ec2be 100644 --- a/pkg/config/featuregates.go +++ b/pkg/config/featuregates.go @@ -35,14 +35,16 @@ const ( // When enabled, the operator runs a validating webhook that enforces // CR schema rules at admission time. // Replaces the legacy ENABLE_VALIDATION_WEBHOOK env var. - ValidationWebhook featuregate.Feature = "ValidationWebhook" + ValidationWebhook featuregate.Feature = "ValidationWebhook" + PostgresController featuregate.Feature = "PostgresController" ) // defaultFeatureGates is the authoritative registry of all feature gates and // their default state / maturity. Each entry here automatically becomes // available via --feature-gates on the operator binary. var defaultFeatureGates = map[featuregate.Feature]featuregate.FeatureSpec{ - ValidationWebhook: {Default: false, PreRelease: featuregate.Alpha}, + ValidationWebhook: {Default: false, PreRelease: featuregate.Alpha}, + PostgresController: {Default: false, PreRelease: featuregate.Alpha}, } var DefaultMutableFeatureGate featuregate.MutableFeatureGate = featuregate.NewFeatureGate() diff --git a/pkg/postgresql/cluster/adapter/webhook/postgrescluster_validation.go b/pkg/postgresql/cluster/adapter/webhook/postgrescluster_validation.go index 7fc724c4f..de88a95eb 100644 --- a/pkg/postgresql/cluster/adapter/webhook/postgrescluster_validation.go +++ b/pkg/postgresql/cluster/adapter/webhook/postgrescluster_validation.go @@ -20,6 +20,7 @@ import ( "k8s.io/apimachinery/pkg/util/validation/field" enterpriseApi "github.com/splunk/splunk-operator/api/v4" + "github.com/splunk/splunk-operator/pkg/config" hba "github.com/splunk/splunk-operator/pkg/postgresql/cluster/core" ) @@ -27,6 +28,14 @@ import ( func ValidatePostgresClusterCreate(obj *enterpriseApi.PostgresCluster) field.ErrorList { var allErrs field.ErrorList + if !config.DefaultMutableFeatureGate.Enabled(config.PostgresController) { + allErrs = append(allErrs, field.Forbidden( + field.NewPath("spec"), + "the PostgresController feature is not enabled; set --feature-gates=PostgresController=true to activate")) + + return allErrs + } + if len(obj.Spec.PgHBA) > 0 { pgHBAPath := field.NewPath("spec").Child("pgHBA") for _, re := range hba.ValidateRules(obj.Spec.PgHBA) { diff --git a/pkg/postgresql/cluster/adapter/webhook/postgrescluster_validation_test.go b/pkg/postgresql/cluster/adapter/webhook/postgrescluster_validation_test.go index 56ff34c9c..1e888c9f9 100644 --- a/pkg/postgresql/cluster/adapter/webhook/postgrescluster_validation_test.go +++ b/pkg/postgresql/cluster/adapter/webhook/postgrescluster_validation_test.go @@ -20,6 +20,7 @@ import ( "testing" enterpriseApi "github.com/splunk/splunk-operator/api/v4" + "github.com/splunk/splunk-operator/pkg/config" "github.com/stretchr/testify/assert" ) @@ -174,6 +175,22 @@ func TestValidatePostgresClusterUpdate(t *testing.T) { } } +func TestValidatePostgresClusterCreateFeatureGateDisabled(t *testing.T) { + config.DefaultMutableFeatureGate.SetFromMap(map[string]bool{string(config.PostgresController): false}) + t.Cleanup(func() { + config.DefaultMutableFeatureGate.SetFromMap(map[string]bool{string(config.PostgresController): true}) + }) + + obj := &enterpriseApi.PostgresCluster{ + Spec: enterpriseApi.PostgresClusterSpec{Class: "dev"}, + } + + errs := ValidatePostgresClusterCreate(obj) + assert.Len(t, errs, 1) + assert.Equal(t, "spec", errs[0].Field) + assert.Equal(t, "the PostgresController feature is not enabled; set --feature-gates=PostgresController=true to activate", errs[0].Detail) +} + func TestGetPostgresClusterWarningsOnCreate(t *testing.T) { obj := &enterpriseApi.PostgresCluster{ Spec: enterpriseApi.PostgresClusterSpec{Class: "dev"}, diff --git a/pkg/postgresql/cluster/adapter/webhook/postgresclusterclass_validation.go b/pkg/postgresql/cluster/adapter/webhook/postgresclusterclass_validation.go index 28246cba4..a8c1dbdd8 100644 --- a/pkg/postgresql/cluster/adapter/webhook/postgresclusterclass_validation.go +++ b/pkg/postgresql/cluster/adapter/webhook/postgresclusterclass_validation.go @@ -20,6 +20,7 @@ import ( "k8s.io/apimachinery/pkg/util/validation/field" enterpriseApi "github.com/splunk/splunk-operator/api/v4" + "github.com/splunk/splunk-operator/pkg/config" hba "github.com/splunk/splunk-operator/pkg/postgresql/cluster/core" ) @@ -27,6 +28,14 @@ import ( func ValidatePostgresClusterClassCreate(obj *enterpriseApi.PostgresClusterClass) field.ErrorList { var allErrs field.ErrorList + if !config.DefaultMutableFeatureGate.Enabled(config.PostgresController) { + allErrs = append(allErrs, field.Forbidden( + field.NewPath("spec"), + "the PostgresController feature is not enabled; set --feature-gates=PostgresController=true to activate")) + + return allErrs + } + if obj.Spec.Config != nil && len(obj.Spec.Config.PgHBA) > 0 { pgHBAPath := field.NewPath("spec").Child("config").Child("pgHBA") for _, re := range hba.ValidateRules(obj.Spec.Config.PgHBA) { diff --git a/pkg/postgresql/cluster/adapter/webhook/postgresclusterclass_validation_test.go b/pkg/postgresql/cluster/adapter/webhook/postgresclusterclass_validation_test.go index 5f0bef95c..f2ad39f46 100644 --- a/pkg/postgresql/cluster/adapter/webhook/postgresclusterclass_validation_test.go +++ b/pkg/postgresql/cluster/adapter/webhook/postgresclusterclass_validation_test.go @@ -20,6 +20,7 @@ import ( "testing" enterpriseApi "github.com/splunk/splunk-operator/api/v4" + "github.com/splunk/splunk-operator/pkg/config" "github.com/stretchr/testify/assert" ) @@ -173,6 +174,22 @@ func TestValidatePostgresClusterClassUpdate(t *testing.T) { } } +func TestValidatePostgresClusterClassCreateFeatureGateDisabled(t *testing.T) { + config.DefaultMutableFeatureGate.SetFromMap(map[string]bool{string(config.PostgresController): false}) + t.Cleanup(func() { + config.DefaultMutableFeatureGate.SetFromMap(map[string]bool{string(config.PostgresController): true}) + }) + + obj := &enterpriseApi.PostgresClusterClass{ + Spec: enterpriseApi.PostgresClusterClassSpec{Provisioner: "postgresql.cnpg.io"}, + } + + errs := ValidatePostgresClusterClassCreate(obj) + assert.Len(t, errs, 1) + assert.Equal(t, "spec", errs[0].Field) + assert.Equal(t, "the PostgresController feature is not enabled; set --feature-gates=PostgresController=true to activate", errs[0].Detail) +} + func TestGetPostgresClusterClassWarningsOnCreate(t *testing.T) { obj := &enterpriseApi.PostgresClusterClass{ Spec: enterpriseApi.PostgresClusterClassSpec{Provisioner: "postgresql.cnpg.io"}, diff --git a/pkg/postgresql/cluster/adapter/webhook/testhelpers_test.go b/pkg/postgresql/cluster/adapter/webhook/testhelpers_test.go new file mode 100644 index 000000000..97d2b30d3 --- /dev/null +++ b/pkg/postgresql/cluster/adapter/webhook/testhelpers_test.go @@ -0,0 +1,26 @@ +/* +Copyright 2026. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package webhook_test + +import ( + "github.com/splunk/splunk-operator/pkg/config" + "github.com/splunk/splunk-operator/pkg/postgresql/shared/testhelpers" +) + +func init() { + testhelpers.EnableFeatureGate(config.PostgresController) +} diff --git a/pkg/postgresql/cluster/adapter/webhook/testsetup_test.go b/pkg/postgresql/cluster/adapter/webhook/testsetup_test.go new file mode 100644 index 000000000..28c4bd5c0 --- /dev/null +++ b/pkg/postgresql/cluster/adapter/webhook/testsetup_test.go @@ -0,0 +1,26 @@ +/* +Copyright 2026. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package webhook + +import ( + "github.com/splunk/splunk-operator/pkg/config" + "github.com/splunk/splunk-operator/pkg/postgresql/shared/testhelpers" +) + +func init() { + testhelpers.EnableFeatureGate(config.PostgresController) +} diff --git a/pkg/postgresql/database/adapter/webhook/postgresdatabase_validation.go b/pkg/postgresql/database/adapter/webhook/postgresdatabase_validation.go new file mode 100644 index 000000000..706566df7 --- /dev/null +++ b/pkg/postgresql/database/adapter/webhook/postgresdatabase_validation.go @@ -0,0 +1,54 @@ +/* +Copyright 2026. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package webhook + +import ( + "k8s.io/apimachinery/pkg/util/validation/field" + + enterpriseApi "github.com/splunk/splunk-operator/api/v4" + "github.com/splunk/splunk-operator/pkg/config" +) + +// ValidatePostgresDatabaseCreate validates a PostgresDatabase on CREATE. +func ValidatePostgresDatabaseCreate(obj *enterpriseApi.PostgresDatabase) field.ErrorList { + var allErrs field.ErrorList + + if !config.DefaultMutableFeatureGate.Enabled(config.PostgresController) { + allErrs = append(allErrs, field.Forbidden( + field.NewPath("spec"), + "the PostgresController feature is not enabled; set --feature-gates=PostgresController=true to activate")) + + return allErrs + } + + return allErrs +} + +// ValidatePostgresDatabaseUpdate validates a PostgresDatabase on UPDATE. +func ValidatePostgresDatabaseUpdate(obj, oldObj *enterpriseApi.PostgresDatabase) field.ErrorList { + return ValidatePostgresDatabaseCreate(obj) +} + +// GetPostgresDatabaseWarningsOnCreate returns warnings for PostgresDatabase CREATE. +func GetPostgresDatabaseWarningsOnCreate(obj *enterpriseApi.PostgresDatabase) []string { + return nil +} + +// GetPostgresDatabaseWarningsOnUpdate returns warnings for PostgresDatabase UPDATE. +func GetPostgresDatabaseWarningsOnUpdate(obj, oldObj *enterpriseApi.PostgresDatabase) []string { + return nil +} diff --git a/pkg/postgresql/database/adapter/webhook/postgresdatabase_validation_test.go b/pkg/postgresql/database/adapter/webhook/postgresdatabase_validation_test.go new file mode 100644 index 000000000..7b6915fe4 --- /dev/null +++ b/pkg/postgresql/database/adapter/webhook/postgresdatabase_validation_test.go @@ -0,0 +1,103 @@ +/* +Copyright 2026. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package webhook + +import ( + "testing" + + corev1 "k8s.io/api/core/v1" + + enterpriseApi "github.com/splunk/splunk-operator/api/v4" + "github.com/splunk/splunk-operator/pkg/config" + "github.com/stretchr/testify/assert" +) + +func TestValidatePostgresDatabaseCreate(t *testing.T) { + tests := []struct { + name string + obj *enterpriseApi.PostgresDatabase + wantErrCount int + }{ + { + name: "valid - minimal spec", + obj: &enterpriseApi.PostgresDatabase{ + Spec: enterpriseApi.PostgresDatabaseSpec{ + ClusterRef: corev1.LocalObjectReference{Name: "my-cluster"}, + Databases: []enterpriseApi.DatabaseDefinition{{Name: "mydb"}}, + }, + }, + wantErrCount: 0, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + errs := ValidatePostgresDatabaseCreate(tt.obj) + assert.Len(t, errs, tt.wantErrCount, "unexpected error count") + }) + } +} + +func TestValidatePostgresDatabaseCreateFeatureGateDisabled(t *testing.T) { + config.DefaultMutableFeatureGate.SetFromMap(map[string]bool{string(config.PostgresController): false}) + t.Cleanup(func() { + config.DefaultMutableFeatureGate.SetFromMap(map[string]bool{string(config.PostgresController): true}) + }) + + obj := &enterpriseApi.PostgresDatabase{ + Spec: enterpriseApi.PostgresDatabaseSpec{ + ClusterRef: corev1.LocalObjectReference{Name: "my-cluster"}, + Databases: []enterpriseApi.DatabaseDefinition{{Name: "mydb"}}, + }, + } + + errs := ValidatePostgresDatabaseCreate(obj) + assert.Len(t, errs, 1) + assert.Equal(t, "spec", errs[0].Field) + assert.Equal(t, "the PostgresController feature is not enabled; set --feature-gates=PostgresController=true to activate", errs[0].Detail) +} + +func TestValidatePostgresDatabaseUpdate(t *testing.T) { + obj := &enterpriseApi.PostgresDatabase{ + Spec: enterpriseApi.PostgresDatabaseSpec{ + ClusterRef: corev1.LocalObjectReference{Name: "my-cluster"}, + Databases: []enterpriseApi.DatabaseDefinition{{Name: "mydb"}}, + }, + } + errs := ValidatePostgresDatabaseUpdate(obj, obj) + assert.Empty(t, errs) +} + +func TestGetPostgresDatabaseWarningsOnCreate(t *testing.T) { + obj := &enterpriseApi.PostgresDatabase{ + Spec: enterpriseApi.PostgresDatabaseSpec{ + ClusterRef: corev1.LocalObjectReference{Name: "my-cluster"}, + Databases: []enterpriseApi.DatabaseDefinition{{Name: "mydb"}}, + }, + } + assert.Empty(t, GetPostgresDatabaseWarningsOnCreate(obj)) +} + +func TestGetPostgresDatabaseWarningsOnUpdate(t *testing.T) { + obj := &enterpriseApi.PostgresDatabase{ + Spec: enterpriseApi.PostgresDatabaseSpec{ + ClusterRef: corev1.LocalObjectReference{Name: "my-cluster"}, + Databases: []enterpriseApi.DatabaseDefinition{{Name: "mydb"}}, + }, + } + assert.Empty(t, GetPostgresDatabaseWarningsOnUpdate(obj, obj)) +} diff --git a/pkg/postgresql/database/adapter/webhook/testsetup_test.go b/pkg/postgresql/database/adapter/webhook/testsetup_test.go new file mode 100644 index 000000000..28c4bd5c0 --- /dev/null +++ b/pkg/postgresql/database/adapter/webhook/testsetup_test.go @@ -0,0 +1,26 @@ +/* +Copyright 2026. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package webhook + +import ( + "github.com/splunk/splunk-operator/pkg/config" + "github.com/splunk/splunk-operator/pkg/postgresql/shared/testhelpers" +) + +func init() { + testhelpers.EnableFeatureGate(config.PostgresController) +} diff --git a/pkg/postgresql/shared/testhelpers/featuregates.go b/pkg/postgresql/shared/testhelpers/featuregates.go new file mode 100644 index 000000000..ca7688160 --- /dev/null +++ b/pkg/postgresql/shared/testhelpers/featuregates.go @@ -0,0 +1,37 @@ +/* +Copyright 2026. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package testhelpers provides shared test utilities for postgresql packages. +// It must not be imported by production code. +package testhelpers + +import ( + "k8s.io/component-base/featuregate" + + "github.com/splunk/splunk-operator/pkg/config" +) + +// EnableFeatureGate enables the given feature gates on the default mutable gate. +// Intended for use in test init() functions. +func EnableFeatureGate(gates ...featuregate.Feature) { + enabled := make(map[string]bool, len(gates)) + for _, g := range gates { + enabled[string(g)] = true + } + if err := config.DefaultMutableFeatureGate.SetFromMap(enabled); err != nil { + panic(err) + } +} diff --git a/pkg/splunk/enterprise/validation/registry.go b/pkg/splunk/enterprise/validation/registry.go index 5eab98402..2cd1b05b2 100644 --- a/pkg/splunk/enterprise/validation/registry.go +++ b/pkg/splunk/enterprise/validation/registry.go @@ -20,7 +20,8 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" enterpriseApi "github.com/splunk/splunk-operator/api/v4" - pgwebhook "github.com/splunk/splunk-operator/pkg/postgresql/cluster/adapter/webhook" + pgclusterwebhook "github.com/splunk/splunk-operator/pkg/postgresql/cluster/adapter/webhook" + pgdbwebhook "github.com/splunk/splunk-operator/pkg/postgresql/database/adapter/webhook" ) // GVR constants for all Splunk Enterprise CRDs @@ -84,6 +85,12 @@ var ( Version: "v4", Resource: "postgresclusterclasses", } + + PostgresDatabaseGVR = schema.GroupVersionResource{ + Group: "enterprise.splunk.com", + Version: "v4", + Resource: "postgresdatabases", + } ) // DefaultValidators is the registry of validators for all Splunk Enterprise CRDs @@ -195,10 +202,10 @@ var DefaultValidators = map[schema.GroupVersionResource]Validator{ }, PostgresClusterGVR: &GenericValidator[*enterpriseApi.PostgresCluster]{ - ValidateCreateFunc: pgwebhook.ValidatePostgresClusterCreate, - ValidateUpdateFunc: pgwebhook.ValidatePostgresClusterUpdate, - WarningsOnCreateFunc: pgwebhook.GetPostgresClusterWarningsOnCreate, - WarningsOnUpdateFunc: pgwebhook.GetPostgresClusterWarningsOnUpdate, + ValidateCreateFunc: pgclusterwebhook.ValidatePostgresClusterCreate, + ValidateUpdateFunc: pgclusterwebhook.ValidatePostgresClusterUpdate, + WarningsOnCreateFunc: pgclusterwebhook.GetPostgresClusterWarningsOnCreate, + WarningsOnUpdateFunc: pgclusterwebhook.GetPostgresClusterWarningsOnUpdate, GroupKind: schema.GroupKind{ Group: "enterprise.splunk.com", Kind: "PostgresCluster", @@ -206,13 +213,23 @@ var DefaultValidators = map[schema.GroupVersionResource]Validator{ }, PostgresClusterClassGVR: &GenericValidator[*enterpriseApi.PostgresClusterClass]{ - ValidateCreateFunc: pgwebhook.ValidatePostgresClusterClassCreate, - ValidateUpdateFunc: pgwebhook.ValidatePostgresClusterClassUpdate, - WarningsOnCreateFunc: pgwebhook.GetPostgresClusterClassWarningsOnCreate, - WarningsOnUpdateFunc: pgwebhook.GetPostgresClusterClassWarningsOnUpdate, + ValidateCreateFunc: pgclusterwebhook.ValidatePostgresClusterClassCreate, + ValidateUpdateFunc: pgclusterwebhook.ValidatePostgresClusterClassUpdate, + WarningsOnCreateFunc: pgclusterwebhook.GetPostgresClusterClassWarningsOnCreate, + WarningsOnUpdateFunc: pgclusterwebhook.GetPostgresClusterClassWarningsOnUpdate, GroupKind: schema.GroupKind{ Group: "enterprise.splunk.com", Kind: "PostgresClusterClass", }, }, + PostgresDatabaseGVR: &GenericValidator[*enterpriseApi.PostgresDatabase]{ + ValidateCreateFunc: pgdbwebhook.ValidatePostgresDatabaseCreate, + ValidateUpdateFunc: pgdbwebhook.ValidatePostgresDatabaseUpdate, + WarningsOnCreateFunc: pgdbwebhook.GetPostgresDatabaseWarningsOnCreate, + WarningsOnUpdateFunc: pgdbwebhook.GetPostgresDatabaseWarningsOnUpdate, + GroupKind: schema.GroupKind{ + Group: "enterprise.splunk.com", + Kind: "PostgresDatabase", + }, + }, }