...
1
16
17 package role
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/registry/rest"
25 "k8s.io/apiserver/pkg/storage/names"
26 "k8s.io/kubernetes/pkg/api/legacyscheme"
27 "k8s.io/kubernetes/pkg/apis/rbac"
28 "k8s.io/kubernetes/pkg/apis/rbac/validation"
29 )
30
31
32 type strategy struct {
33 runtime.ObjectTyper
34 names.NameGenerator
35 }
36
37
38
39 var Strategy = strategy{legacyscheme.Scheme, names.SimpleNameGenerator}
40
41
42 var _ rest.RESTCreateStrategy = Strategy
43
44
45 var _ rest.RESTUpdateStrategy = Strategy
46
47
48 func (strategy) NamespaceScoped() bool {
49 return true
50 }
51
52
53 func (strategy) AllowCreateOnUpdate() bool {
54 return true
55 }
56
57
58
59 func (strategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
60 _ = obj.(*rbac.Role)
61 }
62
63
64 func (strategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
65 newRole := obj.(*rbac.Role)
66 oldRole := old.(*rbac.Role)
67
68 _, _ = newRole, oldRole
69 }
70
71
72 func (strategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
73 role := obj.(*rbac.Role)
74 return validation.ValidateRole(role)
75 }
76
77
78 func (strategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string { return nil }
79
80
81 func (strategy) Canonicalize(obj runtime.Object) {
82 _ = obj.(*rbac.Role)
83 }
84
85
86 func (strategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
87 newObj := obj.(*rbac.Role)
88 errorList := validation.ValidateRole(newObj)
89 return append(errorList, validation.ValidateRoleUpdate(newObj, old.(*rbac.Role))...)
90 }
91
92
93 func (strategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string {
94 return nil
95 }
96
97
98
99
100
101
102 func (strategy) AllowUnconditionalUpdate() bool {
103 return true
104 }
105
View as plain text