...
1
16
17 package csinode
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/storage"
27 "k8s.io/kubernetes/pkg/apis/storage/validation"
28 )
29
30
31 type csiNodeStrategy struct {
32 runtime.ObjectTyper
33 names.NameGenerator
34 }
35
36
37
38 var Strategy = csiNodeStrategy{legacyscheme.Scheme, names.SimpleNameGenerator}
39
40 func (csiNodeStrategy) NamespaceScoped() bool {
41 return false
42 }
43
44
45 func (csiNodeStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
46 }
47
48 func (csiNodeStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
49 csiNode := obj.(*storage.CSINode)
50 validateOptions := validation.CSINodeValidationOptions{
51 AllowLongNodeID: true,
52 }
53
54 errs := validation.ValidateCSINode(csiNode, validateOptions)
55
56 return errs
57 }
58
59
60 func (csiNodeStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string { return nil }
61
62
63 func (csiNodeStrategy) Canonicalize(obj runtime.Object) {
64 }
65
66 func (csiNodeStrategy) AllowCreateOnUpdate() bool {
67 return false
68 }
69
70
71 func (csiNodeStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
72 }
73
74 func (csiNodeStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
75 newCSINodeObj := obj.(*storage.CSINode)
76 oldCSINodeObj := old.(*storage.CSINode)
77 validateOptions := validation.CSINodeValidationOptions{
78 AllowLongNodeID: true,
79 }
80
81 errorList := validation.ValidateCSINode(newCSINodeObj, validateOptions)
82 return append(errorList, validation.ValidateCSINodeUpdate(newCSINodeObj, oldCSINodeObj, validateOptions)...)
83 }
84
85
86 func (csiNodeStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string {
87 return nil
88 }
89
90 func (csiNodeStrategy) AllowUnconditionalUpdate() bool {
91 return false
92 }
93
View as plain text