mirror of
https://github.com/hanzo-ml/spark-operator.git
synced 2026-10-30 20:39:07 +00:00
* Bump k8s api to 0.35.4, and controller runtime to v0.23.3 Signed-off-by: Shingo Omura <[email protected]> * Migrated defaulter/validator to be Generic ones Signed-off-by: Shingo Omura <[email protected]> * Fixed Endpoints deprecation lint errors (replaced with EndpointSlice) Signed-off-by: Shingo Omura <[email protected]> * Deleted unused internal/controller/sparkapplication/validator.go Signed-off-by: Shingo Omura <[email protected]> * Add SA1019 exclusion to golangci-lint config so to preserve Requeue behavior of controllers Signed-off-by: Shingo Omura <[email protected]> * Fixed util.WriteObjectToFile test. Null creationTimestamp is not marshalled anymore. Signed-off-by: Shingo Omura <[email protected]> * Updated codegen and API definitions Signed-off-by: Shingo Omura <[email protected]> * Fixed mgr.GetEventRecorderFor() deprecation (replace with mgr.GetEventRecorder()) Signed-off-by: Shingo Omura <[email protected]> --------- Signed-off-by: Shingo Omura <[email protected]>
56 lines
1.9 KiB
Go
56 lines
1.9 KiB
Go
/*
|
|
Copyright 2026 The Kubeflow authors.
|
|
|
|
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
|
|
|
|
https://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 (
|
|
"context"
|
|
|
|
"sigs.k8s.io/controller-runtime/pkg/log"
|
|
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
|
|
|
|
"github.com/kubeflow/spark-operator/v2/api/v1alpha1"
|
|
operatorscheme "github.com/kubeflow/spark-operator/v2/pkg/scheme"
|
|
)
|
|
|
|
// +kubebuilder:webhook:admissionReviewVersions=v1,failurePolicy=fail,groups=sparkoperator.k8s.io,matchPolicy=Exact,mutating=true,name=mutate-sparkconnect.sparkoperator.k8s.io,path=/mutate-sparkoperator-k8s-io-v1alpha1-sparkconnect,reinvocationPolicy=Never,resources=sparkconnects,sideEffects=None,verbs=create;update,versions=v1alpha1,webhookVersions=v1
|
|
|
|
// SparkConnectDefaulter sets default values for a SparkConnect.
|
|
type SparkConnectDefaulter struct{}
|
|
|
|
// NewSparkConnectDefaulter creates a new SparkConnectDefaulter instance.
|
|
func NewSparkConnectDefaulter() *SparkConnectDefaulter {
|
|
return &SparkConnectDefaulter{}
|
|
}
|
|
|
|
// SparkConnectDefaulter implements admission.CustomDefaulter.
|
|
var _ admission.Defaulter[*v1alpha1.SparkConnect] = &SparkConnectDefaulter{}
|
|
|
|
// Default implements admission.CustomDefaulter.
|
|
func (d *SparkConnectDefaulter) Default(ctx context.Context, sc *v1alpha1.SparkConnect) error {
|
|
if sc == nil {
|
|
return nil
|
|
}
|
|
|
|
logger := log.FromContext(ctx)
|
|
logger.Info("Defaulting SparkConnect", "name", sc.Name, "namespace", sc.Namespace)
|
|
|
|
// Apply scheme defaults
|
|
operatorscheme.WebhookScheme.Default(sc)
|
|
|
|
return nil
|
|
}
|