...
1
16
17 package controllerrevision
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/apps"
28 "k8s.io/kubernetes/pkg/apis/apps/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 func (strategy) NamespaceScoped() bool {
48 return true
49 }
50
51 func (strategy) Canonicalize(obj runtime.Object) {
52 }
53
54 func (strategy) AllowCreateOnUpdate() bool {
55 return false
56 }
57
58 func (strategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
59 _ = obj.(*apps.ControllerRevision)
60 }
61
62 func (strategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
63 revision := obj.(*apps.ControllerRevision)
64
65 return validation.ValidateControllerRevision(revision)
66 }
67
68
69 func (strategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string { return nil }
70
71 func (strategy) PrepareForUpdate(ctx context.Context, newObj, oldObj runtime.Object) {
72 _ = oldObj.(*apps.ControllerRevision)
73 _ = newObj.(*apps.ControllerRevision)
74 }
75
76 func (strategy) AllowUnconditionalUpdate() bool {
77 return true
78 }
79
80 func (strategy) ValidateUpdate(ctx context.Context, newObj, oldObj runtime.Object) field.ErrorList {
81 oldRevision, newRevision := oldObj.(*apps.ControllerRevision), newObj.(*apps.ControllerRevision)
82 return validation.ValidateControllerRevisionUpdate(newRevision, oldRevision)
83 }
84
85
86 func (strategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string { return nil }
87
View as plain text