...
1
16
17 package resourceclass
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/resource"
27 "k8s.io/kubernetes/pkg/apis/resource/validation"
28 )
29
30
31 type resourceClassStrategy struct {
32 runtime.ObjectTyper
33 names.NameGenerator
34 }
35
36 var Strategy = resourceClassStrategy{legacyscheme.Scheme, names.SimpleNameGenerator}
37
38 func (resourceClassStrategy) NamespaceScoped() bool {
39 return false
40 }
41
42 func (resourceClassStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
43 }
44
45 func (resourceClassStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
46 resourceClass := obj.(*resource.ResourceClass)
47 return validation.ValidateClass(resourceClass)
48 }
49
50 func (resourceClassStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string {
51 return nil
52 }
53
54 func (resourceClassStrategy) Canonicalize(obj runtime.Object) {
55 }
56
57 func (resourceClassStrategy) AllowCreateOnUpdate() bool {
58 return false
59 }
60
61 func (resourceClassStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
62 }
63
64 func (resourceClassStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
65 errorList := validation.ValidateClass(obj.(*resource.ResourceClass))
66 return append(errorList, validation.ValidateClassUpdate(obj.(*resource.ResourceClass), old.(*resource.ResourceClass))...)
67 }
68
69 func (resourceClassStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string {
70 return nil
71 }
72
73 func (resourceClassStrategy) AllowUnconditionalUpdate() bool {
74 return true
75 }
76
View as plain text