...
1
16
17 package ipaddress
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/networking"
28 "k8s.io/kubernetes/pkg/apis/networking/validation"
29 )
30
31
32 type ipAddressStrategy struct {
33 runtime.ObjectTyper
34 names.NameGenerator
35 }
36
37
38 type noopNameGenerator struct{}
39
40 func (noopNameGenerator) GenerateName(base string) string {
41 return base
42 }
43
44
45 var Strategy = ipAddressStrategy{legacyscheme.Scheme, noopNameGenerator{}}
46
47
48 var _ rest.RESTCreateStrategy = Strategy
49
50
51 var _ rest.RESTUpdateStrategy = Strategy
52
53
54 func (ipAddressStrategy) NamespaceScoped() bool {
55 return false
56 }
57
58
59 func (ipAddressStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
60 _ = obj.(*networking.IPAddress)
61
62 }
63
64
65 func (ipAddressStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
66 newIPAddress := obj.(*networking.IPAddress)
67 oldIPAddress := old.(*networking.IPAddress)
68
69 _, _ = newIPAddress, oldIPAddress
70 }
71
72
73 func (ipAddressStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
74 ipAddress := obj.(*networking.IPAddress)
75 err := validation.ValidateIPAddress(ipAddress)
76 return err
77 }
78
79
80 func (ipAddressStrategy) Canonicalize(obj runtime.Object) {
81 }
82
83
84 func (ipAddressStrategy) AllowCreateOnUpdate() bool {
85 return false
86 }
87
88
89 func (ipAddressStrategy) ValidateUpdate(ctx context.Context, new, old runtime.Object) field.ErrorList {
90 newIPAddress := new.(*networking.IPAddress)
91 oldIPAddress := old.(*networking.IPAddress)
92 errList := validation.ValidateIPAddress(newIPAddress)
93 errList = append(errList, validation.ValidateIPAddressUpdate(newIPAddress, oldIPAddress)...)
94 return errList
95 }
96
97
98 func (ipAddressStrategy) AllowUnconditionalUpdate() bool {
99 return true
100 }
101
102
103 func (ipAddressStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string {
104 return nil
105 }
106
107
108 func (ipAddressStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string {
109 return nil
110 }
111
View as plain text