...
1
16
17 package ingressclass
18
19 import (
20 "context"
21
22 apiequality "k8s.io/apimachinery/pkg/api/equality"
23 "k8s.io/apimachinery/pkg/runtime"
24 "k8s.io/apimachinery/pkg/util/validation/field"
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
33 type ingressClassStrategy struct {
34 runtime.ObjectTyper
35 names.NameGenerator
36 }
37
38
39
40 var Strategy = ingressClassStrategy{legacyscheme.Scheme, names.SimpleNameGenerator}
41
42
43
44 func (ingressClassStrategy) NamespaceScoped() bool {
45 return false
46 }
47
48
49 func (ingressClassStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
50 ingressClass := obj.(*networking.IngressClass)
51 ingressClass.Generation = 1
52 }
53
54
55
56 func (ingressClassStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
57 newIngressClass := obj.(*networking.IngressClass)
58 oldIngressClass := old.(*networking.IngressClass)
59
60
61
62 if !apiequality.Semantic.DeepEqual(oldIngressClass.Spec, newIngressClass.Spec) {
63 newIngressClass.Generation = oldIngressClass.Generation + 1
64 }
65 }
66
67
68 func (ingressClassStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
69 ingressClass := obj.(*networking.IngressClass)
70 return validation.ValidateIngressClass(ingressClass)
71 }
72
73
74 func (ingressClassStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string {
75 return nil
76 }
77
78
79 func (ingressClassStrategy) Canonicalize(obj runtime.Object) {
80 }
81
82
83
84 func (ingressClassStrategy) AllowCreateOnUpdate() bool {
85 return false
86 }
87
88
89 func (ingressClassStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
90 newIngressClass := obj.(*networking.IngressClass)
91 oldIngressClass := old.(*networking.IngressClass)
92
93 return validation.ValidateIngressClassUpdate(newIngressClass, oldIngressClass)
94 }
95
96
97 func (ingressClassStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string {
98 return nil
99 }
100
101
102
103 func (ingressClassStrategy) AllowUnconditionalUpdate() bool {
104 return true
105 }
106
View as plain text