...
1
16
17 package runtimeclass
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 nodeapi "k8s.io/kubernetes/pkg/api/node"
28 "k8s.io/kubernetes/pkg/apis/node"
29 "k8s.io/kubernetes/pkg/apis/node/validation"
30 )
31
32
33 type strategy struct {
34 runtime.ObjectTyper
35 names.NameGenerator
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 false
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 }
61
62
63 func (strategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
64 newRuntimeClass := obj.(*node.RuntimeClass)
65 oldRuntimeClass := old.(*node.RuntimeClass)
66
67 _, _ = newRuntimeClass, oldRuntimeClass
68 }
69
70
71 func (strategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
72 runtimeClass := obj.(*node.RuntimeClass)
73 return validation.ValidateRuntimeClass(runtimeClass)
74 }
75
76
77 func (strategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string {
78 return nodeapi.GetWarningsForRuntimeClass(obj.(*node.RuntimeClass))
79 }
80
81
82 func (strategy) Canonicalize(obj runtime.Object) {
83 _ = obj.(*node.RuntimeClass)
84 }
85
86
87 func (strategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
88 newObj := obj.(*node.RuntimeClass)
89 errorList := validation.ValidateRuntimeClass(newObj)
90 return append(errorList, validation.ValidateRuntimeClassUpdate(newObj, old.(*node.RuntimeClass))...)
91 }
92
93
94 func (strategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string {
95 return nodeapi.GetWarningsForRuntimeClass(obj.(*node.RuntimeClass))
96 }
97
98
99
100
101
102
103 func (strategy) AllowUnconditionalUpdate() bool {
104 return false
105 }
106
View as plain text