Update kubernetes libs to latest (#2834)
- k8s.io/api v0.28.1 - k8s.io/apiextensions-apiserver v0.28.1 - k8s.io/apimachinery v0.28.1 - k8s.io/client-go v0.28.1 - k8s.io/metrics v0.28.1 - sigs.k8s.io/controller-runtime v0.16.1 - sigs.k8s.io/controller-tools v0.13.0 Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
@@ -23,6 +23,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/webhook"
|
||||
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
|
||||
|
||||
"github.com/fission/fission/pkg/utils/loggerfactory"
|
||||
)
|
||||
@@ -50,55 +51,55 @@ func (r *Function) Default() {
|
||||
var _ webhook.Validator = &Function{}
|
||||
|
||||
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
|
||||
func (r *Function) ValidateCreate() error {
|
||||
func (r *Function) ValidateCreate() (admission.Warnings, error) {
|
||||
functionlog.Debug("validate create", zap.String("name", r.Name))
|
||||
|
||||
for _, cnfMap := range r.Spec.ConfigMaps {
|
||||
if cnfMap.Namespace != r.ObjectMeta.Namespace {
|
||||
err := fmt.Errorf("ConfigMap's [%s] and function's Namespace [%s] are different. ConfigMap needs to be present in the same namespace as function", cnfMap.Namespace, r.ObjectMeta.Namespace)
|
||||
return AggregateValidationErrors("Function", err)
|
||||
return nil, AggregateValidationErrors("Function", err)
|
||||
}
|
||||
}
|
||||
for _, secret := range r.Spec.Secrets {
|
||||
if secret.Namespace != r.ObjectMeta.Namespace {
|
||||
err := fmt.Errorf("secret [%s] and function's Namespace [%s] are different. Secret needs to be present in the same namespace as function", secret.Namespace, r.ObjectMeta.Namespace)
|
||||
return AggregateValidationErrors("Function", err)
|
||||
return nil, AggregateValidationErrors("Function", err)
|
||||
}
|
||||
}
|
||||
|
||||
err := r.Validate()
|
||||
if err != nil {
|
||||
return AggregateValidationErrors("Function", err)
|
||||
return nil, AggregateValidationErrors("Function", err)
|
||||
}
|
||||
return nil
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
|
||||
func (r *Function) ValidateUpdate(old runtime.Object) error {
|
||||
func (r *Function) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
|
||||
functionlog.Debug("validate update", zap.String("name", r.Name))
|
||||
|
||||
for _, cnfMap := range r.Spec.ConfigMaps {
|
||||
if cnfMap.Namespace != r.ObjectMeta.Namespace {
|
||||
err := fmt.Errorf("ConfigMap's [%s] and function's Namespace [%s] are different. ConfigMap needs to be present in the same namespace as function", cnfMap.Namespace, r.ObjectMeta.Namespace)
|
||||
return AggregateValidationErrors("Function", err)
|
||||
return nil, AggregateValidationErrors("Function", err)
|
||||
}
|
||||
}
|
||||
for _, secret := range r.Spec.Secrets {
|
||||
if secret.Namespace != r.ObjectMeta.Namespace {
|
||||
err := fmt.Errorf("secret [%s] and function's Namespace [%s] are different. Secret needs to be present in the same namespace as function", secret.Namespace, r.ObjectMeta.Namespace)
|
||||
return AggregateValidationErrors("Function", err)
|
||||
return nil, AggregateValidationErrors("Function", err)
|
||||
}
|
||||
}
|
||||
|
||||
err := r.Validate()
|
||||
if err != nil {
|
||||
return AggregateValidationErrors("Function", err)
|
||||
return nil, AggregateValidationErrors("Function", err)
|
||||
}
|
||||
return nil
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
|
||||
func (r *Function) ValidateDelete() error {
|
||||
func (r *Function) ValidateDelete() (admission.Warnings, error) {
|
||||
functionlog.Debug("validate delete", zap.String("name", r.Name))
|
||||
return nil
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user