-
Notifications
You must be signed in to change notification settings - Fork 459
/
strategy.go
71 lines (55 loc) · 2.15 KB
/
strategy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors
//
// SPDX-License-Identifier: Apache-2.0
package secretbinding
import (
"context"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/apiserver/pkg/storage/names"
"github.com/gardener/gardener/pkg/api"
"github.com/gardener/gardener/pkg/apis/core"
"github.com/gardener/gardener/pkg/apis/core/validation"
)
type secretBindingStrategy struct {
runtime.ObjectTyper
names.NameGenerator
}
// Strategy defines the storage strategy for SecretBindings.
var Strategy = secretBindingStrategy{api.Scheme, names.SimpleNameGenerator}
func (secretBindingStrategy) NamespaceScoped() bool {
return true
}
func (secretBindingStrategy) PrepareForCreate(_ context.Context, _ runtime.Object) {
}
func (secretBindingStrategy) Validate(_ context.Context, obj runtime.Object) field.ErrorList {
binding := obj.(*core.SecretBinding)
allErrs := field.ErrorList{}
allErrs = append(allErrs, validation.ValidateSecretBinding(binding)...)
allErrs = append(allErrs, validation.ValidateSecretBindingProvider(binding.Provider)...)
return allErrs
}
func (secretBindingStrategy) Canonicalize(_ runtime.Object) {
}
func (secretBindingStrategy) AllowCreateOnUpdate() bool {
return false
}
func (secretBindingStrategy) PrepareForUpdate(_ context.Context, newObj, oldObj runtime.Object) {
_ = oldObj.(*core.SecretBinding)
_ = newObj.(*core.SecretBinding)
}
func (secretBindingStrategy) AllowUnconditionalUpdate() bool {
return true
}
func (secretBindingStrategy) ValidateUpdate(_ context.Context, newObj, oldObj runtime.Object) field.ErrorList {
oldBinding, newBinding := oldObj.(*core.SecretBinding), newObj.(*core.SecretBinding)
return validation.ValidateSecretBindingUpdate(newBinding, oldBinding)
}
// WarningsOnCreate returns warnings to the client performing a create.
func (secretBindingStrategy) WarningsOnCreate(_ context.Context, _ runtime.Object) []string {
return nil
}
// WarningsOnUpdate returns warnings to the client performing the update.
func (secretBindingStrategy) WarningsOnUpdate(_ context.Context, _, _ runtime.Object) []string {
return nil
}