...
1
16
17 package lease
18
19 import (
20 "context"
21
22 "k8s.io/apimachinery/pkg/runtime"
23 "k8s.io/apimachinery/pkg/util/validation/field"
24 "k8s.io/apiserver/pkg/storage/names"
25 "k8s.io/kubernetes/pkg/api/legacyscheme"
26 "k8s.io/kubernetes/pkg/apis/coordination"
27 "k8s.io/kubernetes/pkg/apis/coordination/validation"
28 )
29
30
31 type leaseStrategy struct {
32 runtime.ObjectTyper
33 names.NameGenerator
34 }
35
36
37 var Strategy = leaseStrategy{legacyscheme.Scheme, names.SimpleNameGenerator}
38
39
40 func (leaseStrategy) NamespaceScoped() bool {
41 return true
42 }
43
44
45 func (leaseStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
46 }
47
48
49 func (leaseStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
50 }
51
52
53 func (leaseStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
54 lease := obj.(*coordination.Lease)
55 return validation.ValidateLease(lease)
56 }
57
58
59 func (leaseStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string { return nil }
60
61
62 func (leaseStrategy) Canonicalize(obj runtime.Object) {
63 }
64
65
66 func (leaseStrategy) AllowCreateOnUpdate() bool {
67 return true
68 }
69
70
71 func (leaseStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
72 return validation.ValidateLeaseUpdate(obj.(*coordination.Lease), old.(*coordination.Lease))
73 }
74
75
76 func (leaseStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string {
77 return nil
78 }
79
80
81 func (leaseStrategy) AllowUnconditionalUpdate() bool {
82 return false
83 }
84
View as plain text